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 79 static struct cmdline *testpmd_cl; 80 81 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue); 82 83 /* *** Help command with introduction. *** */ 84 struct cmd_help_brief_result { 85 cmdline_fixed_string_t help; 86 }; 87 88 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result, 89 struct cmdline *cl, 90 __attribute__((unused)) void *data) 91 { 92 cmdline_printf( 93 cl, 94 "\n" 95 "Help is available for the following sections:\n\n" 96 " help control : Start and stop forwarding.\n" 97 " help display : Displaying port, stats and config " 98 "information.\n" 99 " help config : Configuration information.\n" 100 " help ports : Configuring ports.\n" 101 " help registers : Reading and setting port registers.\n" 102 " help filters : Filters configuration help.\n" 103 " help all : All of the above sections.\n\n" 104 ); 105 106 } 107 108 cmdline_parse_token_string_t cmd_help_brief_help = 109 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help"); 110 111 cmdline_parse_inst_t cmd_help_brief = { 112 .f = cmd_help_brief_parsed, 113 .data = NULL, 114 .help_str = "help: Show help", 115 .tokens = { 116 (void *)&cmd_help_brief_help, 117 NULL, 118 }, 119 }; 120 121 /* *** Help command with help sections. *** */ 122 struct cmd_help_long_result { 123 cmdline_fixed_string_t help; 124 cmdline_fixed_string_t section; 125 }; 126 127 static void cmd_help_long_parsed(void *parsed_result, 128 struct cmdline *cl, 129 __attribute__((unused)) void *data) 130 { 131 int show_all = 0; 132 struct cmd_help_long_result *res = parsed_result; 133 134 if (!strcmp(res->section, "all")) 135 show_all = 1; 136 137 if (show_all || !strcmp(res->section, "control")) { 138 139 cmdline_printf( 140 cl, 141 "\n" 142 "Control forwarding:\n" 143 "-------------------\n\n" 144 145 "start\n" 146 " Start packet forwarding with current configuration.\n\n" 147 148 "start tx_first\n" 149 " Start packet forwarding with current config" 150 " after sending one burst of packets.\n\n" 151 152 "stop\n" 153 " Stop packet forwarding, and display accumulated" 154 " statistics.\n\n" 155 156 "quit\n" 157 " Quit to prompt.\n\n" 158 ); 159 } 160 161 if (show_all || !strcmp(res->section, "display")) { 162 163 cmdline_printf( 164 cl, 165 "\n" 166 "Display:\n" 167 "--------\n\n" 168 169 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n" 170 " Display information for port_id, or all.\n\n" 171 172 "show port X rss reta (size) (mask0,mask1,...)\n" 173 " Display the rss redirection table entry indicated" 174 " by masks on port X. size is used to indicate the" 175 " hardware supported reta size\n\n" 176 177 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|" 178 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|" 179 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n" 180 " Display the RSS hash functions and RSS hash key" 181 " of port X\n\n" 182 183 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n" 184 " Clear information for port_id, or all.\n\n" 185 186 "show (rxq|txq) info (port_id) (queue_id)\n" 187 " Display information for configured RX/TX queue.\n\n" 188 189 "show config (rxtx|cores|fwd|txpkts)\n" 190 " Display the given configuration.\n\n" 191 192 "read rxd (port_id) (queue_id) (rxd_id)\n" 193 " Display an RX descriptor of a port RX queue.\n\n" 194 195 "read txd (port_id) (queue_id) (txd_id)\n" 196 " Display a TX descriptor of a port TX queue.\n\n" 197 198 "ddp get list (port_id)\n" 199 " Get ddp profile info list\n\n" 200 201 "ddp get info (profile_path)\n" 202 " Get ddp profile information.\n\n" 203 204 "show vf stats (port_id) (vf_id)\n" 205 " Display a VF's statistics.\n\n" 206 207 "clear vf stats (port_id) (vf_id)\n" 208 " Reset a VF's statistics.\n\n" 209 210 "show port (port_id) pctype mapping\n" 211 " Get flow ptype to pctype mapping on a port\n\n" 212 213 "show port meter stats (port_id) (meter_id) (clear)\n" 214 " Get meter stats on a port\n\n" 215 "show port tm cap (port_id)\n" 216 " Display the port TM capability.\n\n" 217 218 "show port tm level cap (port_id) (level_id)\n" 219 " Display the port TM hierarchical level capability.\n\n" 220 221 "show port tm node cap (port_id) (node_id)\n" 222 " Display the port TM node capability.\n\n" 223 224 "show port tm node type (port_id) (node_id)\n" 225 " Display the port TM node type.\n\n" 226 227 "show port tm node stats (port_id) (node_id) (clear)\n" 228 " Display the port TM node stats.\n\n" 229 230 ); 231 } 232 233 if (show_all || !strcmp(res->section, "config")) { 234 cmdline_printf( 235 cl, 236 "\n" 237 "Configuration:\n" 238 "--------------\n" 239 "Configuration changes only become active when" 240 " forwarding is started/restarted.\n\n" 241 242 "set default\n" 243 " Reset forwarding to the default configuration.\n\n" 244 245 "set verbose (level)\n" 246 " Set the debug verbosity level X.\n\n" 247 248 "set log global|(type) (level)\n" 249 " Set the log level.\n\n" 250 251 "set nbport (num)\n" 252 " Set number of ports.\n\n" 253 254 "set nbcore (num)\n" 255 " Set number of cores.\n\n" 256 257 "set coremask (mask)\n" 258 " Set the forwarding cores hexadecimal mask.\n\n" 259 260 "set portmask (mask)\n" 261 " Set the forwarding ports hexadecimal mask.\n\n" 262 263 "set burst (num)\n" 264 " Set number of packets per burst.\n\n" 265 266 "set burst tx delay (microseconds) retry (num)\n" 267 " Set the transmit delay time and number of retries," 268 " effective when retry is enabled.\n\n" 269 270 "set txpkts (x[,y]*)\n" 271 " Set the length of each segment of TXONLY" 272 " and optionally CSUM packets.\n\n" 273 274 "set txsplit (off|on|rand)\n" 275 " Set the split policy for the TX packets." 276 " Right now only applicable for CSUM and TXONLY" 277 " modes\n\n" 278 279 "set corelist (x[,y]*)\n" 280 " Set the list of forwarding cores.\n\n" 281 282 "set portlist (x[,y]*)\n" 283 " Set the list of forwarding ports.\n\n" 284 285 "set tx loopback (port_id) (on|off)\n" 286 " Enable or disable tx loopback.\n\n" 287 288 "set all queues drop (port_id) (on|off)\n" 289 " Set drop enable bit for all queues.\n\n" 290 291 "set vf split drop (port_id) (vf_id) (on|off)\n" 292 " Set split drop enable bit for a VF from the PF.\n\n" 293 294 "set vf mac antispoof (port_id) (vf_id) (on|off).\n" 295 " Set MAC antispoof for a VF from the PF.\n\n" 296 297 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n" 298 " Enable MACsec offload.\n\n" 299 300 "set macsec offload (port_id) off\n" 301 " Disable MACsec offload.\n\n" 302 303 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n" 304 " Configure MACsec secure connection (SC).\n\n" 305 306 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n" 307 " Configure MACsec secure association (SA).\n\n" 308 309 "set vf broadcast (port_id) (vf_id) (on|off)\n" 310 " Set VF broadcast for a VF from the PF.\n\n" 311 312 "vlan set strip (on|off) (port_id)\n" 313 " Set the VLAN strip on a port.\n\n" 314 315 "vlan set stripq (on|off) (port_id,queue_id)\n" 316 " Set the VLAN strip for a queue on a port.\n\n" 317 318 "set vf vlan stripq (port_id) (vf_id) (on|off)\n" 319 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n" 320 321 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n" 322 " Set VLAN insert for a VF from the PF.\n\n" 323 324 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n" 325 " Set VLAN antispoof for a VF from the PF.\n\n" 326 327 "set vf vlan tag (port_id) (vf_id) (on|off)\n" 328 " Set VLAN tag for a VF from the PF.\n\n" 329 330 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n" 331 " Set a VF's max bandwidth(Mbps).\n\n" 332 333 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n" 334 " Set all TCs' min bandwidth(%%) on a VF.\n\n" 335 336 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n" 337 " Set a TC's max bandwidth(Mbps) on a VF.\n\n" 338 339 "set tx strict-link-priority (port_id) (tc_bitmap)\n" 340 " Set some TCs' strict link priority mode on a physical port.\n\n" 341 342 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n" 343 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n" 344 345 "vlan set filter (on|off) (port_id)\n" 346 " Set the VLAN filter on a port.\n\n" 347 348 "vlan set qinq (on|off) (port_id)\n" 349 " Set the VLAN QinQ (extended queue in queue)" 350 " on a port.\n\n" 351 352 "vlan set (inner|outer) tpid (value) (port_id)\n" 353 " Set the VLAN TPID for Packet Filtering on" 354 " a port\n\n" 355 356 "rx_vlan add (vlan_id|all) (port_id)\n" 357 " Add a vlan_id, or all identifiers, to the set" 358 " of VLAN identifiers filtered by port_id.\n\n" 359 360 "rx_vlan rm (vlan_id|all) (port_id)\n" 361 " Remove a vlan_id, or all identifiers, from the set" 362 " of VLAN identifiers filtered by port_id.\n\n" 363 364 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n" 365 " Add a vlan_id, to the set of VLAN identifiers" 366 "filtered for VF(s) from port_id.\n\n" 367 368 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n" 369 " Remove a vlan_id, to the set of VLAN identifiers" 370 "filtered for VF(s) from port_id.\n\n" 371 372 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) " 373 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|" 374 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 375 " add a tunnel filter of a port.\n\n" 376 377 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) " 378 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|" 379 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 380 " remove a tunnel filter of a port.\n\n" 381 382 "rx_vxlan_port add (udp_port) (port_id)\n" 383 " Add an UDP port for VXLAN packet filter on a port\n\n" 384 385 "rx_vxlan_port rm (udp_port) (port_id)\n" 386 " Remove an UDP port for VXLAN packet filter on a port\n\n" 387 388 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n" 389 " Set hardware insertion of VLAN IDs (single or double VLAN " 390 "depends on the number of VLAN IDs) in packets sent on a port.\n\n" 391 392 "tx_vlan set pvid port_id vlan_id (on|off)\n" 393 " Set port based TX VLAN insertion.\n\n" 394 395 "tx_vlan reset (port_id)\n" 396 " Disable hardware insertion of a VLAN header in" 397 " packets sent on a port.\n\n" 398 399 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n" 400 " Select hardware or software calculation of the" 401 " checksum when transmitting a packet using the" 402 " csum forward engine.\n" 403 " ip|udp|tcp|sctp always concern the inner layer.\n" 404 " outer-ip concerns the outer IP layer in" 405 " case the packet is recognized as a tunnel packet by" 406 " the forward engine (vxlan, gre and ipip are supported)\n" 407 " Please check the NIC datasheet for HW limits.\n\n" 408 409 "csum parse-tunnel (on|off) (tx_port_id)\n" 410 " If disabled, treat tunnel packets as non-tunneled" 411 " packets (treat inner headers as payload). The port\n" 412 " argument is the port used for TX in csum forward" 413 " engine.\n\n" 414 415 "csum show (port_id)\n" 416 " Display tx checksum offload configuration\n\n" 417 418 "tso set (segsize) (portid)\n" 419 " Enable TCP Segmentation Offload in csum forward" 420 " engine.\n" 421 " Please check the NIC datasheet for HW limits.\n\n" 422 423 "tso show (portid)" 424 " Display the status of TCP Segmentation Offload.\n\n" 425 426 "set port (port_id) gro on|off\n" 427 " Enable or disable Generic Receive Offload in" 428 " csum forwarding engine.\n\n" 429 430 "show port (port_id) gro\n" 431 " Display GRO configuration.\n\n" 432 433 "set gro flush (cycles)\n" 434 " Set the cycle to flush GROed packets from" 435 " reassembly tables.\n\n" 436 437 "set port (port_id) gso (on|off)" 438 " Enable or disable Generic Segmentation Offload in" 439 " csum forwarding engine.\n\n" 440 441 "set gso segsz (length)\n" 442 " Set max packet length for output GSO segments," 443 " including packet header and payload.\n\n" 444 445 "show port (port_id) gso\n" 446 " Show GSO configuration.\n\n" 447 448 "set fwd (%s)\n" 449 " Set packet forwarding mode.\n\n" 450 451 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n" 452 " Add a MAC address on port_id.\n\n" 453 454 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n" 455 " Remove a MAC address from port_id.\n\n" 456 457 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n" 458 " Set the default MAC address for port_id.\n\n" 459 460 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n" 461 " Add a MAC address for a VF on the port.\n\n" 462 463 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n" 464 " Set the MAC address for a VF from the PF.\n\n" 465 466 "set eth-peer (port_id) (peer_addr)\n" 467 " set the peer address for certain port.\n\n" 468 469 "set port (port_id) uta (mac_address|all) (on|off)\n" 470 " Add/Remove a or all unicast hash filter(s)" 471 "from port X.\n\n" 472 473 "set promisc (port_id|all) (on|off)\n" 474 " Set the promiscuous mode on port_id, or all.\n\n" 475 476 "set allmulti (port_id|all) (on|off)\n" 477 " Set the allmulti mode on port_id, or all.\n\n" 478 479 "set vf promisc (port_id) (vf_id) (on|off)\n" 480 " Set unicast promiscuous mode for a VF from the PF.\n\n" 481 482 "set vf allmulti (port_id) (vf_id) (on|off)\n" 483 " Set multicast promiscuous mode for a VF from the PF.\n\n" 484 485 "set flow_ctrl rx (on|off) tx (on|off) (high_water)" 486 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd" 487 " (on|off) autoneg (on|off) (port_id)\n" 488 "set flow_ctrl rx (on|off) (portid)\n" 489 "set flow_ctrl tx (on|off) (portid)\n" 490 "set flow_ctrl high_water (high_water) (portid)\n" 491 "set flow_ctrl low_water (low_water) (portid)\n" 492 "set flow_ctrl pause_time (pause_time) (portid)\n" 493 "set flow_ctrl send_xon (send_xon) (portid)\n" 494 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n" 495 "set flow_ctrl autoneg (on|off) (port_id)\n" 496 " Set the link flow control parameter on a port.\n\n" 497 498 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)" 499 " (low_water) (pause_time) (priority) (port_id)\n" 500 " Set the priority flow control parameter on a" 501 " port.\n\n" 502 503 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n" 504 " Set statistics mapping (qmapping 0..15) for RX/TX" 505 " queue on port.\n" 506 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2" 507 " on port 0 to mapping 5.\n\n" 508 509 "set xstats-hide-zero on|off\n" 510 " Set the option to hide the zero values" 511 " for xstats display.\n" 512 513 "set port (port_id) vf (vf_id) rx|tx on|off\n" 514 " Enable/Disable a VF receive/tranmit from a port\n\n" 515 516 "set port (port_id) vf (vf_id) (mac_addr)" 517 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n" 518 " Add/Remove unicast or multicast MAC addr filter" 519 " for a VF.\n\n" 520 521 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM" 522 "|MPE) (on|off)\n" 523 " AUPE:accepts untagged VLAN;" 524 "ROPE:accept unicast hash\n\n" 525 " BAM:accepts broadcast packets;" 526 "MPE:accepts all multicast packets\n\n" 527 " Enable/Disable a VF receive mode of a port\n\n" 528 529 "set port (port_id) queue (queue_id) rate (rate_num)\n" 530 " Set rate limit for a queue of a port\n\n" 531 532 "set port (port_id) vf (vf_id) rate (rate_num) " 533 "queue_mask (queue_mask_value)\n" 534 " Set rate limit for queues in VF of a port\n\n" 535 536 "set port (port_id) mirror-rule (rule_id)" 537 " (pool-mirror-up|pool-mirror-down|vlan-mirror)" 538 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n" 539 " Set pool or vlan type mirror rule on a port.\n" 540 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1" 541 " dst-pool 0 on' enable mirror traffic with vlan 0,1" 542 " to pool 0.\n\n" 543 544 "set port (port_id) mirror-rule (rule_id)" 545 " (uplink-mirror|downlink-mirror) dst-pool" 546 " (pool_id) (on|off)\n" 547 " Set uplink or downlink type mirror rule on a port.\n" 548 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool" 549 " 0 on' enable mirror income traffic to pool 0.\n\n" 550 551 "reset port (port_id) mirror-rule (rule_id)\n" 552 " Reset a mirror rule.\n\n" 553 554 "set flush_rx (on|off)\n" 555 " Flush (default) or don't flush RX streams before" 556 " forwarding. Mainly used with PCAP drivers.\n\n" 557 558 "set bypass mode (normal|bypass|isolate) (port_id)\n" 559 " Set the bypass mode for the lowest port on bypass enabled" 560 " NIC.\n\n" 561 562 "set bypass event (timeout|os_on|os_off|power_on|power_off) " 563 "mode (normal|bypass|isolate) (port_id)\n" 564 " Set the event required to initiate specified bypass mode for" 565 " the lowest port on a bypass enabled NIC where:\n" 566 " timeout = enable bypass after watchdog timeout.\n" 567 " os_on = enable bypass when OS/board is powered on.\n" 568 " os_off = enable bypass when OS/board is powered off.\n" 569 " power_on = enable bypass when power supply is turned on.\n" 570 " power_off = enable bypass when power supply is turned off." 571 "\n\n" 572 573 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n" 574 " Set the bypass watchdog timeout to 'n' seconds" 575 " where 0 = instant.\n\n" 576 577 "show bypass config (port_id)\n" 578 " Show the bypass configuration for a bypass enabled NIC" 579 " using the lowest port on the NIC.\n\n" 580 581 #ifdef RTE_LIBRTE_PMD_BOND 582 "create bonded device (mode) (socket)\n" 583 " Create a new bonded device with specific bonding mode and socket.\n\n" 584 585 "add bonding slave (slave_id) (port_id)\n" 586 " Add a slave device to a bonded device.\n\n" 587 588 "remove bonding slave (slave_id) (port_id)\n" 589 " Remove a slave device from a bonded device.\n\n" 590 591 "set bonding mode (value) (port_id)\n" 592 " Set the bonding mode on a bonded device.\n\n" 593 594 "set bonding primary (slave_id) (port_id)\n" 595 " Set the primary slave for a bonded device.\n\n" 596 597 "show bonding config (port_id)\n" 598 " Show the bonding config for port_id.\n\n" 599 600 "set bonding mac_addr (port_id) (address)\n" 601 " Set the MAC address of a bonded device.\n\n" 602 603 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)" 604 " Set Aggregation mode for IEEE802.3AD (mode 4)" 605 606 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n" 607 " Set the transmit balance policy for bonded device running in balance mode.\n\n" 608 609 "set bonding mon_period (port_id) (value)\n" 610 " Set the bonding link status monitoring polling period in ms.\n\n" 611 612 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n" 613 " Enable/disable dedicated queues for LACP control traffic.\n\n" 614 615 #endif 616 "set link-up port (port_id)\n" 617 " Set link up for a port.\n\n" 618 619 "set link-down port (port_id)\n" 620 " Set link down for a port.\n\n" 621 622 "E-tag set insertion on port-tag-id (value)" 623 " port (port_id) vf (vf_id)\n" 624 " Enable E-tag insertion for a VF on a port\n\n" 625 626 "E-tag set insertion off port (port_id) vf (vf_id)\n" 627 " Disable E-tag insertion for a VF on a port\n\n" 628 629 "E-tag set stripping (on|off) port (port_id)\n" 630 " Enable/disable E-tag stripping on a port\n\n" 631 632 "E-tag set forwarding (on|off) port (port_id)\n" 633 " Enable/disable E-tag based forwarding" 634 " on a port\n\n" 635 636 "E-tag set filter add e-tag-id (value) dst-pool" 637 " (pool_id) port (port_id)\n" 638 " Add an E-tag forwarding filter on a port\n\n" 639 640 "E-tag set filter del e-tag-id (value) port (port_id)\n" 641 " Delete an E-tag forwarding filter on a port\n\n" 642 643 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 644 "set port tm hierarchy default (port_id)\n" 645 " Set default traffic Management hierarchy on a port\n\n" 646 647 #endif 648 "ddp add (port_id) (profile_path[,backup_profile_path])\n" 649 " Load a profile package on a port\n\n" 650 651 "ddp del (port_id) (backup_profile_path)\n" 652 " Delete a profile package from a port\n\n" 653 654 "ptype mapping get (port_id) (valid_only)\n" 655 " Get ptype mapping on a port\n\n" 656 657 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n" 658 " Replace target with the pkt_type in ptype mapping\n\n" 659 660 "ptype mapping reset (port_id)\n" 661 " Reset ptype mapping on a port\n\n" 662 663 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n" 664 " Update a ptype mapping item on a port\n\n" 665 666 "set port (port_id) queue-region region_id (value) " 667 "queue_start_index (value) queue_num (value)\n" 668 " Set a queue region on a port\n\n" 669 670 "set port (port_id) queue-region region_id (value) " 671 "flowtype (value)\n" 672 " Set a flowtype region index on a port\n\n" 673 674 "set port (port_id) queue-region UP (value) region_id (value)\n" 675 " Set the mapping of User Priority to " 676 "queue region on a port\n\n" 677 678 "set port (port_id) queue-region flush (on|off)\n" 679 " flush all queue region related configuration\n\n" 680 681 "show port meter cap (port_id)\n" 682 " Show port meter capability information\n\n" 683 684 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n" 685 " meter profile add - srtcm rfc 2697\n\n" 686 687 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n" 688 " meter profile add - trtcm rfc 2698\n\n" 689 690 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n" 691 " meter profile add - trtcm rfc 4115\n\n" 692 693 "del port meter profile (port_id) (profile_id)\n" 694 " meter profile delete\n\n" 695 696 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n" 697 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n" 698 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" 699 "(dscp_tbl_entry63)]\n" 700 " meter create\n\n" 701 702 "enable port meter (port_id) (mtr_id)\n" 703 " meter enable\n\n" 704 705 "disable port meter (port_id) (mtr_id)\n" 706 " meter disable\n\n" 707 708 "del port meter (port_id) (mtr_id)\n" 709 " meter delete\n\n" 710 711 "set port meter profile (port_id) (mtr_id) (profile_id)\n" 712 " meter update meter profile\n\n" 713 714 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n" 715 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n" 716 " update meter dscp table entries\n\n" 717 718 "set port meter policer action (port_id) (mtr_id) (action_mask)\n" 719 "(action0) [(action1) (action2)]\n" 720 " meter update policer action\n\n" 721 722 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n" 723 " meter update stats\n\n" 724 725 "show port (port_id) queue-region\n" 726 " show all queue region related configuration info\n\n" 727 728 "add port tm node shaper profile (port_id) (shaper_profile_id)" 729 " (tb_rate) (tb_size) (packet_length_adjust)\n" 730 " Add port tm node private shaper profile.\n\n" 731 732 "del port tm node shaper profile (port_id) (shaper_profile_id)\n" 733 " Delete port tm node private shaper profile.\n\n" 734 735 "add port tm node shared shaper (port_id) (shared_shaper_id)" 736 " (shaper_profile_id)\n" 737 " Add/update port tm node shared shaper.\n\n" 738 739 "del port tm node shared shaper (port_id) (shared_shaper_id)\n" 740 " Delete port tm node shared shaper.\n\n" 741 742 "set port tm node shaper profile (port_id) (node_id)" 743 " (shaper_profile_id)\n" 744 " Set port tm node shaper profile.\n\n" 745 746 "add port tm node wred profile (port_id) (wred_profile_id)" 747 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)" 748 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)" 749 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n" 750 " Add port tm node wred profile.\n\n" 751 752 "del port tm node wred profile (port_id) (wred_profile_id)\n" 753 " Delete port tm node wred profile.\n\n" 754 755 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)" 756 " (priority) (weight) (level_id) (shaper_profile_id)" 757 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 758 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 759 " Add port tm nonleaf node.\n\n" 760 761 "add port tm leaf node (port_id) (node_id) (parent_node_id)" 762 " (priority) (weight) (level_id) (shaper_profile_id)" 763 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)" 764 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 765 " Add port tm leaf node.\n\n" 766 767 "del port tm node (port_id) (node_id)\n" 768 " Delete port tm node.\n\n" 769 770 "set port tm node parent (port_id) (node_id) (parent_node_id)" 771 " (priority) (weight)\n" 772 " Set port tm node parent.\n\n" 773 774 "suspend port tm node (port_id) (node_id)" 775 " Suspend tm node.\n\n" 776 777 "resume port tm node (port_id) (node_id)" 778 " Resume tm node.\n\n" 779 780 "port tm hierarchy commit (port_id) (clean_on_fail)\n" 781 " Commit tm hierarchy.\n\n" 782 783 , list_pkt_forwarding_modes() 784 ); 785 } 786 787 if (show_all || !strcmp(res->section, "ports")) { 788 789 cmdline_printf( 790 cl, 791 "\n" 792 "Port Operations:\n" 793 "----------------\n\n" 794 795 "port start (port_id|all)\n" 796 " Start all ports or port_id.\n\n" 797 798 "port stop (port_id|all)\n" 799 " Stop all ports or port_id.\n\n" 800 801 "port close (port_id|all)\n" 802 " Close all ports or port_id.\n\n" 803 804 "port attach (ident)\n" 805 " Attach physical or virtual dev by pci address or virtual device name\n\n" 806 807 "port detach (port_id)\n" 808 " Detach physical or virtual dev by port_id\n\n" 809 810 "port config (port_id|all)" 811 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)" 812 " duplex (half|full|auto)\n" 813 " Set speed and duplex for all ports or port_id\n\n" 814 815 "port config (port_id|all) loopback (mode)\n" 816 " Set loopback mode for all ports or port_id\n\n" 817 818 "port config all (rxq|txq|rxd|txd) (value)\n" 819 " Set number for rxq/txq/rxd/txd.\n\n" 820 821 "port config all max-pkt-len (value)\n" 822 " Set the max packet length.\n\n" 823 824 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|" 825 "hw-vlan-strip|hw-vlan-extend|drop-en)" 826 " (on|off)\n" 827 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en" 828 " for ports.\n\n" 829 830 "port config all rss (all|default|ip|tcp|udp|sctp|" 831 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n" 832 " Set the RSS mode.\n\n" 833 834 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" 835 " Set the RSS redirection table.\n\n" 836 837 "port config (port_id) dcb vt (on|off) (traffic_class)" 838 " pfc (on|off)\n" 839 " Set the DCB mode.\n\n" 840 841 "port config all burst (value)\n" 842 " Set the number of packets per burst.\n\n" 843 844 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)" 845 " (value)\n" 846 " Set the ring prefetch/host/writeback threshold" 847 " for tx/rx queue.\n\n" 848 849 "port config all (txfreet|txrst|rxfreet) (value)\n" 850 " Set free threshold for rx/tx, or set" 851 " tx rs bit threshold.\n\n" 852 "port config mtu X value\n" 853 " Set the MTU of port X to a given value\n\n" 854 855 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n" 856 " Set a rx/tx queue's ring size configuration, the new" 857 " value will take effect after command that (re-)start the port" 858 " or command that setup the specific queue\n\n" 859 860 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n" 861 " Start/stop a rx/tx queue of port X. Only take effect" 862 " when port X is started\n\n" 863 864 "port (port_id) (rxq|txq) (queue_id) setup\n" 865 " Setup a rx/tx queue of port X.\n\n" 866 867 "port config (port_id|all) l2-tunnel E-tag ether-type" 868 " (value)\n" 869 " Set the value of E-tag ether-type.\n\n" 870 871 "port config (port_id|all) l2-tunnel E-tag" 872 " (enable|disable)\n" 873 " Enable/disable the E-tag support.\n\n" 874 875 "port config (port_id) pctype mapping reset\n" 876 " Reset flow type to pctype mapping on a port\n\n" 877 878 "port config (port_id) pctype mapping update" 879 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n" 880 " Update a flow type to pctype mapping item on a port\n\n" 881 882 "port config (port_id) pctype (pctype_id) hash_inset|" 883 "fdir_inset|fdir_flx_inset get|set|clear field\n" 884 " (field_idx)\n" 885 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n" 886 887 "port config (port_id) pctype (pctype_id) hash_inset|" 888 "fdir_inset|fdir_flx_inset clear all" 889 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n" 890 891 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n" 892 " Add/remove UDP tunnel port for tunneling offload\n\n" 893 ); 894 } 895 896 if (show_all || !strcmp(res->section, "registers")) { 897 898 cmdline_printf( 899 cl, 900 "\n" 901 "Registers:\n" 902 "----------\n\n" 903 904 "read reg (port_id) (address)\n" 905 " Display value of a port register.\n\n" 906 907 "read regfield (port_id) (address) (bit_x) (bit_y)\n" 908 " Display a port register bit field.\n\n" 909 910 "read regbit (port_id) (address) (bit_x)\n" 911 " Display a single port register bit.\n\n" 912 913 "write reg (port_id) (address) (value)\n" 914 " Set value of a port register.\n\n" 915 916 "write regfield (port_id) (address) (bit_x) (bit_y)" 917 " (value)\n" 918 " Set bit field of a port register.\n\n" 919 920 "write regbit (port_id) (address) (bit_x) (value)\n" 921 " Set single bit value of a port register.\n\n" 922 ); 923 } 924 if (show_all || !strcmp(res->section, "filters")) { 925 926 cmdline_printf( 927 cl, 928 "\n" 929 "filters:\n" 930 "--------\n\n" 931 932 "ethertype_filter (port_id) (add|del)" 933 " (mac_addr|mac_ignr) (mac_address) ethertype" 934 " (ether_type) (drop|fwd) queue (queue_id)\n" 935 " Add/Del an ethertype filter.\n\n" 936 937 "2tuple_filter (port_id) (add|del)" 938 " dst_port (dst_port_value) protocol (protocol_value)" 939 " mask (mask_value) tcp_flags (tcp_flags_value)" 940 " priority (prio_value) queue (queue_id)\n" 941 " Add/Del a 2tuple filter.\n\n" 942 943 "5tuple_filter (port_id) (add|del)" 944 " dst_ip (dst_address) src_ip (src_address)" 945 " dst_port (dst_port_value) src_port (src_port_value)" 946 " protocol (protocol_value)" 947 " mask (mask_value) tcp_flags (tcp_flags_value)" 948 " priority (prio_value) queue (queue_id)\n" 949 " Add/Del a 5tuple filter.\n\n" 950 951 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)" 952 " Add/Del syn filter.\n\n" 953 954 "flex_filter (port_id) (add|del) len (len_value)" 955 " bytes (bytes_value) mask (mask_value)" 956 " priority (prio_value) queue (queue_id)\n" 957 " Add/Del a flex filter.\n\n" 958 959 "flow_director_filter (port_id) mode IP (add|del|update)" 960 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)" 961 " src (src_ip_address) dst (dst_ip_address)" 962 " tos (tos_value) proto (proto_value) ttl (ttl_value)" 963 " vlan (vlan_value) flexbytes (flexbytes_value)" 964 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 965 " fd_id (fd_id_value)\n" 966 " Add/Del an IP type flow director filter.\n\n" 967 968 "flow_director_filter (port_id) mode IP (add|del|update)" 969 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)" 970 " src (src_ip_address) (src_port)" 971 " dst (dst_ip_address) (dst_port)" 972 " tos (tos_value) ttl (ttl_value)" 973 " vlan (vlan_value) flexbytes (flexbytes_value)" 974 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 975 " fd_id (fd_id_value)\n" 976 " Add/Del an UDP/TCP type flow director filter.\n\n" 977 978 "flow_director_filter (port_id) mode IP (add|del|update)" 979 " flow (ipv4-sctp|ipv6-sctp)" 980 " src (src_ip_address) (src_port)" 981 " dst (dst_ip_address) (dst_port)" 982 " tag (verification_tag) " 983 " tos (tos_value) ttl (ttl_value)" 984 " vlan (vlan_value)" 985 " flexbytes (flexbytes_value) (drop|fwd)" 986 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 987 " Add/Del a SCTP type flow director filter.\n\n" 988 989 "flow_director_filter (port_id) mode IP (add|del|update)" 990 " flow l2_payload ether (ethertype)" 991 " flexbytes (flexbytes_value) (drop|fwd)" 992 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 993 " Add/Del a l2 payload type flow director filter.\n\n" 994 995 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)" 996 " mac (mac_address) vlan (vlan_value)" 997 " flexbytes (flexbytes_value) (drop|fwd)" 998 " queue (queue_id) fd_id (fd_id_value)\n" 999 " Add/Del a MAC-VLAN flow director filter.\n\n" 1000 1001 "flow_director_filter (port_id) mode Tunnel (add|del|update)" 1002 " mac (mac_address) vlan (vlan_value)" 1003 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)" 1004 " flexbytes (flexbytes_value) (drop|fwd)" 1005 " queue (queue_id) fd_id (fd_id_value)\n" 1006 " Add/Del a Tunnel flow director filter.\n\n" 1007 1008 "flow_director_filter (port_id) mode raw (add|del|update)" 1009 " flow (flow_id) (drop|fwd) queue (queue_id)" 1010 " fd_id (fd_id_value) packet (packet file name)\n" 1011 " Add/Del a raw type flow director filter.\n\n" 1012 1013 "flush_flow_director (port_id)\n" 1014 " Flush all flow director entries of a device.\n\n" 1015 1016 "flow_director_mask (port_id) mode IP vlan (vlan_value)" 1017 " src_mask (ipv4_src) (ipv6_src) (src_port)" 1018 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n" 1019 " Set flow director IP mask.\n\n" 1020 1021 "flow_director_mask (port_id) mode MAC-VLAN" 1022 " vlan (vlan_value)\n" 1023 " Set flow director MAC-VLAN mask.\n\n" 1024 1025 "flow_director_mask (port_id) mode Tunnel" 1026 " vlan (vlan_value) mac (mac_value)" 1027 " tunnel-type (tunnel_type_value)" 1028 " tunnel-id (tunnel_id_value)\n" 1029 " Set flow director Tunnel mask.\n\n" 1030 1031 "flow_director_flex_mask (port_id)" 1032 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 1033 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)" 1034 " (mask)\n" 1035 " Configure mask of flex payload.\n\n" 1036 1037 "flow_director_flex_payload (port_id)" 1038 " (raw|l2|l3|l4) (config)\n" 1039 " Configure flex payload selection.\n\n" 1040 1041 "get_sym_hash_ena_per_port (port_id)\n" 1042 " get symmetric hash enable configuration per port.\n\n" 1043 1044 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n" 1045 " set symmetric hash enable configuration per port" 1046 " to enable or disable.\n\n" 1047 1048 "get_hash_global_config (port_id)\n" 1049 " Get the global configurations of hash filters.\n\n" 1050 1051 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)" 1052 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1053 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)" 1054 " (enable|disable)\n" 1055 " Set the global configurations of hash filters.\n\n" 1056 1057 "set_hash_input_set (port_id) (ipv4|ipv4-frag|" 1058 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1059 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1060 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|" 1061 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|" 1062 "ipv6-next-header|udp-src-port|udp-dst-port|" 1063 "tcp-src-port|tcp-dst-port|sctp-src-port|" 1064 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|" 1065 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|" 1066 "fld-8th|none) (select|add)\n" 1067 " Set the input set for hash.\n\n" 1068 1069 "set_fdir_input_set (port_id) " 1070 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 1071 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1072 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|" 1073 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|" 1074 "ipv6-next-header|ipv6-hop-limits|udp-src-port|" 1075 "udp-dst-port|tcp-src-port|tcp-dst-port|" 1076 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)" 1077 " (select|add)\n" 1078 " Set the input set for FDir.\n\n" 1079 1080 "flow validate {port_id}" 1081 " [group {group_id}] [priority {level}]" 1082 " [ingress] [egress]" 1083 " pattern {item} [/ {item} [...]] / end" 1084 " actions {action} [/ {action} [...]] / end\n" 1085 " Check whether a flow rule can be created.\n\n" 1086 1087 "flow create {port_id}" 1088 " [group {group_id}] [priority {level}]" 1089 " [ingress] [egress]" 1090 " pattern {item} [/ {item} [...]] / end" 1091 " actions {action} [/ {action} [...]] / end\n" 1092 " Create a flow rule.\n\n" 1093 1094 "flow destroy {port_id} rule {rule_id} [...]\n" 1095 " Destroy specific flow rules.\n\n" 1096 1097 "flow flush {port_id}\n" 1098 " Destroy all flow rules.\n\n" 1099 1100 "flow query {port_id} {rule_id} {action}\n" 1101 " Query an existing flow rule.\n\n" 1102 1103 "flow list {port_id} [group {group_id}] [...]\n" 1104 " List existing flow rules sorted by priority," 1105 " filtered by group identifiers.\n\n" 1106 1107 "flow isolate {port_id} {boolean}\n" 1108 " Restrict ingress traffic to the defined" 1109 " flow rules\n\n" 1110 ); 1111 } 1112 } 1113 1114 cmdline_parse_token_string_t cmd_help_long_help = 1115 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help"); 1116 1117 cmdline_parse_token_string_t cmd_help_long_section = 1118 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section, 1119 "all#control#display#config#" 1120 "ports#registers#filters"); 1121 1122 cmdline_parse_inst_t cmd_help_long = { 1123 .f = cmd_help_long_parsed, 1124 .data = NULL, 1125 .help_str = "help all|control|display|config|ports|register|filters: " 1126 "Show help", 1127 .tokens = { 1128 (void *)&cmd_help_long_help, 1129 (void *)&cmd_help_long_section, 1130 NULL, 1131 }, 1132 }; 1133 1134 1135 /* *** start/stop/close all ports *** */ 1136 struct cmd_operate_port_result { 1137 cmdline_fixed_string_t keyword; 1138 cmdline_fixed_string_t name; 1139 cmdline_fixed_string_t value; 1140 }; 1141 1142 static void cmd_operate_port_parsed(void *parsed_result, 1143 __attribute__((unused)) struct cmdline *cl, 1144 __attribute__((unused)) void *data) 1145 { 1146 struct cmd_operate_port_result *res = parsed_result; 1147 1148 if (!strcmp(res->name, "start")) 1149 start_port(RTE_PORT_ALL); 1150 else if (!strcmp(res->name, "stop")) 1151 stop_port(RTE_PORT_ALL); 1152 else if (!strcmp(res->name, "close")) 1153 close_port(RTE_PORT_ALL); 1154 else if (!strcmp(res->name, "reset")) 1155 reset_port(RTE_PORT_ALL); 1156 else 1157 printf("Unknown parameter\n"); 1158 } 1159 1160 cmdline_parse_token_string_t cmd_operate_port_all_cmd = 1161 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword, 1162 "port"); 1163 cmdline_parse_token_string_t cmd_operate_port_all_port = 1164 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name, 1165 "start#stop#close#reset"); 1166 cmdline_parse_token_string_t cmd_operate_port_all_all = 1167 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all"); 1168 1169 cmdline_parse_inst_t cmd_operate_port = { 1170 .f = cmd_operate_port_parsed, 1171 .data = NULL, 1172 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports", 1173 .tokens = { 1174 (void *)&cmd_operate_port_all_cmd, 1175 (void *)&cmd_operate_port_all_port, 1176 (void *)&cmd_operate_port_all_all, 1177 NULL, 1178 }, 1179 }; 1180 1181 /* *** start/stop/close specific port *** */ 1182 struct cmd_operate_specific_port_result { 1183 cmdline_fixed_string_t keyword; 1184 cmdline_fixed_string_t name; 1185 uint8_t value; 1186 }; 1187 1188 static void cmd_operate_specific_port_parsed(void *parsed_result, 1189 __attribute__((unused)) struct cmdline *cl, 1190 __attribute__((unused)) void *data) 1191 { 1192 struct cmd_operate_specific_port_result *res = parsed_result; 1193 1194 if (!strcmp(res->name, "start")) 1195 start_port(res->value); 1196 else if (!strcmp(res->name, "stop")) 1197 stop_port(res->value); 1198 else if (!strcmp(res->name, "close")) 1199 close_port(res->value); 1200 else if (!strcmp(res->name, "reset")) 1201 reset_port(res->value); 1202 else 1203 printf("Unknown parameter\n"); 1204 } 1205 1206 cmdline_parse_token_string_t cmd_operate_specific_port_cmd = 1207 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1208 keyword, "port"); 1209 cmdline_parse_token_string_t cmd_operate_specific_port_port = 1210 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1211 name, "start#stop#close#reset"); 1212 cmdline_parse_token_num_t cmd_operate_specific_port_id = 1213 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result, 1214 value, UINT8); 1215 1216 cmdline_parse_inst_t cmd_operate_specific_port = { 1217 .f = cmd_operate_specific_port_parsed, 1218 .data = NULL, 1219 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id", 1220 .tokens = { 1221 (void *)&cmd_operate_specific_port_cmd, 1222 (void *)&cmd_operate_specific_port_port, 1223 (void *)&cmd_operate_specific_port_id, 1224 NULL, 1225 }, 1226 }; 1227 1228 /* *** attach a specified port *** */ 1229 struct cmd_operate_attach_port_result { 1230 cmdline_fixed_string_t port; 1231 cmdline_fixed_string_t keyword; 1232 cmdline_fixed_string_t identifier; 1233 }; 1234 1235 static void cmd_operate_attach_port_parsed(void *parsed_result, 1236 __attribute__((unused)) struct cmdline *cl, 1237 __attribute__((unused)) void *data) 1238 { 1239 struct cmd_operate_attach_port_result *res = parsed_result; 1240 1241 if (!strcmp(res->keyword, "attach")) 1242 attach_port(res->identifier); 1243 else 1244 printf("Unknown parameter\n"); 1245 } 1246 1247 cmdline_parse_token_string_t cmd_operate_attach_port_port = 1248 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1249 port, "port"); 1250 cmdline_parse_token_string_t cmd_operate_attach_port_keyword = 1251 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1252 keyword, "attach"); 1253 cmdline_parse_token_string_t cmd_operate_attach_port_identifier = 1254 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1255 identifier, NULL); 1256 1257 cmdline_parse_inst_t cmd_operate_attach_port = { 1258 .f = cmd_operate_attach_port_parsed, 1259 .data = NULL, 1260 .help_str = "port attach <identifier>: " 1261 "(identifier: pci address or virtual dev name)", 1262 .tokens = { 1263 (void *)&cmd_operate_attach_port_port, 1264 (void *)&cmd_operate_attach_port_keyword, 1265 (void *)&cmd_operate_attach_port_identifier, 1266 NULL, 1267 }, 1268 }; 1269 1270 /* *** detach a specified port *** */ 1271 struct cmd_operate_detach_port_result { 1272 cmdline_fixed_string_t port; 1273 cmdline_fixed_string_t keyword; 1274 portid_t port_id; 1275 }; 1276 1277 static void cmd_operate_detach_port_parsed(void *parsed_result, 1278 __attribute__((unused)) struct cmdline *cl, 1279 __attribute__((unused)) void *data) 1280 { 1281 struct cmd_operate_detach_port_result *res = parsed_result; 1282 1283 if (!strcmp(res->keyword, "detach")) 1284 detach_port(res->port_id); 1285 else 1286 printf("Unknown parameter\n"); 1287 } 1288 1289 cmdline_parse_token_string_t cmd_operate_detach_port_port = 1290 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1291 port, "port"); 1292 cmdline_parse_token_string_t cmd_operate_detach_port_keyword = 1293 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1294 keyword, "detach"); 1295 cmdline_parse_token_num_t cmd_operate_detach_port_port_id = 1296 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result, 1297 port_id, UINT16); 1298 1299 cmdline_parse_inst_t cmd_operate_detach_port = { 1300 .f = cmd_operate_detach_port_parsed, 1301 .data = NULL, 1302 .help_str = "port detach <port_id>", 1303 .tokens = { 1304 (void *)&cmd_operate_detach_port_port, 1305 (void *)&cmd_operate_detach_port_keyword, 1306 (void *)&cmd_operate_detach_port_port_id, 1307 NULL, 1308 }, 1309 }; 1310 1311 /* *** configure speed for all ports *** */ 1312 struct cmd_config_speed_all { 1313 cmdline_fixed_string_t port; 1314 cmdline_fixed_string_t keyword; 1315 cmdline_fixed_string_t all; 1316 cmdline_fixed_string_t item1; 1317 cmdline_fixed_string_t item2; 1318 cmdline_fixed_string_t value1; 1319 cmdline_fixed_string_t value2; 1320 }; 1321 1322 static int 1323 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed) 1324 { 1325 1326 int duplex; 1327 1328 if (!strcmp(duplexstr, "half")) { 1329 duplex = ETH_LINK_HALF_DUPLEX; 1330 } else if (!strcmp(duplexstr, "full")) { 1331 duplex = ETH_LINK_FULL_DUPLEX; 1332 } else if (!strcmp(duplexstr, "auto")) { 1333 duplex = ETH_LINK_FULL_DUPLEX; 1334 } else { 1335 printf("Unknown duplex parameter\n"); 1336 return -1; 1337 } 1338 1339 if (!strcmp(speedstr, "10")) { 1340 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1341 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M; 1342 } else if (!strcmp(speedstr, "100")) { 1343 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1344 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M; 1345 } else { 1346 if (duplex != ETH_LINK_FULL_DUPLEX) { 1347 printf("Invalid speed/duplex parameters\n"); 1348 return -1; 1349 } 1350 if (!strcmp(speedstr, "1000")) { 1351 *speed = ETH_LINK_SPEED_1G; 1352 } else if (!strcmp(speedstr, "10000")) { 1353 *speed = ETH_LINK_SPEED_10G; 1354 } else if (!strcmp(speedstr, "25000")) { 1355 *speed = ETH_LINK_SPEED_25G; 1356 } else if (!strcmp(speedstr, "40000")) { 1357 *speed = ETH_LINK_SPEED_40G; 1358 } else if (!strcmp(speedstr, "50000")) { 1359 *speed = ETH_LINK_SPEED_50G; 1360 } else if (!strcmp(speedstr, "100000")) { 1361 *speed = ETH_LINK_SPEED_100G; 1362 } else if (!strcmp(speedstr, "auto")) { 1363 *speed = ETH_LINK_SPEED_AUTONEG; 1364 } else { 1365 printf("Unknown speed parameter\n"); 1366 return -1; 1367 } 1368 } 1369 1370 return 0; 1371 } 1372 1373 static void 1374 cmd_config_speed_all_parsed(void *parsed_result, 1375 __attribute__((unused)) struct cmdline *cl, 1376 __attribute__((unused)) void *data) 1377 { 1378 struct cmd_config_speed_all *res = parsed_result; 1379 uint32_t link_speed; 1380 portid_t pid; 1381 1382 if (!all_ports_stopped()) { 1383 printf("Please stop all ports first\n"); 1384 return; 1385 } 1386 1387 if (parse_and_check_speed_duplex(res->value1, res->value2, 1388 &link_speed) < 0) 1389 return; 1390 1391 RTE_ETH_FOREACH_DEV(pid) { 1392 ports[pid].dev_conf.link_speeds = link_speed; 1393 } 1394 1395 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1396 } 1397 1398 cmdline_parse_token_string_t cmd_config_speed_all_port = 1399 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port"); 1400 cmdline_parse_token_string_t cmd_config_speed_all_keyword = 1401 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword, 1402 "config"); 1403 cmdline_parse_token_string_t cmd_config_speed_all_all = 1404 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all"); 1405 cmdline_parse_token_string_t cmd_config_speed_all_item1 = 1406 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed"); 1407 cmdline_parse_token_string_t cmd_config_speed_all_value1 = 1408 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1, 1409 "10#100#1000#10000#25000#40000#50000#100000#auto"); 1410 cmdline_parse_token_string_t cmd_config_speed_all_item2 = 1411 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex"); 1412 cmdline_parse_token_string_t cmd_config_speed_all_value2 = 1413 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2, 1414 "half#full#auto"); 1415 1416 cmdline_parse_inst_t cmd_config_speed_all = { 1417 .f = cmd_config_speed_all_parsed, 1418 .data = NULL, 1419 .help_str = "port config all speed " 1420 "10|100|1000|10000|25000|40000|50000|100000|auto duplex " 1421 "half|full|auto", 1422 .tokens = { 1423 (void *)&cmd_config_speed_all_port, 1424 (void *)&cmd_config_speed_all_keyword, 1425 (void *)&cmd_config_speed_all_all, 1426 (void *)&cmd_config_speed_all_item1, 1427 (void *)&cmd_config_speed_all_value1, 1428 (void *)&cmd_config_speed_all_item2, 1429 (void *)&cmd_config_speed_all_value2, 1430 NULL, 1431 }, 1432 }; 1433 1434 /* *** configure speed for specific port *** */ 1435 struct cmd_config_speed_specific { 1436 cmdline_fixed_string_t port; 1437 cmdline_fixed_string_t keyword; 1438 portid_t id; 1439 cmdline_fixed_string_t item1; 1440 cmdline_fixed_string_t item2; 1441 cmdline_fixed_string_t value1; 1442 cmdline_fixed_string_t value2; 1443 }; 1444 1445 static void 1446 cmd_config_speed_specific_parsed(void *parsed_result, 1447 __attribute__((unused)) struct cmdline *cl, 1448 __attribute__((unused)) void *data) 1449 { 1450 struct cmd_config_speed_specific *res = parsed_result; 1451 uint32_t link_speed; 1452 1453 if (!all_ports_stopped()) { 1454 printf("Please stop all ports first\n"); 1455 return; 1456 } 1457 1458 if (port_id_is_invalid(res->id, ENABLED_WARN)) 1459 return; 1460 1461 if (parse_and_check_speed_duplex(res->value1, res->value2, 1462 &link_speed) < 0) 1463 return; 1464 1465 ports[res->id].dev_conf.link_speeds = link_speed; 1466 1467 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1468 } 1469 1470 1471 cmdline_parse_token_string_t cmd_config_speed_specific_port = 1472 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port, 1473 "port"); 1474 cmdline_parse_token_string_t cmd_config_speed_specific_keyword = 1475 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword, 1476 "config"); 1477 cmdline_parse_token_num_t cmd_config_speed_specific_id = 1478 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16); 1479 cmdline_parse_token_string_t cmd_config_speed_specific_item1 = 1480 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1, 1481 "speed"); 1482 cmdline_parse_token_string_t cmd_config_speed_specific_value1 = 1483 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1, 1484 "10#100#1000#10000#25000#40000#50000#100000#auto"); 1485 cmdline_parse_token_string_t cmd_config_speed_specific_item2 = 1486 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2, 1487 "duplex"); 1488 cmdline_parse_token_string_t cmd_config_speed_specific_value2 = 1489 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2, 1490 "half#full#auto"); 1491 1492 cmdline_parse_inst_t cmd_config_speed_specific = { 1493 .f = cmd_config_speed_specific_parsed, 1494 .data = NULL, 1495 .help_str = "port config <port_id> speed " 1496 "10|100|1000|10000|25000|40000|50000|100000|auto duplex " 1497 "half|full|auto", 1498 .tokens = { 1499 (void *)&cmd_config_speed_specific_port, 1500 (void *)&cmd_config_speed_specific_keyword, 1501 (void *)&cmd_config_speed_specific_id, 1502 (void *)&cmd_config_speed_specific_item1, 1503 (void *)&cmd_config_speed_specific_value1, 1504 (void *)&cmd_config_speed_specific_item2, 1505 (void *)&cmd_config_speed_specific_value2, 1506 NULL, 1507 }, 1508 }; 1509 1510 /* *** configure loopback for all ports *** */ 1511 struct cmd_config_loopback_all { 1512 cmdline_fixed_string_t port; 1513 cmdline_fixed_string_t keyword; 1514 cmdline_fixed_string_t all; 1515 cmdline_fixed_string_t item; 1516 uint32_t mode; 1517 }; 1518 1519 static void 1520 cmd_config_loopback_all_parsed(void *parsed_result, 1521 __attribute__((unused)) struct cmdline *cl, 1522 __attribute__((unused)) void *data) 1523 { 1524 struct cmd_config_loopback_all *res = parsed_result; 1525 portid_t pid; 1526 1527 if (!all_ports_stopped()) { 1528 printf("Please stop all ports first\n"); 1529 return; 1530 } 1531 1532 RTE_ETH_FOREACH_DEV(pid) { 1533 ports[pid].dev_conf.lpbk_mode = res->mode; 1534 } 1535 1536 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1537 } 1538 1539 cmdline_parse_token_string_t cmd_config_loopback_all_port = 1540 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port"); 1541 cmdline_parse_token_string_t cmd_config_loopback_all_keyword = 1542 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword, 1543 "config"); 1544 cmdline_parse_token_string_t cmd_config_loopback_all_all = 1545 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all"); 1546 cmdline_parse_token_string_t cmd_config_loopback_all_item = 1547 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item, 1548 "loopback"); 1549 cmdline_parse_token_num_t cmd_config_loopback_all_mode = 1550 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32); 1551 1552 cmdline_parse_inst_t cmd_config_loopback_all = { 1553 .f = cmd_config_loopback_all_parsed, 1554 .data = NULL, 1555 .help_str = "port config all loopback <mode>", 1556 .tokens = { 1557 (void *)&cmd_config_loopback_all_port, 1558 (void *)&cmd_config_loopback_all_keyword, 1559 (void *)&cmd_config_loopback_all_all, 1560 (void *)&cmd_config_loopback_all_item, 1561 (void *)&cmd_config_loopback_all_mode, 1562 NULL, 1563 }, 1564 }; 1565 1566 /* *** configure loopback for specific port *** */ 1567 struct cmd_config_loopback_specific { 1568 cmdline_fixed_string_t port; 1569 cmdline_fixed_string_t keyword; 1570 uint16_t port_id; 1571 cmdline_fixed_string_t item; 1572 uint32_t mode; 1573 }; 1574 1575 static void 1576 cmd_config_loopback_specific_parsed(void *parsed_result, 1577 __attribute__((unused)) struct cmdline *cl, 1578 __attribute__((unused)) void *data) 1579 { 1580 struct cmd_config_loopback_specific *res = parsed_result; 1581 1582 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 1583 return; 1584 1585 if (!port_is_stopped(res->port_id)) { 1586 printf("Please stop port %u first\n", res->port_id); 1587 return; 1588 } 1589 1590 ports[res->port_id].dev_conf.lpbk_mode = res->mode; 1591 1592 cmd_reconfig_device_queue(res->port_id, 1, 1); 1593 } 1594 1595 1596 cmdline_parse_token_string_t cmd_config_loopback_specific_port = 1597 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port, 1598 "port"); 1599 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword = 1600 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword, 1601 "config"); 1602 cmdline_parse_token_num_t cmd_config_loopback_specific_id = 1603 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id, 1604 UINT16); 1605 cmdline_parse_token_string_t cmd_config_loopback_specific_item = 1606 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item, 1607 "loopback"); 1608 cmdline_parse_token_num_t cmd_config_loopback_specific_mode = 1609 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode, 1610 UINT32); 1611 1612 cmdline_parse_inst_t cmd_config_loopback_specific = { 1613 .f = cmd_config_loopback_specific_parsed, 1614 .data = NULL, 1615 .help_str = "port config <port_id> loopback <mode>", 1616 .tokens = { 1617 (void *)&cmd_config_loopback_specific_port, 1618 (void *)&cmd_config_loopback_specific_keyword, 1619 (void *)&cmd_config_loopback_specific_id, 1620 (void *)&cmd_config_loopback_specific_item, 1621 (void *)&cmd_config_loopback_specific_mode, 1622 NULL, 1623 }, 1624 }; 1625 1626 /* *** configure txq/rxq, txd/rxd *** */ 1627 struct cmd_config_rx_tx { 1628 cmdline_fixed_string_t port; 1629 cmdline_fixed_string_t keyword; 1630 cmdline_fixed_string_t all; 1631 cmdline_fixed_string_t name; 1632 uint16_t value; 1633 }; 1634 1635 static void 1636 cmd_config_rx_tx_parsed(void *parsed_result, 1637 __attribute__((unused)) struct cmdline *cl, 1638 __attribute__((unused)) void *data) 1639 { 1640 struct cmd_config_rx_tx *res = parsed_result; 1641 1642 if (!all_ports_stopped()) { 1643 printf("Please stop all ports first\n"); 1644 return; 1645 } 1646 if (!strcmp(res->name, "rxq")) { 1647 if (!res->value && !nb_txq) { 1648 printf("Warning: Either rx or tx queues should be non zero\n"); 1649 return; 1650 } 1651 if (check_nb_rxq(res->value) != 0) 1652 return; 1653 nb_rxq = res->value; 1654 } 1655 else if (!strcmp(res->name, "txq")) { 1656 if (!res->value && !nb_rxq) { 1657 printf("Warning: Either rx or tx queues should be non zero\n"); 1658 return; 1659 } 1660 if (check_nb_txq(res->value) != 0) 1661 return; 1662 nb_txq = res->value; 1663 } 1664 else if (!strcmp(res->name, "rxd")) { 1665 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) { 1666 printf("rxd %d invalid - must be > 0 && <= %d\n", 1667 res->value, RTE_TEST_RX_DESC_MAX); 1668 return; 1669 } 1670 nb_rxd = res->value; 1671 } else if (!strcmp(res->name, "txd")) { 1672 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) { 1673 printf("txd %d invalid - must be > 0 && <= %d\n", 1674 res->value, RTE_TEST_TX_DESC_MAX); 1675 return; 1676 } 1677 nb_txd = res->value; 1678 } else { 1679 printf("Unknown parameter\n"); 1680 return; 1681 } 1682 1683 fwd_config_setup(); 1684 1685 init_port_config(); 1686 1687 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1688 } 1689 1690 cmdline_parse_token_string_t cmd_config_rx_tx_port = 1691 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port"); 1692 cmdline_parse_token_string_t cmd_config_rx_tx_keyword = 1693 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config"); 1694 cmdline_parse_token_string_t cmd_config_rx_tx_all = 1695 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all"); 1696 cmdline_parse_token_string_t cmd_config_rx_tx_name = 1697 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name, 1698 "rxq#txq#rxd#txd"); 1699 cmdline_parse_token_num_t cmd_config_rx_tx_value = 1700 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16); 1701 1702 cmdline_parse_inst_t cmd_config_rx_tx = { 1703 .f = cmd_config_rx_tx_parsed, 1704 .data = NULL, 1705 .help_str = "port config all rxq|txq|rxd|txd <value>", 1706 .tokens = { 1707 (void *)&cmd_config_rx_tx_port, 1708 (void *)&cmd_config_rx_tx_keyword, 1709 (void *)&cmd_config_rx_tx_all, 1710 (void *)&cmd_config_rx_tx_name, 1711 (void *)&cmd_config_rx_tx_value, 1712 NULL, 1713 }, 1714 }; 1715 1716 /* *** config max packet length *** */ 1717 struct cmd_config_max_pkt_len_result { 1718 cmdline_fixed_string_t port; 1719 cmdline_fixed_string_t keyword; 1720 cmdline_fixed_string_t all; 1721 cmdline_fixed_string_t name; 1722 uint32_t value; 1723 }; 1724 1725 static void 1726 cmd_config_max_pkt_len_parsed(void *parsed_result, 1727 __attribute__((unused)) struct cmdline *cl, 1728 __attribute__((unused)) void *data) 1729 { 1730 struct cmd_config_max_pkt_len_result *res = parsed_result; 1731 portid_t pid; 1732 1733 if (!all_ports_stopped()) { 1734 printf("Please stop all ports first\n"); 1735 return; 1736 } 1737 1738 RTE_ETH_FOREACH_DEV(pid) { 1739 struct rte_port *port = &ports[pid]; 1740 uint64_t rx_offloads = port->dev_conf.rxmode.offloads; 1741 1742 if (!strcmp(res->name, "max-pkt-len")) { 1743 if (res->value < ETHER_MIN_LEN) { 1744 printf("max-pkt-len can not be less than %d\n", 1745 ETHER_MIN_LEN); 1746 return; 1747 } 1748 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len) 1749 return; 1750 1751 port->dev_conf.rxmode.max_rx_pkt_len = res->value; 1752 if (res->value > ETHER_MAX_LEN) 1753 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; 1754 else 1755 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; 1756 port->dev_conf.rxmode.offloads = rx_offloads; 1757 } else { 1758 printf("Unknown parameter\n"); 1759 return; 1760 } 1761 } 1762 1763 init_port_config(); 1764 1765 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1766 } 1767 1768 cmdline_parse_token_string_t cmd_config_max_pkt_len_port = 1769 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port, 1770 "port"); 1771 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword = 1772 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword, 1773 "config"); 1774 cmdline_parse_token_string_t cmd_config_max_pkt_len_all = 1775 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all, 1776 "all"); 1777 cmdline_parse_token_string_t cmd_config_max_pkt_len_name = 1778 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name, 1779 "max-pkt-len"); 1780 cmdline_parse_token_num_t cmd_config_max_pkt_len_value = 1781 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value, 1782 UINT32); 1783 1784 cmdline_parse_inst_t cmd_config_max_pkt_len = { 1785 .f = cmd_config_max_pkt_len_parsed, 1786 .data = NULL, 1787 .help_str = "port config all max-pkt-len <value>", 1788 .tokens = { 1789 (void *)&cmd_config_max_pkt_len_port, 1790 (void *)&cmd_config_max_pkt_len_keyword, 1791 (void *)&cmd_config_max_pkt_len_all, 1792 (void *)&cmd_config_max_pkt_len_name, 1793 (void *)&cmd_config_max_pkt_len_value, 1794 NULL, 1795 }, 1796 }; 1797 1798 /* *** configure port MTU *** */ 1799 struct cmd_config_mtu_result { 1800 cmdline_fixed_string_t port; 1801 cmdline_fixed_string_t keyword; 1802 cmdline_fixed_string_t mtu; 1803 portid_t port_id; 1804 uint16_t value; 1805 }; 1806 1807 static void 1808 cmd_config_mtu_parsed(void *parsed_result, 1809 __attribute__((unused)) struct cmdline *cl, 1810 __attribute__((unused)) void *data) 1811 { 1812 struct cmd_config_mtu_result *res = parsed_result; 1813 1814 if (res->value < ETHER_MIN_LEN) { 1815 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN); 1816 return; 1817 } 1818 port_mtu_set(res->port_id, res->value); 1819 } 1820 1821 cmdline_parse_token_string_t cmd_config_mtu_port = 1822 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port, 1823 "port"); 1824 cmdline_parse_token_string_t cmd_config_mtu_keyword = 1825 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 1826 "config"); 1827 cmdline_parse_token_string_t cmd_config_mtu_mtu = 1828 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 1829 "mtu"); 1830 cmdline_parse_token_num_t cmd_config_mtu_port_id = 1831 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16); 1832 cmdline_parse_token_num_t cmd_config_mtu_value = 1833 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16); 1834 1835 cmdline_parse_inst_t cmd_config_mtu = { 1836 .f = cmd_config_mtu_parsed, 1837 .data = NULL, 1838 .help_str = "port config mtu <port_id> <value>", 1839 .tokens = { 1840 (void *)&cmd_config_mtu_port, 1841 (void *)&cmd_config_mtu_keyword, 1842 (void *)&cmd_config_mtu_mtu, 1843 (void *)&cmd_config_mtu_port_id, 1844 (void *)&cmd_config_mtu_value, 1845 NULL, 1846 }, 1847 }; 1848 1849 /* *** configure rx mode *** */ 1850 struct cmd_config_rx_mode_flag { 1851 cmdline_fixed_string_t port; 1852 cmdline_fixed_string_t keyword; 1853 cmdline_fixed_string_t all; 1854 cmdline_fixed_string_t name; 1855 cmdline_fixed_string_t value; 1856 }; 1857 1858 static void 1859 cmd_config_rx_mode_flag_parsed(void *parsed_result, 1860 __attribute__((unused)) struct cmdline *cl, 1861 __attribute__((unused)) void *data) 1862 { 1863 struct cmd_config_rx_mode_flag *res = parsed_result; 1864 portid_t pid; 1865 1866 if (!all_ports_stopped()) { 1867 printf("Please stop all ports first\n"); 1868 return; 1869 } 1870 1871 RTE_ETH_FOREACH_DEV(pid) { 1872 struct rte_port *port; 1873 uint64_t rx_offloads; 1874 1875 port = &ports[pid]; 1876 rx_offloads = port->dev_conf.rxmode.offloads; 1877 if (!strcmp(res->name, "crc-strip")) { 1878 if (!strcmp(res->value, "on")) 1879 rx_offloads |= DEV_RX_OFFLOAD_CRC_STRIP; 1880 else if (!strcmp(res->value, "off")) 1881 rx_offloads &= ~DEV_RX_OFFLOAD_CRC_STRIP; 1882 else { 1883 printf("Unknown parameter\n"); 1884 return; 1885 } 1886 } else if (!strcmp(res->name, "scatter")) { 1887 if (!strcmp(res->value, "on")) { 1888 rx_offloads |= DEV_RX_OFFLOAD_SCATTER; 1889 } else if (!strcmp(res->value, "off")) { 1890 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER; 1891 } else { 1892 printf("Unknown parameter\n"); 1893 return; 1894 } 1895 } else if (!strcmp(res->name, "rx-cksum")) { 1896 if (!strcmp(res->value, "on")) 1897 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM; 1898 else if (!strcmp(res->value, "off")) 1899 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM; 1900 else { 1901 printf("Unknown parameter\n"); 1902 return; 1903 } 1904 } else if (!strcmp(res->name, "rx-timestamp")) { 1905 if (!strcmp(res->value, "on")) 1906 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP; 1907 else if (!strcmp(res->value, "off")) 1908 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP; 1909 else { 1910 printf("Unknown parameter\n"); 1911 return; 1912 } 1913 } else if (!strcmp(res->name, "hw-vlan")) { 1914 if (!strcmp(res->value, "on")) { 1915 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER | 1916 DEV_RX_OFFLOAD_VLAN_STRIP); 1917 } else if (!strcmp(res->value, "off")) { 1918 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER | 1919 DEV_RX_OFFLOAD_VLAN_STRIP); 1920 } else { 1921 printf("Unknown parameter\n"); 1922 return; 1923 } 1924 } else if (!strcmp(res->name, "hw-vlan-filter")) { 1925 if (!strcmp(res->value, "on")) 1926 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER; 1927 else if (!strcmp(res->value, "off")) 1928 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER; 1929 else { 1930 printf("Unknown parameter\n"); 1931 return; 1932 } 1933 } else if (!strcmp(res->name, "hw-vlan-strip")) { 1934 if (!strcmp(res->value, "on")) 1935 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP; 1936 else if (!strcmp(res->value, "off")) 1937 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP; 1938 else { 1939 printf("Unknown parameter\n"); 1940 return; 1941 } 1942 } else if (!strcmp(res->name, "hw-vlan-extend")) { 1943 if (!strcmp(res->value, "on")) 1944 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND; 1945 else if (!strcmp(res->value, "off")) 1946 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND; 1947 else { 1948 printf("Unknown parameter\n"); 1949 return; 1950 } 1951 } else if (!strcmp(res->name, "drop-en")) { 1952 if (!strcmp(res->value, "on")) 1953 rx_drop_en = 1; 1954 else if (!strcmp(res->value, "off")) 1955 rx_drop_en = 0; 1956 else { 1957 printf("Unknown parameter\n"); 1958 return; 1959 } 1960 } else { 1961 printf("Unknown parameter\n"); 1962 return; 1963 } 1964 port->dev_conf.rxmode.offloads = rx_offloads; 1965 } 1966 1967 init_port_config(); 1968 1969 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1970 } 1971 1972 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port = 1973 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port"); 1974 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword = 1975 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword, 1976 "config"); 1977 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all = 1978 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all"); 1979 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name = 1980 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name, 1981 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#" 1982 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend"); 1983 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = 1984 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value, 1985 "on#off"); 1986 1987 cmdline_parse_inst_t cmd_config_rx_mode_flag = { 1988 .f = cmd_config_rx_mode_flag_parsed, 1989 .data = NULL, 1990 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|" 1991 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off", 1992 .tokens = { 1993 (void *)&cmd_config_rx_mode_flag_port, 1994 (void *)&cmd_config_rx_mode_flag_keyword, 1995 (void *)&cmd_config_rx_mode_flag_all, 1996 (void *)&cmd_config_rx_mode_flag_name, 1997 (void *)&cmd_config_rx_mode_flag_value, 1998 NULL, 1999 }, 2000 }; 2001 2002 /* *** configure rss *** */ 2003 struct cmd_config_rss { 2004 cmdline_fixed_string_t port; 2005 cmdline_fixed_string_t keyword; 2006 cmdline_fixed_string_t all; 2007 cmdline_fixed_string_t name; 2008 cmdline_fixed_string_t value; 2009 }; 2010 2011 static void 2012 cmd_config_rss_parsed(void *parsed_result, 2013 __attribute__((unused)) struct cmdline *cl, 2014 __attribute__((unused)) void *data) 2015 { 2016 struct cmd_config_rss *res = parsed_result; 2017 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, }; 2018 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, }; 2019 int use_default = 0; 2020 int all_updated = 1; 2021 int diag; 2022 uint16_t i; 2023 2024 if (!strcmp(res->value, "all")) 2025 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP | 2026 ETH_RSS_UDP | ETH_RSS_SCTP | 2027 ETH_RSS_L2_PAYLOAD; 2028 else if (!strcmp(res->value, "ip")) 2029 rss_conf.rss_hf = ETH_RSS_IP; 2030 else if (!strcmp(res->value, "udp")) 2031 rss_conf.rss_hf = ETH_RSS_UDP; 2032 else if (!strcmp(res->value, "tcp")) 2033 rss_conf.rss_hf = ETH_RSS_TCP; 2034 else if (!strcmp(res->value, "sctp")) 2035 rss_conf.rss_hf = ETH_RSS_SCTP; 2036 else if (!strcmp(res->value, "ether")) 2037 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD; 2038 else if (!strcmp(res->value, "port")) 2039 rss_conf.rss_hf = ETH_RSS_PORT; 2040 else if (!strcmp(res->value, "vxlan")) 2041 rss_conf.rss_hf = ETH_RSS_VXLAN; 2042 else if (!strcmp(res->value, "geneve")) 2043 rss_conf.rss_hf = ETH_RSS_GENEVE; 2044 else if (!strcmp(res->value, "nvgre")) 2045 rss_conf.rss_hf = ETH_RSS_NVGRE; 2046 else if (!strcmp(res->value, "none")) 2047 rss_conf.rss_hf = 0; 2048 else if (!strcmp(res->value, "default")) 2049 use_default = 1; 2050 else if (isdigit(res->value[0]) && atoi(res->value) > 0 && 2051 atoi(res->value) < 64) 2052 rss_conf.rss_hf = 1ULL << atoi(res->value); 2053 else { 2054 printf("Unknown parameter\n"); 2055 return; 2056 } 2057 rss_conf.rss_key = NULL; 2058 /* Update global configuration for RSS types. */ 2059 RTE_ETH_FOREACH_DEV(i) { 2060 if (use_default) { 2061 rte_eth_dev_info_get(i, &dev_info); 2062 rss_conf.rss_hf = dev_info.flow_type_rss_offloads; 2063 } 2064 diag = rte_eth_dev_rss_hash_update(i, &rss_conf); 2065 if (diag < 0) { 2066 all_updated = 0; 2067 printf("Configuration of RSS hash at ethernet port %d " 2068 "failed with error (%d): %s.\n", 2069 i, -diag, strerror(-diag)); 2070 } 2071 } 2072 if (all_updated && !use_default) 2073 rss_hf = rss_conf.rss_hf; 2074 } 2075 2076 cmdline_parse_token_string_t cmd_config_rss_port = 2077 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port"); 2078 cmdline_parse_token_string_t cmd_config_rss_keyword = 2079 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config"); 2080 cmdline_parse_token_string_t cmd_config_rss_all = 2081 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all"); 2082 cmdline_parse_token_string_t cmd_config_rss_name = 2083 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss"); 2084 cmdline_parse_token_string_t cmd_config_rss_value = 2085 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL); 2086 2087 cmdline_parse_inst_t cmd_config_rss = { 2088 .f = cmd_config_rss_parsed, 2089 .data = NULL, 2090 .help_str = "port config all rss " 2091 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>", 2092 .tokens = { 2093 (void *)&cmd_config_rss_port, 2094 (void *)&cmd_config_rss_keyword, 2095 (void *)&cmd_config_rss_all, 2096 (void *)&cmd_config_rss_name, 2097 (void *)&cmd_config_rss_value, 2098 NULL, 2099 }, 2100 }; 2101 2102 /* *** configure rss hash key *** */ 2103 struct cmd_config_rss_hash_key { 2104 cmdline_fixed_string_t port; 2105 cmdline_fixed_string_t config; 2106 portid_t port_id; 2107 cmdline_fixed_string_t rss_hash_key; 2108 cmdline_fixed_string_t rss_type; 2109 cmdline_fixed_string_t key; 2110 }; 2111 2112 static uint8_t 2113 hexa_digit_to_value(char hexa_digit) 2114 { 2115 if ((hexa_digit >= '0') && (hexa_digit <= '9')) 2116 return (uint8_t) (hexa_digit - '0'); 2117 if ((hexa_digit >= 'a') && (hexa_digit <= 'f')) 2118 return (uint8_t) ((hexa_digit - 'a') + 10); 2119 if ((hexa_digit >= 'A') && (hexa_digit <= 'F')) 2120 return (uint8_t) ((hexa_digit - 'A') + 10); 2121 /* Invalid hexa digit */ 2122 return 0xFF; 2123 } 2124 2125 static uint8_t 2126 parse_and_check_key_hexa_digit(char *key, int idx) 2127 { 2128 uint8_t hexa_v; 2129 2130 hexa_v = hexa_digit_to_value(key[idx]); 2131 if (hexa_v == 0xFF) 2132 printf("invalid key: character %c at position %d is not a " 2133 "valid hexa digit\n", key[idx], idx); 2134 return hexa_v; 2135 } 2136 2137 static void 2138 cmd_config_rss_hash_key_parsed(void *parsed_result, 2139 __attribute__((unused)) struct cmdline *cl, 2140 __attribute__((unused)) void *data) 2141 { 2142 struct cmd_config_rss_hash_key *res = parsed_result; 2143 uint8_t hash_key[RSS_HASH_KEY_LENGTH]; 2144 uint8_t xdgt0; 2145 uint8_t xdgt1; 2146 int i; 2147 struct rte_eth_dev_info dev_info; 2148 uint8_t hash_key_size; 2149 uint32_t key_len; 2150 2151 memset(&dev_info, 0, sizeof(dev_info)); 2152 rte_eth_dev_info_get(res->port_id, &dev_info); 2153 if (dev_info.hash_key_size > 0 && 2154 dev_info.hash_key_size <= sizeof(hash_key)) 2155 hash_key_size = dev_info.hash_key_size; 2156 else { 2157 printf("dev_info did not provide a valid hash key size\n"); 2158 return; 2159 } 2160 /* Check the length of the RSS hash key */ 2161 key_len = strlen(res->key); 2162 if (key_len != (hash_key_size * 2)) { 2163 printf("key length: %d invalid - key must be a string of %d" 2164 " hexa-decimal numbers\n", 2165 (int) key_len, hash_key_size * 2); 2166 return; 2167 } 2168 /* Translate RSS hash key into binary representation */ 2169 for (i = 0; i < hash_key_size; i++) { 2170 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 2171 if (xdgt0 == 0xFF) 2172 return; 2173 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 2174 if (xdgt1 == 0xFF) 2175 return; 2176 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 2177 } 2178 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key, 2179 hash_key_size); 2180 } 2181 2182 cmdline_parse_token_string_t cmd_config_rss_hash_key_port = 2183 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port"); 2184 cmdline_parse_token_string_t cmd_config_rss_hash_key_config = 2185 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config, 2186 "config"); 2187 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id = 2188 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16); 2189 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key = 2190 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, 2191 rss_hash_key, "rss-hash-key"); 2192 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type = 2193 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type, 2194 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2195 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2196 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2197 "ipv6-tcp-ex#ipv6-udp-ex"); 2198 cmdline_parse_token_string_t cmd_config_rss_hash_key_value = 2199 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL); 2200 2201 cmdline_parse_inst_t cmd_config_rss_hash_key = { 2202 .f = cmd_config_rss_hash_key_parsed, 2203 .data = NULL, 2204 .help_str = "port config <port_id> rss-hash-key " 2205 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2206 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2207 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex " 2208 "<string of hex digits (variable length, NIC dependent)>", 2209 .tokens = { 2210 (void *)&cmd_config_rss_hash_key_port, 2211 (void *)&cmd_config_rss_hash_key_config, 2212 (void *)&cmd_config_rss_hash_key_port_id, 2213 (void *)&cmd_config_rss_hash_key_rss_hash_key, 2214 (void *)&cmd_config_rss_hash_key_rss_type, 2215 (void *)&cmd_config_rss_hash_key_value, 2216 NULL, 2217 }, 2218 }; 2219 2220 /* *** configure port rxq/txq ring size *** */ 2221 struct cmd_config_rxtx_ring_size { 2222 cmdline_fixed_string_t port; 2223 cmdline_fixed_string_t config; 2224 portid_t portid; 2225 cmdline_fixed_string_t rxtxq; 2226 uint16_t qid; 2227 cmdline_fixed_string_t rsize; 2228 uint16_t size; 2229 }; 2230 2231 static void 2232 cmd_config_rxtx_ring_size_parsed(void *parsed_result, 2233 __attribute__((unused)) struct cmdline *cl, 2234 __attribute__((unused)) void *data) 2235 { 2236 struct cmd_config_rxtx_ring_size *res = parsed_result; 2237 struct rte_port *port; 2238 uint8_t isrx; 2239 2240 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2241 return; 2242 2243 if (res->portid == (portid_t)RTE_PORT_ALL) { 2244 printf("Invalid port id\n"); 2245 return; 2246 } 2247 2248 port = &ports[res->portid]; 2249 2250 if (!strcmp(res->rxtxq, "rxq")) 2251 isrx = 1; 2252 else if (!strcmp(res->rxtxq, "txq")) 2253 isrx = 0; 2254 else { 2255 printf("Unknown parameter\n"); 2256 return; 2257 } 2258 2259 if (isrx && rx_queue_id_is_invalid(res->qid)) 2260 return; 2261 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2262 return; 2263 2264 if (isrx && res->size != 0 && res->size <= rx_free_thresh) { 2265 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n", 2266 rx_free_thresh); 2267 return; 2268 } 2269 2270 if (isrx) 2271 port->nb_rx_desc[res->qid] = res->size; 2272 else 2273 port->nb_tx_desc[res->qid] = res->size; 2274 2275 cmd_reconfig_device_queue(res->portid, 0, 1); 2276 } 2277 2278 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port = 2279 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2280 port, "port"); 2281 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config = 2282 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2283 config, "config"); 2284 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid = 2285 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2286 portid, UINT16); 2287 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq = 2288 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2289 rxtxq, "rxq#txq"); 2290 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid = 2291 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2292 qid, UINT16); 2293 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize = 2294 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2295 rsize, "ring_size"); 2296 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size = 2297 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2298 size, UINT16); 2299 2300 cmdline_parse_inst_t cmd_config_rxtx_ring_size = { 2301 .f = cmd_config_rxtx_ring_size_parsed, 2302 .data = NULL, 2303 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>", 2304 .tokens = { 2305 (void *)&cmd_config_rxtx_ring_size_port, 2306 (void *)&cmd_config_rxtx_ring_size_config, 2307 (void *)&cmd_config_rxtx_ring_size_portid, 2308 (void *)&cmd_config_rxtx_ring_size_rxtxq, 2309 (void *)&cmd_config_rxtx_ring_size_qid, 2310 (void *)&cmd_config_rxtx_ring_size_rsize, 2311 (void *)&cmd_config_rxtx_ring_size_size, 2312 NULL, 2313 }, 2314 }; 2315 2316 /* *** configure port rxq/txq start/stop *** */ 2317 struct cmd_config_rxtx_queue { 2318 cmdline_fixed_string_t port; 2319 portid_t portid; 2320 cmdline_fixed_string_t rxtxq; 2321 uint16_t qid; 2322 cmdline_fixed_string_t opname; 2323 }; 2324 2325 static void 2326 cmd_config_rxtx_queue_parsed(void *parsed_result, 2327 __attribute__((unused)) struct cmdline *cl, 2328 __attribute__((unused)) void *data) 2329 { 2330 struct cmd_config_rxtx_queue *res = parsed_result; 2331 uint8_t isrx; 2332 uint8_t isstart; 2333 int ret = 0; 2334 2335 if (test_done == 0) { 2336 printf("Please stop forwarding first\n"); 2337 return; 2338 } 2339 2340 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2341 return; 2342 2343 if (port_is_started(res->portid) != 1) { 2344 printf("Please start port %u first\n", res->portid); 2345 return; 2346 } 2347 2348 if (!strcmp(res->rxtxq, "rxq")) 2349 isrx = 1; 2350 else if (!strcmp(res->rxtxq, "txq")) 2351 isrx = 0; 2352 else { 2353 printf("Unknown parameter\n"); 2354 return; 2355 } 2356 2357 if (isrx && rx_queue_id_is_invalid(res->qid)) 2358 return; 2359 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2360 return; 2361 2362 if (!strcmp(res->opname, "start")) 2363 isstart = 1; 2364 else if (!strcmp(res->opname, "stop")) 2365 isstart = 0; 2366 else { 2367 printf("Unknown parameter\n"); 2368 return; 2369 } 2370 2371 if (isstart && isrx) 2372 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid); 2373 else if (!isstart && isrx) 2374 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid); 2375 else if (isstart && !isrx) 2376 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid); 2377 else 2378 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid); 2379 2380 if (ret == -ENOTSUP) 2381 printf("Function not supported in PMD driver\n"); 2382 } 2383 2384 cmdline_parse_token_string_t cmd_config_rxtx_queue_port = 2385 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port"); 2386 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid = 2387 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16); 2388 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq = 2389 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq"); 2390 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid = 2391 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16); 2392 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname = 2393 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname, 2394 "start#stop"); 2395 2396 cmdline_parse_inst_t cmd_config_rxtx_queue = { 2397 .f = cmd_config_rxtx_queue_parsed, 2398 .data = NULL, 2399 .help_str = "port <port_id> rxq|txq <queue_id> start|stop", 2400 .tokens = { 2401 (void *)&cmd_config_rxtx_queue_port, 2402 (void *)&cmd_config_rxtx_queue_portid, 2403 (void *)&cmd_config_rxtx_queue_rxtxq, 2404 (void *)&cmd_config_rxtx_queue_qid, 2405 (void *)&cmd_config_rxtx_queue_opname, 2406 NULL, 2407 }, 2408 }; 2409 2410 /* *** configure port rxq/txq setup *** */ 2411 struct cmd_setup_rxtx_queue { 2412 cmdline_fixed_string_t port; 2413 portid_t portid; 2414 cmdline_fixed_string_t rxtxq; 2415 uint16_t qid; 2416 cmdline_fixed_string_t setup; 2417 }; 2418 2419 /* Common CLI fields for queue setup */ 2420 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port = 2421 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port"); 2422 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid = 2423 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16); 2424 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq = 2425 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq"); 2426 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid = 2427 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16); 2428 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup = 2429 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup"); 2430 2431 static void 2432 cmd_setup_rxtx_queue_parsed( 2433 void *parsed_result, 2434 __attribute__((unused)) struct cmdline *cl, 2435 __attribute__((unused)) void *data) 2436 { 2437 struct cmd_setup_rxtx_queue *res = parsed_result; 2438 struct rte_port *port; 2439 struct rte_mempool *mp; 2440 unsigned int socket_id; 2441 uint8_t isrx = 0; 2442 int ret; 2443 2444 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2445 return; 2446 2447 if (res->portid == (portid_t)RTE_PORT_ALL) { 2448 printf("Invalid port id\n"); 2449 return; 2450 } 2451 2452 if (!strcmp(res->rxtxq, "rxq")) 2453 isrx = 1; 2454 else if (!strcmp(res->rxtxq, "txq")) 2455 isrx = 0; 2456 else { 2457 printf("Unknown parameter\n"); 2458 return; 2459 } 2460 2461 if (isrx && rx_queue_id_is_invalid(res->qid)) { 2462 printf("Invalid rx queue\n"); 2463 return; 2464 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) { 2465 printf("Invalid tx queue\n"); 2466 return; 2467 } 2468 2469 port = &ports[res->portid]; 2470 if (isrx) { 2471 socket_id = rxring_numa[res->portid]; 2472 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2473 socket_id = port->socket_id; 2474 2475 mp = mbuf_pool_find(socket_id); 2476 if (mp == NULL) { 2477 printf("Failed to setup RX queue: " 2478 "No mempool allocation" 2479 " on the socket %d\n", 2480 rxring_numa[res->portid]); 2481 return; 2482 } 2483 ret = rte_eth_rx_queue_setup(res->portid, 2484 res->qid, 2485 port->nb_rx_desc[res->qid], 2486 socket_id, 2487 &port->rx_conf[res->qid], 2488 mp); 2489 if (ret) 2490 printf("Failed to setup RX queue\n"); 2491 } else { 2492 socket_id = txring_numa[res->portid]; 2493 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2494 socket_id = port->socket_id; 2495 2496 ret = rte_eth_tx_queue_setup(res->portid, 2497 res->qid, 2498 port->nb_tx_desc[res->qid], 2499 socket_id, 2500 &port->tx_conf[res->qid]); 2501 if (ret) 2502 printf("Failed to setup TX queue\n"); 2503 } 2504 } 2505 2506 cmdline_parse_inst_t cmd_setup_rxtx_queue = { 2507 .f = cmd_setup_rxtx_queue_parsed, 2508 .data = NULL, 2509 .help_str = "port <port_id> rxq|txq <queue_idx> setup", 2510 .tokens = { 2511 (void *)&cmd_setup_rxtx_queue_port, 2512 (void *)&cmd_setup_rxtx_queue_portid, 2513 (void *)&cmd_setup_rxtx_queue_rxtxq, 2514 (void *)&cmd_setup_rxtx_queue_qid, 2515 (void *)&cmd_setup_rxtx_queue_setup, 2516 NULL, 2517 }, 2518 }; 2519 2520 2521 /* *** Configure RSS RETA *** */ 2522 struct cmd_config_rss_reta { 2523 cmdline_fixed_string_t port; 2524 cmdline_fixed_string_t keyword; 2525 portid_t port_id; 2526 cmdline_fixed_string_t name; 2527 cmdline_fixed_string_t list_name; 2528 cmdline_fixed_string_t list_of_items; 2529 }; 2530 2531 static int 2532 parse_reta_config(const char *str, 2533 struct rte_eth_rss_reta_entry64 *reta_conf, 2534 uint16_t nb_entries) 2535 { 2536 int i; 2537 unsigned size; 2538 uint16_t hash_index, idx, shift; 2539 uint16_t nb_queue; 2540 char s[256]; 2541 const char *p, *p0 = str; 2542 char *end; 2543 enum fieldnames { 2544 FLD_HASH_INDEX = 0, 2545 FLD_QUEUE, 2546 _NUM_FLD 2547 }; 2548 unsigned long int_fld[_NUM_FLD]; 2549 char *str_fld[_NUM_FLD]; 2550 2551 while ((p = strchr(p0,'(')) != NULL) { 2552 ++p; 2553 if((p0 = strchr(p,')')) == NULL) 2554 return -1; 2555 2556 size = p0 - p; 2557 if(size >= sizeof(s)) 2558 return -1; 2559 2560 snprintf(s, sizeof(s), "%.*s", size, p); 2561 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 2562 return -1; 2563 for (i = 0; i < _NUM_FLD; i++) { 2564 errno = 0; 2565 int_fld[i] = strtoul(str_fld[i], &end, 0); 2566 if (errno != 0 || end == str_fld[i] || 2567 int_fld[i] > 65535) 2568 return -1; 2569 } 2570 2571 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX]; 2572 nb_queue = (uint16_t)int_fld[FLD_QUEUE]; 2573 2574 if (hash_index >= nb_entries) { 2575 printf("Invalid RETA hash index=%d\n", hash_index); 2576 return -1; 2577 } 2578 2579 idx = hash_index / RTE_RETA_GROUP_SIZE; 2580 shift = hash_index % RTE_RETA_GROUP_SIZE; 2581 reta_conf[idx].mask |= (1ULL << shift); 2582 reta_conf[idx].reta[shift] = nb_queue; 2583 } 2584 2585 return 0; 2586 } 2587 2588 static void 2589 cmd_set_rss_reta_parsed(void *parsed_result, 2590 __attribute__((unused)) struct cmdline *cl, 2591 __attribute__((unused)) void *data) 2592 { 2593 int ret; 2594 struct rte_eth_dev_info dev_info; 2595 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2596 struct cmd_config_rss_reta *res = parsed_result; 2597 2598 memset(&dev_info, 0, sizeof(dev_info)); 2599 rte_eth_dev_info_get(res->port_id, &dev_info); 2600 if (dev_info.reta_size == 0) { 2601 printf("Redirection table size is 0 which is " 2602 "invalid for RSS\n"); 2603 return; 2604 } else 2605 printf("The reta size of port %d is %u\n", 2606 res->port_id, dev_info.reta_size); 2607 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) { 2608 printf("Currently do not support more than %u entries of " 2609 "redirection table\n", ETH_RSS_RETA_SIZE_512); 2610 return; 2611 } 2612 2613 memset(reta_conf, 0, sizeof(reta_conf)); 2614 if (!strcmp(res->list_name, "reta")) { 2615 if (parse_reta_config(res->list_of_items, reta_conf, 2616 dev_info.reta_size)) { 2617 printf("Invalid RSS Redirection Table " 2618 "config entered\n"); 2619 return; 2620 } 2621 ret = rte_eth_dev_rss_reta_update(res->port_id, 2622 reta_conf, dev_info.reta_size); 2623 if (ret != 0) 2624 printf("Bad redirection table parameter, " 2625 "return code = %d \n", ret); 2626 } 2627 } 2628 2629 cmdline_parse_token_string_t cmd_config_rss_reta_port = 2630 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port"); 2631 cmdline_parse_token_string_t cmd_config_rss_reta_keyword = 2632 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config"); 2633 cmdline_parse_token_num_t cmd_config_rss_reta_port_id = 2634 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16); 2635 cmdline_parse_token_string_t cmd_config_rss_reta_name = 2636 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss"); 2637 cmdline_parse_token_string_t cmd_config_rss_reta_list_name = 2638 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta"); 2639 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items = 2640 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items, 2641 NULL); 2642 cmdline_parse_inst_t cmd_config_rss_reta = { 2643 .f = cmd_set_rss_reta_parsed, 2644 .data = NULL, 2645 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>", 2646 .tokens = { 2647 (void *)&cmd_config_rss_reta_port, 2648 (void *)&cmd_config_rss_reta_keyword, 2649 (void *)&cmd_config_rss_reta_port_id, 2650 (void *)&cmd_config_rss_reta_name, 2651 (void *)&cmd_config_rss_reta_list_name, 2652 (void *)&cmd_config_rss_reta_list_of_items, 2653 NULL, 2654 }, 2655 }; 2656 2657 /* *** SHOW PORT RETA INFO *** */ 2658 struct cmd_showport_reta { 2659 cmdline_fixed_string_t show; 2660 cmdline_fixed_string_t port; 2661 portid_t port_id; 2662 cmdline_fixed_string_t rss; 2663 cmdline_fixed_string_t reta; 2664 uint16_t size; 2665 cmdline_fixed_string_t list_of_items; 2666 }; 2667 2668 static int 2669 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf, 2670 uint16_t nb_entries, 2671 char *str) 2672 { 2673 uint32_t size; 2674 const char *p, *p0 = str; 2675 char s[256]; 2676 char *end; 2677 char *str_fld[8]; 2678 uint16_t i; 2679 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) / 2680 RTE_RETA_GROUP_SIZE; 2681 int ret; 2682 2683 p = strchr(p0, '('); 2684 if (p == NULL) 2685 return -1; 2686 p++; 2687 p0 = strchr(p, ')'); 2688 if (p0 == NULL) 2689 return -1; 2690 size = p0 - p; 2691 if (size >= sizeof(s)) { 2692 printf("The string size exceeds the internal buffer size\n"); 2693 return -1; 2694 } 2695 snprintf(s, sizeof(s), "%.*s", size, p); 2696 ret = rte_strsplit(s, sizeof(s), str_fld, num, ','); 2697 if (ret <= 0 || ret != num) { 2698 printf("The bits of masks do not match the number of " 2699 "reta entries: %u\n", num); 2700 return -1; 2701 } 2702 for (i = 0; i < ret; i++) 2703 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0); 2704 2705 return 0; 2706 } 2707 2708 static void 2709 cmd_showport_reta_parsed(void *parsed_result, 2710 __attribute__((unused)) struct cmdline *cl, 2711 __attribute__((unused)) void *data) 2712 { 2713 struct cmd_showport_reta *res = parsed_result; 2714 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2715 struct rte_eth_dev_info dev_info; 2716 uint16_t max_reta_size; 2717 2718 memset(&dev_info, 0, sizeof(dev_info)); 2719 rte_eth_dev_info_get(res->port_id, &dev_info); 2720 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512); 2721 if (res->size == 0 || res->size > max_reta_size) { 2722 printf("Invalid redirection table size: %u (1-%u)\n", 2723 res->size, max_reta_size); 2724 return; 2725 } 2726 2727 memset(reta_conf, 0, sizeof(reta_conf)); 2728 if (showport_parse_reta_config(reta_conf, res->size, 2729 res->list_of_items) < 0) { 2730 printf("Invalid string: %s for reta masks\n", 2731 res->list_of_items); 2732 return; 2733 } 2734 port_rss_reta_info(res->port_id, reta_conf, res->size); 2735 } 2736 2737 cmdline_parse_token_string_t cmd_showport_reta_show = 2738 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show"); 2739 cmdline_parse_token_string_t cmd_showport_reta_port = 2740 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port"); 2741 cmdline_parse_token_num_t cmd_showport_reta_port_id = 2742 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16); 2743 cmdline_parse_token_string_t cmd_showport_reta_rss = 2744 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss"); 2745 cmdline_parse_token_string_t cmd_showport_reta_reta = 2746 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta"); 2747 cmdline_parse_token_num_t cmd_showport_reta_size = 2748 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16); 2749 cmdline_parse_token_string_t cmd_showport_reta_list_of_items = 2750 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, 2751 list_of_items, NULL); 2752 2753 cmdline_parse_inst_t cmd_showport_reta = { 2754 .f = cmd_showport_reta_parsed, 2755 .data = NULL, 2756 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>", 2757 .tokens = { 2758 (void *)&cmd_showport_reta_show, 2759 (void *)&cmd_showport_reta_port, 2760 (void *)&cmd_showport_reta_port_id, 2761 (void *)&cmd_showport_reta_rss, 2762 (void *)&cmd_showport_reta_reta, 2763 (void *)&cmd_showport_reta_size, 2764 (void *)&cmd_showport_reta_list_of_items, 2765 NULL, 2766 }, 2767 }; 2768 2769 /* *** Show RSS hash configuration *** */ 2770 struct cmd_showport_rss_hash { 2771 cmdline_fixed_string_t show; 2772 cmdline_fixed_string_t port; 2773 portid_t port_id; 2774 cmdline_fixed_string_t rss_hash; 2775 cmdline_fixed_string_t rss_type; 2776 cmdline_fixed_string_t key; /* optional argument */ 2777 }; 2778 2779 static void cmd_showport_rss_hash_parsed(void *parsed_result, 2780 __attribute__((unused)) struct cmdline *cl, 2781 void *show_rss_key) 2782 { 2783 struct cmd_showport_rss_hash *res = parsed_result; 2784 2785 port_rss_hash_conf_show(res->port_id, res->rss_type, 2786 show_rss_key != NULL); 2787 } 2788 2789 cmdline_parse_token_string_t cmd_showport_rss_hash_show = 2790 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show"); 2791 cmdline_parse_token_string_t cmd_showport_rss_hash_port = 2792 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port"); 2793 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id = 2794 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16); 2795 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = 2796 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash, 2797 "rss-hash"); 2798 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info = 2799 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type, 2800 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2801 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2802 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2803 "ipv6-tcp-ex#ipv6-udp-ex"); 2804 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = 2805 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); 2806 2807 cmdline_parse_inst_t cmd_showport_rss_hash = { 2808 .f = cmd_showport_rss_hash_parsed, 2809 .data = NULL, 2810 .help_str = "show port <port_id> rss-hash " 2811 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2812 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2813 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex", 2814 .tokens = { 2815 (void *)&cmd_showport_rss_hash_show, 2816 (void *)&cmd_showport_rss_hash_port, 2817 (void *)&cmd_showport_rss_hash_port_id, 2818 (void *)&cmd_showport_rss_hash_rss_hash, 2819 (void *)&cmd_showport_rss_hash_rss_hash_info, 2820 NULL, 2821 }, 2822 }; 2823 2824 cmdline_parse_inst_t cmd_showport_rss_hash_key = { 2825 .f = cmd_showport_rss_hash_parsed, 2826 .data = (void *)1, 2827 .help_str = "show port <port_id> rss-hash " 2828 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2829 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2830 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key", 2831 .tokens = { 2832 (void *)&cmd_showport_rss_hash_show, 2833 (void *)&cmd_showport_rss_hash_port, 2834 (void *)&cmd_showport_rss_hash_port_id, 2835 (void *)&cmd_showport_rss_hash_rss_hash, 2836 (void *)&cmd_showport_rss_hash_rss_hash_info, 2837 (void *)&cmd_showport_rss_hash_rss_key, 2838 NULL, 2839 }, 2840 }; 2841 2842 /* *** Configure DCB *** */ 2843 struct cmd_config_dcb { 2844 cmdline_fixed_string_t port; 2845 cmdline_fixed_string_t config; 2846 portid_t port_id; 2847 cmdline_fixed_string_t dcb; 2848 cmdline_fixed_string_t vt; 2849 cmdline_fixed_string_t vt_en; 2850 uint8_t num_tcs; 2851 cmdline_fixed_string_t pfc; 2852 cmdline_fixed_string_t pfc_en; 2853 }; 2854 2855 static void 2856 cmd_config_dcb_parsed(void *parsed_result, 2857 __attribute__((unused)) struct cmdline *cl, 2858 __attribute__((unused)) void *data) 2859 { 2860 struct cmd_config_dcb *res = parsed_result; 2861 portid_t port_id = res->port_id; 2862 struct rte_port *port; 2863 uint8_t pfc_en; 2864 int ret; 2865 2866 port = &ports[port_id]; 2867 /** Check if the port is not started **/ 2868 if (port->port_status != RTE_PORT_STOPPED) { 2869 printf("Please stop port %d first\n", port_id); 2870 return; 2871 } 2872 2873 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) { 2874 printf("The invalid number of traffic class," 2875 " only 4 or 8 allowed.\n"); 2876 return; 2877 } 2878 2879 if (nb_fwd_lcores < res->num_tcs) { 2880 printf("nb_cores shouldn't be less than number of TCs.\n"); 2881 return; 2882 } 2883 if (!strncmp(res->pfc_en, "on", 2)) 2884 pfc_en = 1; 2885 else 2886 pfc_en = 0; 2887 2888 /* DCB in VT mode */ 2889 if (!strncmp(res->vt_en, "on", 2)) 2890 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED, 2891 (enum rte_eth_nb_tcs)res->num_tcs, 2892 pfc_en); 2893 else 2894 ret = init_port_dcb_config(port_id, DCB_ENABLED, 2895 (enum rte_eth_nb_tcs)res->num_tcs, 2896 pfc_en); 2897 2898 2899 if (ret != 0) { 2900 printf("Cannot initialize network ports.\n"); 2901 return; 2902 } 2903 2904 cmd_reconfig_device_queue(port_id, 1, 1); 2905 } 2906 2907 cmdline_parse_token_string_t cmd_config_dcb_port = 2908 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port"); 2909 cmdline_parse_token_string_t cmd_config_dcb_config = 2910 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config"); 2911 cmdline_parse_token_num_t cmd_config_dcb_port_id = 2912 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16); 2913 cmdline_parse_token_string_t cmd_config_dcb_dcb = 2914 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb"); 2915 cmdline_parse_token_string_t cmd_config_dcb_vt = 2916 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt"); 2917 cmdline_parse_token_string_t cmd_config_dcb_vt_en = 2918 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off"); 2919 cmdline_parse_token_num_t cmd_config_dcb_num_tcs = 2920 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8); 2921 cmdline_parse_token_string_t cmd_config_dcb_pfc= 2922 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc"); 2923 cmdline_parse_token_string_t cmd_config_dcb_pfc_en = 2924 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off"); 2925 2926 cmdline_parse_inst_t cmd_config_dcb = { 2927 .f = cmd_config_dcb_parsed, 2928 .data = NULL, 2929 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off", 2930 .tokens = { 2931 (void *)&cmd_config_dcb_port, 2932 (void *)&cmd_config_dcb_config, 2933 (void *)&cmd_config_dcb_port_id, 2934 (void *)&cmd_config_dcb_dcb, 2935 (void *)&cmd_config_dcb_vt, 2936 (void *)&cmd_config_dcb_vt_en, 2937 (void *)&cmd_config_dcb_num_tcs, 2938 (void *)&cmd_config_dcb_pfc, 2939 (void *)&cmd_config_dcb_pfc_en, 2940 NULL, 2941 }, 2942 }; 2943 2944 /* *** configure number of packets per burst *** */ 2945 struct cmd_config_burst { 2946 cmdline_fixed_string_t port; 2947 cmdline_fixed_string_t keyword; 2948 cmdline_fixed_string_t all; 2949 cmdline_fixed_string_t name; 2950 uint16_t value; 2951 }; 2952 2953 static void 2954 cmd_config_burst_parsed(void *parsed_result, 2955 __attribute__((unused)) struct cmdline *cl, 2956 __attribute__((unused)) void *data) 2957 { 2958 struct cmd_config_burst *res = parsed_result; 2959 struct rte_eth_dev_info dev_info; 2960 uint16_t rec_nb_pkts; 2961 2962 if (!all_ports_stopped()) { 2963 printf("Please stop all ports first\n"); 2964 return; 2965 } 2966 2967 if (!strcmp(res->name, "burst")) { 2968 if (res->value == 0) { 2969 /* If user gives a value of zero, query the PMD for 2970 * its recommended Rx burst size. Testpmd uses a single 2971 * size for all ports, so assume all ports are the same 2972 * NIC model and use the values from Port 0. 2973 */ 2974 rte_eth_dev_info_get(0, &dev_info); 2975 rec_nb_pkts = dev_info.default_rxportconf.burst_size; 2976 2977 if (rec_nb_pkts == 0) { 2978 printf("PMD does not recommend a burst size.\n" 2979 "User provided value must be between" 2980 " 1 and %d\n", MAX_PKT_BURST); 2981 return; 2982 } else if (rec_nb_pkts > MAX_PKT_BURST) { 2983 printf("PMD recommended burst size of %d" 2984 " exceeds maximum value of %d\n", 2985 rec_nb_pkts, MAX_PKT_BURST); 2986 return; 2987 } 2988 printf("Using PMD-provided burst value of %d\n", 2989 rec_nb_pkts); 2990 nb_pkt_per_burst = rec_nb_pkts; 2991 } else if (res->value > MAX_PKT_BURST) { 2992 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST); 2993 return; 2994 } else 2995 nb_pkt_per_burst = res->value; 2996 } else { 2997 printf("Unknown parameter\n"); 2998 return; 2999 } 3000 3001 init_port_config(); 3002 3003 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3004 } 3005 3006 cmdline_parse_token_string_t cmd_config_burst_port = 3007 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port"); 3008 cmdline_parse_token_string_t cmd_config_burst_keyword = 3009 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config"); 3010 cmdline_parse_token_string_t cmd_config_burst_all = 3011 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all"); 3012 cmdline_parse_token_string_t cmd_config_burst_name = 3013 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst"); 3014 cmdline_parse_token_num_t cmd_config_burst_value = 3015 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16); 3016 3017 cmdline_parse_inst_t cmd_config_burst = { 3018 .f = cmd_config_burst_parsed, 3019 .data = NULL, 3020 .help_str = "port config all burst <value>", 3021 .tokens = { 3022 (void *)&cmd_config_burst_port, 3023 (void *)&cmd_config_burst_keyword, 3024 (void *)&cmd_config_burst_all, 3025 (void *)&cmd_config_burst_name, 3026 (void *)&cmd_config_burst_value, 3027 NULL, 3028 }, 3029 }; 3030 3031 /* *** configure rx/tx queues *** */ 3032 struct cmd_config_thresh { 3033 cmdline_fixed_string_t port; 3034 cmdline_fixed_string_t keyword; 3035 cmdline_fixed_string_t all; 3036 cmdline_fixed_string_t name; 3037 uint8_t value; 3038 }; 3039 3040 static void 3041 cmd_config_thresh_parsed(void *parsed_result, 3042 __attribute__((unused)) struct cmdline *cl, 3043 __attribute__((unused)) void *data) 3044 { 3045 struct cmd_config_thresh *res = parsed_result; 3046 3047 if (!all_ports_stopped()) { 3048 printf("Please stop all ports first\n"); 3049 return; 3050 } 3051 3052 if (!strcmp(res->name, "txpt")) 3053 tx_pthresh = res->value; 3054 else if(!strcmp(res->name, "txht")) 3055 tx_hthresh = res->value; 3056 else if(!strcmp(res->name, "txwt")) 3057 tx_wthresh = res->value; 3058 else if(!strcmp(res->name, "rxpt")) 3059 rx_pthresh = res->value; 3060 else if(!strcmp(res->name, "rxht")) 3061 rx_hthresh = res->value; 3062 else if(!strcmp(res->name, "rxwt")) 3063 rx_wthresh = res->value; 3064 else { 3065 printf("Unknown parameter\n"); 3066 return; 3067 } 3068 3069 init_port_config(); 3070 3071 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3072 } 3073 3074 cmdline_parse_token_string_t cmd_config_thresh_port = 3075 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port"); 3076 cmdline_parse_token_string_t cmd_config_thresh_keyword = 3077 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config"); 3078 cmdline_parse_token_string_t cmd_config_thresh_all = 3079 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all"); 3080 cmdline_parse_token_string_t cmd_config_thresh_name = 3081 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name, 3082 "txpt#txht#txwt#rxpt#rxht#rxwt"); 3083 cmdline_parse_token_num_t cmd_config_thresh_value = 3084 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8); 3085 3086 cmdline_parse_inst_t cmd_config_thresh = { 3087 .f = cmd_config_thresh_parsed, 3088 .data = NULL, 3089 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>", 3090 .tokens = { 3091 (void *)&cmd_config_thresh_port, 3092 (void *)&cmd_config_thresh_keyword, 3093 (void *)&cmd_config_thresh_all, 3094 (void *)&cmd_config_thresh_name, 3095 (void *)&cmd_config_thresh_value, 3096 NULL, 3097 }, 3098 }; 3099 3100 /* *** configure free/rs threshold *** */ 3101 struct cmd_config_threshold { 3102 cmdline_fixed_string_t port; 3103 cmdline_fixed_string_t keyword; 3104 cmdline_fixed_string_t all; 3105 cmdline_fixed_string_t name; 3106 uint16_t value; 3107 }; 3108 3109 static void 3110 cmd_config_threshold_parsed(void *parsed_result, 3111 __attribute__((unused)) struct cmdline *cl, 3112 __attribute__((unused)) void *data) 3113 { 3114 struct cmd_config_threshold *res = parsed_result; 3115 3116 if (!all_ports_stopped()) { 3117 printf("Please stop all ports first\n"); 3118 return; 3119 } 3120 3121 if (!strcmp(res->name, "txfreet")) 3122 tx_free_thresh = res->value; 3123 else if (!strcmp(res->name, "txrst")) 3124 tx_rs_thresh = res->value; 3125 else if (!strcmp(res->name, "rxfreet")) 3126 rx_free_thresh = res->value; 3127 else { 3128 printf("Unknown parameter\n"); 3129 return; 3130 } 3131 3132 init_port_config(); 3133 3134 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3135 } 3136 3137 cmdline_parse_token_string_t cmd_config_threshold_port = 3138 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port"); 3139 cmdline_parse_token_string_t cmd_config_threshold_keyword = 3140 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword, 3141 "config"); 3142 cmdline_parse_token_string_t cmd_config_threshold_all = 3143 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all"); 3144 cmdline_parse_token_string_t cmd_config_threshold_name = 3145 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name, 3146 "txfreet#txrst#rxfreet"); 3147 cmdline_parse_token_num_t cmd_config_threshold_value = 3148 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16); 3149 3150 cmdline_parse_inst_t cmd_config_threshold = { 3151 .f = cmd_config_threshold_parsed, 3152 .data = NULL, 3153 .help_str = "port config all txfreet|txrst|rxfreet <value>", 3154 .tokens = { 3155 (void *)&cmd_config_threshold_port, 3156 (void *)&cmd_config_threshold_keyword, 3157 (void *)&cmd_config_threshold_all, 3158 (void *)&cmd_config_threshold_name, 3159 (void *)&cmd_config_threshold_value, 3160 NULL, 3161 }, 3162 }; 3163 3164 /* *** stop *** */ 3165 struct cmd_stop_result { 3166 cmdline_fixed_string_t stop; 3167 }; 3168 3169 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result, 3170 __attribute__((unused)) struct cmdline *cl, 3171 __attribute__((unused)) void *data) 3172 { 3173 stop_packet_forwarding(); 3174 } 3175 3176 cmdline_parse_token_string_t cmd_stop_stop = 3177 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop"); 3178 3179 cmdline_parse_inst_t cmd_stop = { 3180 .f = cmd_stop_parsed, 3181 .data = NULL, 3182 .help_str = "stop: Stop packet forwarding", 3183 .tokens = { 3184 (void *)&cmd_stop_stop, 3185 NULL, 3186 }, 3187 }; 3188 3189 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */ 3190 3191 unsigned int 3192 parse_item_list(char* str, const char* item_name, unsigned int max_items, 3193 unsigned int *parsed_items, int check_unique_values) 3194 { 3195 unsigned int nb_item; 3196 unsigned int value; 3197 unsigned int i; 3198 unsigned int j; 3199 int value_ok; 3200 char c; 3201 3202 /* 3203 * First parse all items in the list and store their value. 3204 */ 3205 value = 0; 3206 nb_item = 0; 3207 value_ok = 0; 3208 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) { 3209 c = str[i]; 3210 if ((c >= '0') && (c <= '9')) { 3211 value = (unsigned int) (value * 10 + (c - '0')); 3212 value_ok = 1; 3213 continue; 3214 } 3215 if (c != ',') { 3216 printf("character %c is not a decimal digit\n", c); 3217 return 0; 3218 } 3219 if (! value_ok) { 3220 printf("No valid value before comma\n"); 3221 return 0; 3222 } 3223 if (nb_item < max_items) { 3224 parsed_items[nb_item] = value; 3225 value_ok = 0; 3226 value = 0; 3227 } 3228 nb_item++; 3229 } 3230 if (nb_item >= max_items) { 3231 printf("Number of %s = %u > %u (maximum items)\n", 3232 item_name, nb_item + 1, max_items); 3233 return 0; 3234 } 3235 parsed_items[nb_item++] = value; 3236 if (! check_unique_values) 3237 return nb_item; 3238 3239 /* 3240 * Then, check that all values in the list are differents. 3241 * No optimization here... 3242 */ 3243 for (i = 0; i < nb_item; i++) { 3244 for (j = i + 1; j < nb_item; j++) { 3245 if (parsed_items[j] == parsed_items[i]) { 3246 printf("duplicated %s %u at index %u and %u\n", 3247 item_name, parsed_items[i], i, j); 3248 return 0; 3249 } 3250 } 3251 } 3252 return nb_item; 3253 } 3254 3255 struct cmd_set_list_result { 3256 cmdline_fixed_string_t cmd_keyword; 3257 cmdline_fixed_string_t list_name; 3258 cmdline_fixed_string_t list_of_items; 3259 }; 3260 3261 static void cmd_set_list_parsed(void *parsed_result, 3262 __attribute__((unused)) struct cmdline *cl, 3263 __attribute__((unused)) void *data) 3264 { 3265 struct cmd_set_list_result *res; 3266 union { 3267 unsigned int lcorelist[RTE_MAX_LCORE]; 3268 unsigned int portlist[RTE_MAX_ETHPORTS]; 3269 } parsed_items; 3270 unsigned int nb_item; 3271 3272 if (test_done == 0) { 3273 printf("Please stop forwarding first\n"); 3274 return; 3275 } 3276 3277 res = parsed_result; 3278 if (!strcmp(res->list_name, "corelist")) { 3279 nb_item = parse_item_list(res->list_of_items, "core", 3280 RTE_MAX_LCORE, 3281 parsed_items.lcorelist, 1); 3282 if (nb_item > 0) { 3283 set_fwd_lcores_list(parsed_items.lcorelist, nb_item); 3284 fwd_config_setup(); 3285 } 3286 return; 3287 } 3288 if (!strcmp(res->list_name, "portlist")) { 3289 nb_item = parse_item_list(res->list_of_items, "port", 3290 RTE_MAX_ETHPORTS, 3291 parsed_items.portlist, 1); 3292 if (nb_item > 0) { 3293 set_fwd_ports_list(parsed_items.portlist, nb_item); 3294 fwd_config_setup(); 3295 } 3296 } 3297 } 3298 3299 cmdline_parse_token_string_t cmd_set_list_keyword = 3300 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword, 3301 "set"); 3302 cmdline_parse_token_string_t cmd_set_list_name = 3303 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name, 3304 "corelist#portlist"); 3305 cmdline_parse_token_string_t cmd_set_list_of_items = 3306 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items, 3307 NULL); 3308 3309 cmdline_parse_inst_t cmd_set_fwd_list = { 3310 .f = cmd_set_list_parsed, 3311 .data = NULL, 3312 .help_str = "set corelist|portlist <list0[,list1]*>", 3313 .tokens = { 3314 (void *)&cmd_set_list_keyword, 3315 (void *)&cmd_set_list_name, 3316 (void *)&cmd_set_list_of_items, 3317 NULL, 3318 }, 3319 }; 3320 3321 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */ 3322 3323 struct cmd_setmask_result { 3324 cmdline_fixed_string_t set; 3325 cmdline_fixed_string_t mask; 3326 uint64_t hexavalue; 3327 }; 3328 3329 static void cmd_set_mask_parsed(void *parsed_result, 3330 __attribute__((unused)) struct cmdline *cl, 3331 __attribute__((unused)) void *data) 3332 { 3333 struct cmd_setmask_result *res = parsed_result; 3334 3335 if (test_done == 0) { 3336 printf("Please stop forwarding first\n"); 3337 return; 3338 } 3339 if (!strcmp(res->mask, "coremask")) { 3340 set_fwd_lcores_mask(res->hexavalue); 3341 fwd_config_setup(); 3342 } else if (!strcmp(res->mask, "portmask")) { 3343 set_fwd_ports_mask(res->hexavalue); 3344 fwd_config_setup(); 3345 } 3346 } 3347 3348 cmdline_parse_token_string_t cmd_setmask_set = 3349 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set"); 3350 cmdline_parse_token_string_t cmd_setmask_mask = 3351 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask, 3352 "coremask#portmask"); 3353 cmdline_parse_token_num_t cmd_setmask_value = 3354 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64); 3355 3356 cmdline_parse_inst_t cmd_set_fwd_mask = { 3357 .f = cmd_set_mask_parsed, 3358 .data = NULL, 3359 .help_str = "set coremask|portmask <hexadecimal value>", 3360 .tokens = { 3361 (void *)&cmd_setmask_set, 3362 (void *)&cmd_setmask_mask, 3363 (void *)&cmd_setmask_value, 3364 NULL, 3365 }, 3366 }; 3367 3368 /* 3369 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION 3370 */ 3371 struct cmd_set_result { 3372 cmdline_fixed_string_t set; 3373 cmdline_fixed_string_t what; 3374 uint16_t value; 3375 }; 3376 3377 static void cmd_set_parsed(void *parsed_result, 3378 __attribute__((unused)) struct cmdline *cl, 3379 __attribute__((unused)) void *data) 3380 { 3381 struct cmd_set_result *res = parsed_result; 3382 if (!strcmp(res->what, "nbport")) { 3383 set_fwd_ports_number(res->value); 3384 fwd_config_setup(); 3385 } else if (!strcmp(res->what, "nbcore")) { 3386 set_fwd_lcores_number(res->value); 3387 fwd_config_setup(); 3388 } else if (!strcmp(res->what, "burst")) 3389 set_nb_pkt_per_burst(res->value); 3390 else if (!strcmp(res->what, "verbose")) 3391 set_verbose_level(res->value); 3392 } 3393 3394 cmdline_parse_token_string_t cmd_set_set = 3395 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set"); 3396 cmdline_parse_token_string_t cmd_set_what = 3397 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what, 3398 "nbport#nbcore#burst#verbose"); 3399 cmdline_parse_token_num_t cmd_set_value = 3400 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16); 3401 3402 cmdline_parse_inst_t cmd_set_numbers = { 3403 .f = cmd_set_parsed, 3404 .data = NULL, 3405 .help_str = "set nbport|nbcore|burst|verbose <value>", 3406 .tokens = { 3407 (void *)&cmd_set_set, 3408 (void *)&cmd_set_what, 3409 (void *)&cmd_set_value, 3410 NULL, 3411 }, 3412 }; 3413 3414 /* *** SET LOG LEVEL CONFIGURATION *** */ 3415 3416 struct cmd_set_log_result { 3417 cmdline_fixed_string_t set; 3418 cmdline_fixed_string_t log; 3419 cmdline_fixed_string_t type; 3420 uint32_t level; 3421 }; 3422 3423 static void 3424 cmd_set_log_parsed(void *parsed_result, 3425 __attribute__((unused)) struct cmdline *cl, 3426 __attribute__((unused)) void *data) 3427 { 3428 struct cmd_set_log_result *res; 3429 int ret; 3430 3431 res = parsed_result; 3432 if (!strcmp(res->type, "global")) 3433 rte_log_set_global_level(res->level); 3434 else { 3435 ret = rte_log_set_level_regexp(res->type, res->level); 3436 if (ret < 0) 3437 printf("Unable to set log level\n"); 3438 } 3439 } 3440 3441 cmdline_parse_token_string_t cmd_set_log_set = 3442 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set"); 3443 cmdline_parse_token_string_t cmd_set_log_log = 3444 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log"); 3445 cmdline_parse_token_string_t cmd_set_log_type = 3446 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL); 3447 cmdline_parse_token_num_t cmd_set_log_level = 3448 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32); 3449 3450 cmdline_parse_inst_t cmd_set_log = { 3451 .f = cmd_set_log_parsed, 3452 .data = NULL, 3453 .help_str = "set log global|<type> <level>", 3454 .tokens = { 3455 (void *)&cmd_set_log_set, 3456 (void *)&cmd_set_log_log, 3457 (void *)&cmd_set_log_type, 3458 (void *)&cmd_set_log_level, 3459 NULL, 3460 }, 3461 }; 3462 3463 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ 3464 3465 struct cmd_set_txpkts_result { 3466 cmdline_fixed_string_t cmd_keyword; 3467 cmdline_fixed_string_t txpkts; 3468 cmdline_fixed_string_t seg_lengths; 3469 }; 3470 3471 static void 3472 cmd_set_txpkts_parsed(void *parsed_result, 3473 __attribute__((unused)) struct cmdline *cl, 3474 __attribute__((unused)) void *data) 3475 { 3476 struct cmd_set_txpkts_result *res; 3477 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; 3478 unsigned int nb_segs; 3479 3480 res = parsed_result; 3481 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3482 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0); 3483 if (nb_segs > 0) 3484 set_tx_pkt_segments(seg_lengths, nb_segs); 3485 } 3486 3487 cmdline_parse_token_string_t cmd_set_txpkts_keyword = 3488 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3489 cmd_keyword, "set"); 3490 cmdline_parse_token_string_t cmd_set_txpkts_name = 3491 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3492 txpkts, "txpkts"); 3493 cmdline_parse_token_string_t cmd_set_txpkts_lengths = 3494 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3495 seg_lengths, NULL); 3496 3497 cmdline_parse_inst_t cmd_set_txpkts = { 3498 .f = cmd_set_txpkts_parsed, 3499 .data = NULL, 3500 .help_str = "set txpkts <len0[,len1]*>", 3501 .tokens = { 3502 (void *)&cmd_set_txpkts_keyword, 3503 (void *)&cmd_set_txpkts_name, 3504 (void *)&cmd_set_txpkts_lengths, 3505 NULL, 3506 }, 3507 }; 3508 3509 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */ 3510 3511 struct cmd_set_txsplit_result { 3512 cmdline_fixed_string_t cmd_keyword; 3513 cmdline_fixed_string_t txsplit; 3514 cmdline_fixed_string_t mode; 3515 }; 3516 3517 static void 3518 cmd_set_txsplit_parsed(void *parsed_result, 3519 __attribute__((unused)) struct cmdline *cl, 3520 __attribute__((unused)) void *data) 3521 { 3522 struct cmd_set_txsplit_result *res; 3523 3524 res = parsed_result; 3525 set_tx_pkt_split(res->mode); 3526 } 3527 3528 cmdline_parse_token_string_t cmd_set_txsplit_keyword = 3529 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3530 cmd_keyword, "set"); 3531 cmdline_parse_token_string_t cmd_set_txsplit_name = 3532 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3533 txsplit, "txsplit"); 3534 cmdline_parse_token_string_t cmd_set_txsplit_mode = 3535 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3536 mode, NULL); 3537 3538 cmdline_parse_inst_t cmd_set_txsplit = { 3539 .f = cmd_set_txsplit_parsed, 3540 .data = NULL, 3541 .help_str = "set txsplit on|off|rand", 3542 .tokens = { 3543 (void *)&cmd_set_txsplit_keyword, 3544 (void *)&cmd_set_txsplit_name, 3545 (void *)&cmd_set_txsplit_mode, 3546 NULL, 3547 }, 3548 }; 3549 3550 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */ 3551 struct cmd_rx_vlan_filter_all_result { 3552 cmdline_fixed_string_t rx_vlan; 3553 cmdline_fixed_string_t what; 3554 cmdline_fixed_string_t all; 3555 portid_t port_id; 3556 }; 3557 3558 static void 3559 cmd_rx_vlan_filter_all_parsed(void *parsed_result, 3560 __attribute__((unused)) struct cmdline *cl, 3561 __attribute__((unused)) void *data) 3562 { 3563 struct cmd_rx_vlan_filter_all_result *res = parsed_result; 3564 3565 if (!strcmp(res->what, "add")) 3566 rx_vlan_all_filter_set(res->port_id, 1); 3567 else 3568 rx_vlan_all_filter_set(res->port_id, 0); 3569 } 3570 3571 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan = 3572 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3573 rx_vlan, "rx_vlan"); 3574 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what = 3575 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3576 what, "add#rm"); 3577 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all = 3578 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3579 all, "all"); 3580 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid = 3581 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3582 port_id, UINT16); 3583 3584 cmdline_parse_inst_t cmd_rx_vlan_filter_all = { 3585 .f = cmd_rx_vlan_filter_all_parsed, 3586 .data = NULL, 3587 .help_str = "rx_vlan add|rm all <port_id>: " 3588 "Add/Remove all identifiers to/from the set of VLAN " 3589 "identifiers filtered by a port", 3590 .tokens = { 3591 (void *)&cmd_rx_vlan_filter_all_rx_vlan, 3592 (void *)&cmd_rx_vlan_filter_all_what, 3593 (void *)&cmd_rx_vlan_filter_all_all, 3594 (void *)&cmd_rx_vlan_filter_all_portid, 3595 NULL, 3596 }, 3597 }; 3598 3599 /* *** VLAN OFFLOAD SET ON A PORT *** */ 3600 struct cmd_vlan_offload_result { 3601 cmdline_fixed_string_t vlan; 3602 cmdline_fixed_string_t set; 3603 cmdline_fixed_string_t vlan_type; 3604 cmdline_fixed_string_t what; 3605 cmdline_fixed_string_t on; 3606 cmdline_fixed_string_t port_id; 3607 }; 3608 3609 static void 3610 cmd_vlan_offload_parsed(void *parsed_result, 3611 __attribute__((unused)) struct cmdline *cl, 3612 __attribute__((unused)) void *data) 3613 { 3614 int on; 3615 struct cmd_vlan_offload_result *res = parsed_result; 3616 char *str; 3617 int i, len = 0; 3618 portid_t port_id = 0; 3619 unsigned int tmp; 3620 3621 str = res->port_id; 3622 len = strnlen(str, STR_TOKEN_SIZE); 3623 i = 0; 3624 /* Get port_id first */ 3625 while(i < len){ 3626 if(str[i] == ',') 3627 break; 3628 3629 i++; 3630 } 3631 str[i]='\0'; 3632 tmp = strtoul(str, NULL, 0); 3633 /* If port_id greater that what portid_t can represent, return */ 3634 if(tmp >= RTE_MAX_ETHPORTS) 3635 return; 3636 port_id = (portid_t)tmp; 3637 3638 if (!strcmp(res->on, "on")) 3639 on = 1; 3640 else 3641 on = 0; 3642 3643 if (!strcmp(res->what, "strip")) 3644 rx_vlan_strip_set(port_id, on); 3645 else if(!strcmp(res->what, "stripq")){ 3646 uint16_t queue_id = 0; 3647 3648 /* No queue_id, return */ 3649 if(i + 1 >= len) { 3650 printf("must specify (port,queue_id)\n"); 3651 return; 3652 } 3653 tmp = strtoul(str + i + 1, NULL, 0); 3654 /* If queue_id greater that what 16-bits can represent, return */ 3655 if(tmp > 0xffff) 3656 return; 3657 3658 queue_id = (uint16_t)tmp; 3659 rx_vlan_strip_set_on_queue(port_id, queue_id, on); 3660 } 3661 else if (!strcmp(res->what, "filter")) 3662 rx_vlan_filter_set(port_id, on); 3663 else 3664 vlan_extend_set(port_id, on); 3665 3666 return; 3667 } 3668 3669 cmdline_parse_token_string_t cmd_vlan_offload_vlan = 3670 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3671 vlan, "vlan"); 3672 cmdline_parse_token_string_t cmd_vlan_offload_set = 3673 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3674 set, "set"); 3675 cmdline_parse_token_string_t cmd_vlan_offload_what = 3676 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3677 what, "strip#filter#qinq#stripq"); 3678 cmdline_parse_token_string_t cmd_vlan_offload_on = 3679 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3680 on, "on#off"); 3681 cmdline_parse_token_string_t cmd_vlan_offload_portid = 3682 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3683 port_id, NULL); 3684 3685 cmdline_parse_inst_t cmd_vlan_offload = { 3686 .f = cmd_vlan_offload_parsed, 3687 .data = NULL, 3688 .help_str = "vlan set strip|filter|qinq|stripq on|off " 3689 "<port_id[,queue_id]>: " 3690 "Filter/Strip for rx side qinq(extended) for both rx/tx sides", 3691 .tokens = { 3692 (void *)&cmd_vlan_offload_vlan, 3693 (void *)&cmd_vlan_offload_set, 3694 (void *)&cmd_vlan_offload_what, 3695 (void *)&cmd_vlan_offload_on, 3696 (void *)&cmd_vlan_offload_portid, 3697 NULL, 3698 }, 3699 }; 3700 3701 /* *** VLAN TPID SET ON A PORT *** */ 3702 struct cmd_vlan_tpid_result { 3703 cmdline_fixed_string_t vlan; 3704 cmdline_fixed_string_t set; 3705 cmdline_fixed_string_t vlan_type; 3706 cmdline_fixed_string_t what; 3707 uint16_t tp_id; 3708 portid_t port_id; 3709 }; 3710 3711 static void 3712 cmd_vlan_tpid_parsed(void *parsed_result, 3713 __attribute__((unused)) struct cmdline *cl, 3714 __attribute__((unused)) void *data) 3715 { 3716 struct cmd_vlan_tpid_result *res = parsed_result; 3717 enum rte_vlan_type vlan_type; 3718 3719 if (!strcmp(res->vlan_type, "inner")) 3720 vlan_type = ETH_VLAN_TYPE_INNER; 3721 else if (!strcmp(res->vlan_type, "outer")) 3722 vlan_type = ETH_VLAN_TYPE_OUTER; 3723 else { 3724 printf("Unknown vlan type\n"); 3725 return; 3726 } 3727 vlan_tpid_set(res->port_id, vlan_type, res->tp_id); 3728 } 3729 3730 cmdline_parse_token_string_t cmd_vlan_tpid_vlan = 3731 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3732 vlan, "vlan"); 3733 cmdline_parse_token_string_t cmd_vlan_tpid_set = 3734 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3735 set, "set"); 3736 cmdline_parse_token_string_t cmd_vlan_type = 3737 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3738 vlan_type, "inner#outer"); 3739 cmdline_parse_token_string_t cmd_vlan_tpid_what = 3740 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3741 what, "tpid"); 3742 cmdline_parse_token_num_t cmd_vlan_tpid_tpid = 3743 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 3744 tp_id, UINT16); 3745 cmdline_parse_token_num_t cmd_vlan_tpid_portid = 3746 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 3747 port_id, UINT16); 3748 3749 cmdline_parse_inst_t cmd_vlan_tpid = { 3750 .f = cmd_vlan_tpid_parsed, 3751 .data = NULL, 3752 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: " 3753 "Set the VLAN Ether type", 3754 .tokens = { 3755 (void *)&cmd_vlan_tpid_vlan, 3756 (void *)&cmd_vlan_tpid_set, 3757 (void *)&cmd_vlan_type, 3758 (void *)&cmd_vlan_tpid_what, 3759 (void *)&cmd_vlan_tpid_tpid, 3760 (void *)&cmd_vlan_tpid_portid, 3761 NULL, 3762 }, 3763 }; 3764 3765 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 3766 struct cmd_rx_vlan_filter_result { 3767 cmdline_fixed_string_t rx_vlan; 3768 cmdline_fixed_string_t what; 3769 uint16_t vlan_id; 3770 portid_t port_id; 3771 }; 3772 3773 static void 3774 cmd_rx_vlan_filter_parsed(void *parsed_result, 3775 __attribute__((unused)) struct cmdline *cl, 3776 __attribute__((unused)) void *data) 3777 { 3778 struct cmd_rx_vlan_filter_result *res = parsed_result; 3779 3780 if (!strcmp(res->what, "add")) 3781 rx_vft_set(res->port_id, res->vlan_id, 1); 3782 else 3783 rx_vft_set(res->port_id, res->vlan_id, 0); 3784 } 3785 3786 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan = 3787 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 3788 rx_vlan, "rx_vlan"); 3789 cmdline_parse_token_string_t cmd_rx_vlan_filter_what = 3790 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 3791 what, "add#rm"); 3792 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid = 3793 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 3794 vlan_id, UINT16); 3795 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid = 3796 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 3797 port_id, UINT16); 3798 3799 cmdline_parse_inst_t cmd_rx_vlan_filter = { 3800 .f = cmd_rx_vlan_filter_parsed, 3801 .data = NULL, 3802 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: " 3803 "Add/Remove a VLAN identifier to/from the set of VLAN " 3804 "identifiers filtered by a port", 3805 .tokens = { 3806 (void *)&cmd_rx_vlan_filter_rx_vlan, 3807 (void *)&cmd_rx_vlan_filter_what, 3808 (void *)&cmd_rx_vlan_filter_vlanid, 3809 (void *)&cmd_rx_vlan_filter_portid, 3810 NULL, 3811 }, 3812 }; 3813 3814 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 3815 struct cmd_tx_vlan_set_result { 3816 cmdline_fixed_string_t tx_vlan; 3817 cmdline_fixed_string_t set; 3818 portid_t port_id; 3819 uint16_t vlan_id; 3820 }; 3821 3822 static void 3823 cmd_tx_vlan_set_parsed(void *parsed_result, 3824 __attribute__((unused)) struct cmdline *cl, 3825 __attribute__((unused)) void *data) 3826 { 3827 struct cmd_tx_vlan_set_result *res = parsed_result; 3828 3829 if (!port_is_stopped(res->port_id)) { 3830 printf("Please stop port %d first\n", res->port_id); 3831 return; 3832 } 3833 3834 tx_vlan_set(res->port_id, res->vlan_id); 3835 3836 cmd_reconfig_device_queue(res->port_id, 1, 1); 3837 } 3838 3839 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan = 3840 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 3841 tx_vlan, "tx_vlan"); 3842 cmdline_parse_token_string_t cmd_tx_vlan_set_set = 3843 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 3844 set, "set"); 3845 cmdline_parse_token_num_t cmd_tx_vlan_set_portid = 3846 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 3847 port_id, UINT16); 3848 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid = 3849 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 3850 vlan_id, UINT16); 3851 3852 cmdline_parse_inst_t cmd_tx_vlan_set = { 3853 .f = cmd_tx_vlan_set_parsed, 3854 .data = NULL, 3855 .help_str = "tx_vlan set <port_id> <vlan_id>: " 3856 "Enable hardware insertion of a single VLAN header " 3857 "with a given TAG Identifier in packets sent on a port", 3858 .tokens = { 3859 (void *)&cmd_tx_vlan_set_tx_vlan, 3860 (void *)&cmd_tx_vlan_set_set, 3861 (void *)&cmd_tx_vlan_set_portid, 3862 (void *)&cmd_tx_vlan_set_vlanid, 3863 NULL, 3864 }, 3865 }; 3866 3867 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */ 3868 struct cmd_tx_vlan_set_qinq_result { 3869 cmdline_fixed_string_t tx_vlan; 3870 cmdline_fixed_string_t set; 3871 portid_t port_id; 3872 uint16_t vlan_id; 3873 uint16_t vlan_id_outer; 3874 }; 3875 3876 static void 3877 cmd_tx_vlan_set_qinq_parsed(void *parsed_result, 3878 __attribute__((unused)) struct cmdline *cl, 3879 __attribute__((unused)) void *data) 3880 { 3881 struct cmd_tx_vlan_set_qinq_result *res = parsed_result; 3882 3883 if (!port_is_stopped(res->port_id)) { 3884 printf("Please stop port %d first\n", res->port_id); 3885 return; 3886 } 3887 3888 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer); 3889 3890 cmd_reconfig_device_queue(res->port_id, 1, 1); 3891 } 3892 3893 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan = 3894 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 3895 tx_vlan, "tx_vlan"); 3896 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set = 3897 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 3898 set, "set"); 3899 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid = 3900 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 3901 port_id, UINT16); 3902 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid = 3903 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 3904 vlan_id, UINT16); 3905 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer = 3906 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 3907 vlan_id_outer, UINT16); 3908 3909 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = { 3910 .f = cmd_tx_vlan_set_qinq_parsed, 3911 .data = NULL, 3912 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: " 3913 "Enable hardware insertion of double VLAN header " 3914 "with given TAG Identifiers in packets sent on a port", 3915 .tokens = { 3916 (void *)&cmd_tx_vlan_set_qinq_tx_vlan, 3917 (void *)&cmd_tx_vlan_set_qinq_set, 3918 (void *)&cmd_tx_vlan_set_qinq_portid, 3919 (void *)&cmd_tx_vlan_set_qinq_vlanid, 3920 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer, 3921 NULL, 3922 }, 3923 }; 3924 3925 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */ 3926 struct cmd_tx_vlan_set_pvid_result { 3927 cmdline_fixed_string_t tx_vlan; 3928 cmdline_fixed_string_t set; 3929 cmdline_fixed_string_t pvid; 3930 portid_t port_id; 3931 uint16_t vlan_id; 3932 cmdline_fixed_string_t mode; 3933 }; 3934 3935 static void 3936 cmd_tx_vlan_set_pvid_parsed(void *parsed_result, 3937 __attribute__((unused)) struct cmdline *cl, 3938 __attribute__((unused)) void *data) 3939 { 3940 struct cmd_tx_vlan_set_pvid_result *res = parsed_result; 3941 3942 if (strcmp(res->mode, "on") == 0) 3943 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1); 3944 else 3945 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0); 3946 } 3947 3948 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan = 3949 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 3950 tx_vlan, "tx_vlan"); 3951 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set = 3952 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 3953 set, "set"); 3954 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid = 3955 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 3956 pvid, "pvid"); 3957 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id = 3958 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 3959 port_id, UINT16); 3960 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id = 3961 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 3962 vlan_id, UINT16); 3963 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode = 3964 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 3965 mode, "on#off"); 3966 3967 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = { 3968 .f = cmd_tx_vlan_set_pvid_parsed, 3969 .data = NULL, 3970 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off", 3971 .tokens = { 3972 (void *)&cmd_tx_vlan_set_pvid_tx_vlan, 3973 (void *)&cmd_tx_vlan_set_pvid_set, 3974 (void *)&cmd_tx_vlan_set_pvid_pvid, 3975 (void *)&cmd_tx_vlan_set_pvid_port_id, 3976 (void *)&cmd_tx_vlan_set_pvid_vlan_id, 3977 (void *)&cmd_tx_vlan_set_pvid_mode, 3978 NULL, 3979 }, 3980 }; 3981 3982 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 3983 struct cmd_tx_vlan_reset_result { 3984 cmdline_fixed_string_t tx_vlan; 3985 cmdline_fixed_string_t reset; 3986 portid_t port_id; 3987 }; 3988 3989 static void 3990 cmd_tx_vlan_reset_parsed(void *parsed_result, 3991 __attribute__((unused)) struct cmdline *cl, 3992 __attribute__((unused)) void *data) 3993 { 3994 struct cmd_tx_vlan_reset_result *res = parsed_result; 3995 3996 if (!port_is_stopped(res->port_id)) { 3997 printf("Please stop port %d first\n", res->port_id); 3998 return; 3999 } 4000 4001 tx_vlan_reset(res->port_id); 4002 4003 cmd_reconfig_device_queue(res->port_id, 1, 1); 4004 } 4005 4006 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan = 4007 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4008 tx_vlan, "tx_vlan"); 4009 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset = 4010 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4011 reset, "reset"); 4012 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid = 4013 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result, 4014 port_id, UINT16); 4015 4016 cmdline_parse_inst_t cmd_tx_vlan_reset = { 4017 .f = cmd_tx_vlan_reset_parsed, 4018 .data = NULL, 4019 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a " 4020 "VLAN header in packets sent on a port", 4021 .tokens = { 4022 (void *)&cmd_tx_vlan_reset_tx_vlan, 4023 (void *)&cmd_tx_vlan_reset_reset, 4024 (void *)&cmd_tx_vlan_reset_portid, 4025 NULL, 4026 }, 4027 }; 4028 4029 4030 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ 4031 struct cmd_csum_result { 4032 cmdline_fixed_string_t csum; 4033 cmdline_fixed_string_t mode; 4034 cmdline_fixed_string_t proto; 4035 cmdline_fixed_string_t hwsw; 4036 portid_t port_id; 4037 }; 4038 4039 static void 4040 csum_show(int port_id) 4041 { 4042 struct rte_eth_dev_info dev_info; 4043 uint64_t tx_offloads; 4044 4045 tx_offloads = ports[port_id].dev_conf.txmode.offloads; 4046 printf("Parse tunnel is %s\n", 4047 (ports[port_id].parse_tunnel) ? "on" : "off"); 4048 printf("IP checksum offload is %s\n", 4049 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw"); 4050 printf("UDP checksum offload is %s\n", 4051 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); 4052 printf("TCP checksum offload is %s\n", 4053 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); 4054 printf("SCTP checksum offload is %s\n", 4055 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); 4056 printf("Outer-Ip checksum offload is %s\n", 4057 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw"); 4058 4059 /* display warnings if configuration is not supported by the NIC */ 4060 rte_eth_dev_info_get(port_id, &dev_info); 4061 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) && 4062 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { 4063 printf("Warning: hardware IP checksum enabled but not " 4064 "supported by port %d\n", port_id); 4065 } 4066 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) && 4067 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { 4068 printf("Warning: hardware UDP checksum enabled but not " 4069 "supported by port %d\n", port_id); 4070 } 4071 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) && 4072 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { 4073 printf("Warning: hardware TCP checksum enabled but not " 4074 "supported by port %d\n", port_id); 4075 } 4076 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) && 4077 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { 4078 printf("Warning: hardware SCTP checksum enabled but not " 4079 "supported by port %d\n", port_id); 4080 } 4081 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) && 4082 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { 4083 printf("Warning: hardware outer IP checksum enabled but not " 4084 "supported by port %d\n", port_id); 4085 } 4086 } 4087 4088 static void 4089 cmd_csum_parsed(void *parsed_result, 4090 __attribute__((unused)) struct cmdline *cl, 4091 __attribute__((unused)) void *data) 4092 { 4093 struct cmd_csum_result *res = parsed_result; 4094 int hw = 0; 4095 uint64_t csum_offloads = 0; 4096 struct rte_eth_dev_info dev_info; 4097 4098 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) { 4099 printf("invalid port %d\n", res->port_id); 4100 return; 4101 } 4102 if (!port_is_stopped(res->port_id)) { 4103 printf("Please stop port %d first\n", res->port_id); 4104 return; 4105 } 4106 4107 rte_eth_dev_info_get(res->port_id, &dev_info); 4108 if (!strcmp(res->mode, "set")) { 4109 4110 if (!strcmp(res->hwsw, "hw")) 4111 hw = 1; 4112 4113 if (!strcmp(res->proto, "ip")) { 4114 if (hw == 0 || (dev_info.tx_offload_capa & 4115 DEV_TX_OFFLOAD_IPV4_CKSUM)) { 4116 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM; 4117 } else { 4118 printf("IP checksum offload is not supported " 4119 "by port %u\n", res->port_id); 4120 } 4121 } else if (!strcmp(res->proto, "udp")) { 4122 if (hw == 0 || (dev_info.tx_offload_capa & 4123 DEV_TX_OFFLOAD_UDP_CKSUM)) { 4124 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; 4125 } else { 4126 printf("UDP checksum offload is not supported " 4127 "by port %u\n", res->port_id); 4128 } 4129 } else if (!strcmp(res->proto, "tcp")) { 4130 if (hw == 0 || (dev_info.tx_offload_capa & 4131 DEV_TX_OFFLOAD_TCP_CKSUM)) { 4132 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; 4133 } else { 4134 printf("TCP checksum offload is not supported " 4135 "by port %u\n", res->port_id); 4136 } 4137 } else if (!strcmp(res->proto, "sctp")) { 4138 if (hw == 0 || (dev_info.tx_offload_capa & 4139 DEV_TX_OFFLOAD_SCTP_CKSUM)) { 4140 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; 4141 } else { 4142 printf("SCTP checksum offload is not supported " 4143 "by port %u\n", res->port_id); 4144 } 4145 } else if (!strcmp(res->proto, "outer-ip")) { 4146 if (hw == 0 || (dev_info.tx_offload_capa & 4147 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) { 4148 csum_offloads |= 4149 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; 4150 } else { 4151 printf("Outer IP checksum offload is not " 4152 "supported by port %u\n", res->port_id); 4153 } 4154 } 4155 4156 if (hw) { 4157 ports[res->port_id].dev_conf.txmode.offloads |= 4158 csum_offloads; 4159 } else { 4160 ports[res->port_id].dev_conf.txmode.offloads &= 4161 (~csum_offloads); 4162 } 4163 } 4164 csum_show(res->port_id); 4165 4166 cmd_reconfig_device_queue(res->port_id, 1, 1); 4167 } 4168 4169 cmdline_parse_token_string_t cmd_csum_csum = 4170 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4171 csum, "csum"); 4172 cmdline_parse_token_string_t cmd_csum_mode = 4173 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4174 mode, "set"); 4175 cmdline_parse_token_string_t cmd_csum_proto = 4176 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4177 proto, "ip#tcp#udp#sctp#outer-ip"); 4178 cmdline_parse_token_string_t cmd_csum_hwsw = 4179 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4180 hwsw, "hw#sw"); 4181 cmdline_parse_token_num_t cmd_csum_portid = 4182 TOKEN_NUM_INITIALIZER(struct cmd_csum_result, 4183 port_id, UINT16); 4184 4185 cmdline_parse_inst_t cmd_csum_set = { 4186 .f = cmd_csum_parsed, 4187 .data = NULL, 4188 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: " 4189 "Enable/Disable hardware calculation of L3/L4 checksum when " 4190 "using csum forward engine", 4191 .tokens = { 4192 (void *)&cmd_csum_csum, 4193 (void *)&cmd_csum_mode, 4194 (void *)&cmd_csum_proto, 4195 (void *)&cmd_csum_hwsw, 4196 (void *)&cmd_csum_portid, 4197 NULL, 4198 }, 4199 }; 4200 4201 cmdline_parse_token_string_t cmd_csum_mode_show = 4202 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4203 mode, "show"); 4204 4205 cmdline_parse_inst_t cmd_csum_show = { 4206 .f = cmd_csum_parsed, 4207 .data = NULL, 4208 .help_str = "csum show <port_id>: Show checksum offload configuration", 4209 .tokens = { 4210 (void *)&cmd_csum_csum, 4211 (void *)&cmd_csum_mode_show, 4212 (void *)&cmd_csum_portid, 4213 NULL, 4214 }, 4215 }; 4216 4217 /* Enable/disable tunnel parsing */ 4218 struct cmd_csum_tunnel_result { 4219 cmdline_fixed_string_t csum; 4220 cmdline_fixed_string_t parse; 4221 cmdline_fixed_string_t onoff; 4222 portid_t port_id; 4223 }; 4224 4225 static void 4226 cmd_csum_tunnel_parsed(void *parsed_result, 4227 __attribute__((unused)) struct cmdline *cl, 4228 __attribute__((unused)) void *data) 4229 { 4230 struct cmd_csum_tunnel_result *res = parsed_result; 4231 4232 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4233 return; 4234 4235 if (!strcmp(res->onoff, "on")) 4236 ports[res->port_id].parse_tunnel = 1; 4237 else 4238 ports[res->port_id].parse_tunnel = 0; 4239 4240 csum_show(res->port_id); 4241 } 4242 4243 cmdline_parse_token_string_t cmd_csum_tunnel_csum = 4244 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4245 csum, "csum"); 4246 cmdline_parse_token_string_t cmd_csum_tunnel_parse = 4247 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4248 parse, "parse_tunnel"); 4249 cmdline_parse_token_string_t cmd_csum_tunnel_onoff = 4250 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4251 onoff, "on#off"); 4252 cmdline_parse_token_num_t cmd_csum_tunnel_portid = 4253 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, 4254 port_id, UINT16); 4255 4256 cmdline_parse_inst_t cmd_csum_tunnel = { 4257 .f = cmd_csum_tunnel_parsed, 4258 .data = NULL, 4259 .help_str = "csum parse_tunnel on|off <port_id>: " 4260 "Enable/Disable parsing of tunnels for csum engine", 4261 .tokens = { 4262 (void *)&cmd_csum_tunnel_csum, 4263 (void *)&cmd_csum_tunnel_parse, 4264 (void *)&cmd_csum_tunnel_onoff, 4265 (void *)&cmd_csum_tunnel_portid, 4266 NULL, 4267 }, 4268 }; 4269 4270 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */ 4271 struct cmd_tso_set_result { 4272 cmdline_fixed_string_t tso; 4273 cmdline_fixed_string_t mode; 4274 uint16_t tso_segsz; 4275 portid_t port_id; 4276 }; 4277 4278 static void 4279 cmd_tso_set_parsed(void *parsed_result, 4280 __attribute__((unused)) struct cmdline *cl, 4281 __attribute__((unused)) void *data) 4282 { 4283 struct cmd_tso_set_result *res = parsed_result; 4284 struct rte_eth_dev_info dev_info; 4285 4286 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4287 return; 4288 if (!port_is_stopped(res->port_id)) { 4289 printf("Please stop port %d first\n", res->port_id); 4290 return; 4291 } 4292 4293 if (!strcmp(res->mode, "set")) 4294 ports[res->port_id].tso_segsz = res->tso_segsz; 4295 4296 rte_eth_dev_info_get(res->port_id, &dev_info); 4297 if ((ports[res->port_id].tso_segsz != 0) && 4298 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4299 printf("Error: TSO is not supported by port %d\n", 4300 res->port_id); 4301 return; 4302 } 4303 4304 if (ports[res->port_id].tso_segsz == 0) { 4305 ports[res->port_id].dev_conf.txmode.offloads &= 4306 ~DEV_TX_OFFLOAD_TCP_TSO; 4307 printf("TSO for non-tunneled packets is disabled\n"); 4308 } else { 4309 ports[res->port_id].dev_conf.txmode.offloads |= 4310 DEV_TX_OFFLOAD_TCP_TSO; 4311 printf("TSO segment size for non-tunneled packets is %d\n", 4312 ports[res->port_id].tso_segsz); 4313 } 4314 4315 /* display warnings if configuration is not supported by the NIC */ 4316 rte_eth_dev_info_get(res->port_id, &dev_info); 4317 if ((ports[res->port_id].tso_segsz != 0) && 4318 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4319 printf("Warning: TSO enabled but not " 4320 "supported by port %d\n", res->port_id); 4321 } 4322 4323 cmd_reconfig_device_queue(res->port_id, 1, 1); 4324 } 4325 4326 cmdline_parse_token_string_t cmd_tso_set_tso = 4327 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4328 tso, "tso"); 4329 cmdline_parse_token_string_t cmd_tso_set_mode = 4330 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4331 mode, "set"); 4332 cmdline_parse_token_num_t cmd_tso_set_tso_segsz = 4333 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4334 tso_segsz, UINT16); 4335 cmdline_parse_token_num_t cmd_tso_set_portid = 4336 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4337 port_id, UINT16); 4338 4339 cmdline_parse_inst_t cmd_tso_set = { 4340 .f = cmd_tso_set_parsed, 4341 .data = NULL, 4342 .help_str = "tso set <tso_segsz> <port_id>: " 4343 "Set TSO segment size of non-tunneled packets for csum engine " 4344 "(0 to disable)", 4345 .tokens = { 4346 (void *)&cmd_tso_set_tso, 4347 (void *)&cmd_tso_set_mode, 4348 (void *)&cmd_tso_set_tso_segsz, 4349 (void *)&cmd_tso_set_portid, 4350 NULL, 4351 }, 4352 }; 4353 4354 cmdline_parse_token_string_t cmd_tso_show_mode = 4355 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4356 mode, "show"); 4357 4358 4359 cmdline_parse_inst_t cmd_tso_show = { 4360 .f = cmd_tso_set_parsed, 4361 .data = NULL, 4362 .help_str = "tso show <port_id>: " 4363 "Show TSO segment size of non-tunneled packets for csum engine", 4364 .tokens = { 4365 (void *)&cmd_tso_set_tso, 4366 (void *)&cmd_tso_show_mode, 4367 (void *)&cmd_tso_set_portid, 4368 NULL, 4369 }, 4370 }; 4371 4372 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */ 4373 struct cmd_tunnel_tso_set_result { 4374 cmdline_fixed_string_t tso; 4375 cmdline_fixed_string_t mode; 4376 uint16_t tso_segsz; 4377 portid_t port_id; 4378 }; 4379 4380 static struct rte_eth_dev_info 4381 check_tunnel_tso_nic_support(portid_t port_id) 4382 { 4383 struct rte_eth_dev_info dev_info; 4384 4385 rte_eth_dev_info_get(port_id, &dev_info); 4386 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) 4387 printf("Warning: VXLAN TUNNEL TSO not supported therefore " 4388 "not enabled for port %d\n", port_id); 4389 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO)) 4390 printf("Warning: GRE TUNNEL TSO not supported therefore " 4391 "not enabled for port %d\n", port_id); 4392 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO)) 4393 printf("Warning: IPIP TUNNEL TSO not supported therefore " 4394 "not enabled for port %d\n", port_id); 4395 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO)) 4396 printf("Warning: GENEVE TUNNEL TSO not supported therefore " 4397 "not enabled for port %d\n", port_id); 4398 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO)) 4399 printf("Warning: IP TUNNEL TSO not supported therefore " 4400 "not enabled for port %d\n", port_id); 4401 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO)) 4402 printf("Warning: UDP TUNNEL TSO not supported therefore " 4403 "not enabled for port %d\n", port_id); 4404 return dev_info; 4405 } 4406 4407 static void 4408 cmd_tunnel_tso_set_parsed(void *parsed_result, 4409 __attribute__((unused)) struct cmdline *cl, 4410 __attribute__((unused)) void *data) 4411 { 4412 struct cmd_tunnel_tso_set_result *res = parsed_result; 4413 struct rte_eth_dev_info dev_info; 4414 4415 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4416 return; 4417 if (!port_is_stopped(res->port_id)) { 4418 printf("Please stop port %d first\n", res->port_id); 4419 return; 4420 } 4421 4422 if (!strcmp(res->mode, "set")) 4423 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz; 4424 4425 dev_info = check_tunnel_tso_nic_support(res->port_id); 4426 if (ports[res->port_id].tunnel_tso_segsz == 0) { 4427 ports[res->port_id].dev_conf.txmode.offloads &= 4428 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4429 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4430 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4431 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4432 DEV_TX_OFFLOAD_IP_TNL_TSO | 4433 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4434 printf("TSO for tunneled packets is disabled\n"); 4435 } else { 4436 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4437 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4438 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4439 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4440 DEV_TX_OFFLOAD_IP_TNL_TSO | 4441 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4442 4443 ports[res->port_id].dev_conf.txmode.offloads |= 4444 (tso_offloads & dev_info.tx_offload_capa); 4445 printf("TSO segment size for tunneled packets is %d\n", 4446 ports[res->port_id].tunnel_tso_segsz); 4447 4448 /* Below conditions are needed to make it work: 4449 * (1) tunnel TSO is supported by the NIC; 4450 * (2) "csum parse_tunnel" must be set so that tunneled pkts 4451 * are recognized; 4452 * (3) for tunneled pkts with outer L3 of IPv4, 4453 * "csum set outer-ip" must be set to hw, because after tso, 4454 * total_len of outer IP header is changed, and the checksum 4455 * of outer IP header calculated by sw should be wrong; that 4456 * is not necessary for IPv6 tunneled pkts because there's no 4457 * checksum in IP header anymore. 4458 */ 4459 4460 if (!ports[res->port_id].parse_tunnel) 4461 printf("Warning: csum parse_tunnel must be set " 4462 "so that tunneled packets are recognized\n"); 4463 if (!(ports[res->port_id].dev_conf.txmode.offloads & 4464 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) 4465 printf("Warning: csum set outer-ip must be set to hw " 4466 "if outer L3 is IPv4; not necessary for IPv6\n"); 4467 } 4468 4469 cmd_reconfig_device_queue(res->port_id, 1, 1); 4470 } 4471 4472 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso = 4473 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4474 tso, "tunnel_tso"); 4475 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode = 4476 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4477 mode, "set"); 4478 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz = 4479 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4480 tso_segsz, UINT16); 4481 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid = 4482 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4483 port_id, UINT16); 4484 4485 cmdline_parse_inst_t cmd_tunnel_tso_set = { 4486 .f = cmd_tunnel_tso_set_parsed, 4487 .data = NULL, 4488 .help_str = "tunnel_tso set <tso_segsz> <port_id>: " 4489 "Set TSO segment size of tunneled packets for csum engine " 4490 "(0 to disable)", 4491 .tokens = { 4492 (void *)&cmd_tunnel_tso_set_tso, 4493 (void *)&cmd_tunnel_tso_set_mode, 4494 (void *)&cmd_tunnel_tso_set_tso_segsz, 4495 (void *)&cmd_tunnel_tso_set_portid, 4496 NULL, 4497 }, 4498 }; 4499 4500 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode = 4501 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4502 mode, "show"); 4503 4504 4505 cmdline_parse_inst_t cmd_tunnel_tso_show = { 4506 .f = cmd_tunnel_tso_set_parsed, 4507 .data = NULL, 4508 .help_str = "tunnel_tso show <port_id> " 4509 "Show TSO segment size of tunneled packets for csum engine", 4510 .tokens = { 4511 (void *)&cmd_tunnel_tso_set_tso, 4512 (void *)&cmd_tunnel_tso_show_mode, 4513 (void *)&cmd_tunnel_tso_set_portid, 4514 NULL, 4515 }, 4516 }; 4517 4518 /* *** SET GRO FOR A PORT *** */ 4519 struct cmd_gro_enable_result { 4520 cmdline_fixed_string_t cmd_set; 4521 cmdline_fixed_string_t cmd_port; 4522 cmdline_fixed_string_t cmd_keyword; 4523 cmdline_fixed_string_t cmd_onoff; 4524 portid_t cmd_pid; 4525 }; 4526 4527 static void 4528 cmd_gro_enable_parsed(void *parsed_result, 4529 __attribute__((unused)) struct cmdline *cl, 4530 __attribute__((unused)) void *data) 4531 { 4532 struct cmd_gro_enable_result *res; 4533 4534 res = parsed_result; 4535 if (!strcmp(res->cmd_keyword, "gro")) 4536 setup_gro(res->cmd_onoff, res->cmd_pid); 4537 } 4538 4539 cmdline_parse_token_string_t cmd_gro_enable_set = 4540 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4541 cmd_set, "set"); 4542 cmdline_parse_token_string_t cmd_gro_enable_port = 4543 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4544 cmd_keyword, "port"); 4545 cmdline_parse_token_num_t cmd_gro_enable_pid = 4546 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result, 4547 cmd_pid, UINT16); 4548 cmdline_parse_token_string_t cmd_gro_enable_keyword = 4549 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4550 cmd_keyword, "gro"); 4551 cmdline_parse_token_string_t cmd_gro_enable_onoff = 4552 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4553 cmd_onoff, "on#off"); 4554 4555 cmdline_parse_inst_t cmd_gro_enable = { 4556 .f = cmd_gro_enable_parsed, 4557 .data = NULL, 4558 .help_str = "set port <port_id> gro on|off", 4559 .tokens = { 4560 (void *)&cmd_gro_enable_set, 4561 (void *)&cmd_gro_enable_port, 4562 (void *)&cmd_gro_enable_pid, 4563 (void *)&cmd_gro_enable_keyword, 4564 (void *)&cmd_gro_enable_onoff, 4565 NULL, 4566 }, 4567 }; 4568 4569 /* *** DISPLAY GRO CONFIGURATION *** */ 4570 struct cmd_gro_show_result { 4571 cmdline_fixed_string_t cmd_show; 4572 cmdline_fixed_string_t cmd_port; 4573 cmdline_fixed_string_t cmd_keyword; 4574 portid_t cmd_pid; 4575 }; 4576 4577 static void 4578 cmd_gro_show_parsed(void *parsed_result, 4579 __attribute__((unused)) struct cmdline *cl, 4580 __attribute__((unused)) void *data) 4581 { 4582 struct cmd_gro_show_result *res; 4583 4584 res = parsed_result; 4585 if (!strcmp(res->cmd_keyword, "gro")) 4586 show_gro(res->cmd_pid); 4587 } 4588 4589 cmdline_parse_token_string_t cmd_gro_show_show = 4590 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4591 cmd_show, "show"); 4592 cmdline_parse_token_string_t cmd_gro_show_port = 4593 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4594 cmd_port, "port"); 4595 cmdline_parse_token_num_t cmd_gro_show_pid = 4596 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result, 4597 cmd_pid, UINT16); 4598 cmdline_parse_token_string_t cmd_gro_show_keyword = 4599 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4600 cmd_keyword, "gro"); 4601 4602 cmdline_parse_inst_t cmd_gro_show = { 4603 .f = cmd_gro_show_parsed, 4604 .data = NULL, 4605 .help_str = "show port <port_id> gro", 4606 .tokens = { 4607 (void *)&cmd_gro_show_show, 4608 (void *)&cmd_gro_show_port, 4609 (void *)&cmd_gro_show_pid, 4610 (void *)&cmd_gro_show_keyword, 4611 NULL, 4612 }, 4613 }; 4614 4615 /* *** SET FLUSH CYCLES FOR GRO *** */ 4616 struct cmd_gro_flush_result { 4617 cmdline_fixed_string_t cmd_set; 4618 cmdline_fixed_string_t cmd_keyword; 4619 cmdline_fixed_string_t cmd_flush; 4620 uint8_t cmd_cycles; 4621 }; 4622 4623 static void 4624 cmd_gro_flush_parsed(void *parsed_result, 4625 __attribute__((unused)) struct cmdline *cl, 4626 __attribute__((unused)) void *data) 4627 { 4628 struct cmd_gro_flush_result *res; 4629 4630 res = parsed_result; 4631 if ((!strcmp(res->cmd_keyword, "gro")) && 4632 (!strcmp(res->cmd_flush, "flush"))) 4633 setup_gro_flush_cycles(res->cmd_cycles); 4634 } 4635 4636 cmdline_parse_token_string_t cmd_gro_flush_set = 4637 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4638 cmd_set, "set"); 4639 cmdline_parse_token_string_t cmd_gro_flush_keyword = 4640 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4641 cmd_keyword, "gro"); 4642 cmdline_parse_token_string_t cmd_gro_flush_flush = 4643 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4644 cmd_flush, "flush"); 4645 cmdline_parse_token_num_t cmd_gro_flush_cycles = 4646 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result, 4647 cmd_cycles, UINT8); 4648 4649 cmdline_parse_inst_t cmd_gro_flush = { 4650 .f = cmd_gro_flush_parsed, 4651 .data = NULL, 4652 .help_str = "set gro flush <cycles>", 4653 .tokens = { 4654 (void *)&cmd_gro_flush_set, 4655 (void *)&cmd_gro_flush_keyword, 4656 (void *)&cmd_gro_flush_flush, 4657 (void *)&cmd_gro_flush_cycles, 4658 NULL, 4659 }, 4660 }; 4661 4662 /* *** ENABLE/DISABLE GSO *** */ 4663 struct cmd_gso_enable_result { 4664 cmdline_fixed_string_t cmd_set; 4665 cmdline_fixed_string_t cmd_port; 4666 cmdline_fixed_string_t cmd_keyword; 4667 cmdline_fixed_string_t cmd_mode; 4668 portid_t cmd_pid; 4669 }; 4670 4671 static void 4672 cmd_gso_enable_parsed(void *parsed_result, 4673 __attribute__((unused)) struct cmdline *cl, 4674 __attribute__((unused)) void *data) 4675 { 4676 struct cmd_gso_enable_result *res; 4677 4678 res = parsed_result; 4679 if (!strcmp(res->cmd_keyword, "gso")) 4680 setup_gso(res->cmd_mode, res->cmd_pid); 4681 } 4682 4683 cmdline_parse_token_string_t cmd_gso_enable_set = 4684 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4685 cmd_set, "set"); 4686 cmdline_parse_token_string_t cmd_gso_enable_port = 4687 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4688 cmd_port, "port"); 4689 cmdline_parse_token_string_t cmd_gso_enable_keyword = 4690 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4691 cmd_keyword, "gso"); 4692 cmdline_parse_token_string_t cmd_gso_enable_mode = 4693 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4694 cmd_mode, "on#off"); 4695 cmdline_parse_token_num_t cmd_gso_enable_pid = 4696 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result, 4697 cmd_pid, UINT16); 4698 4699 cmdline_parse_inst_t cmd_gso_enable = { 4700 .f = cmd_gso_enable_parsed, 4701 .data = NULL, 4702 .help_str = "set port <port_id> gso on|off", 4703 .tokens = { 4704 (void *)&cmd_gso_enable_set, 4705 (void *)&cmd_gso_enable_port, 4706 (void *)&cmd_gso_enable_pid, 4707 (void *)&cmd_gso_enable_keyword, 4708 (void *)&cmd_gso_enable_mode, 4709 NULL, 4710 }, 4711 }; 4712 4713 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */ 4714 struct cmd_gso_size_result { 4715 cmdline_fixed_string_t cmd_set; 4716 cmdline_fixed_string_t cmd_keyword; 4717 cmdline_fixed_string_t cmd_segsz; 4718 uint16_t cmd_size; 4719 }; 4720 4721 static void 4722 cmd_gso_size_parsed(void *parsed_result, 4723 __attribute__((unused)) struct cmdline *cl, 4724 __attribute__((unused)) void *data) 4725 { 4726 struct cmd_gso_size_result *res = parsed_result; 4727 4728 if (test_done == 0) { 4729 printf("Before setting GSO segsz, please first" 4730 " stop fowarding\n"); 4731 return; 4732 } 4733 4734 if (!strcmp(res->cmd_keyword, "gso") && 4735 !strcmp(res->cmd_segsz, "segsz")) { 4736 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN) 4737 printf("gso_size should be larger than %zu." 4738 " Please input a legal value\n", 4739 RTE_GSO_SEG_SIZE_MIN); 4740 else 4741 gso_max_segment_size = res->cmd_size; 4742 } 4743 } 4744 4745 cmdline_parse_token_string_t cmd_gso_size_set = 4746 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 4747 cmd_set, "set"); 4748 cmdline_parse_token_string_t cmd_gso_size_keyword = 4749 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 4750 cmd_keyword, "gso"); 4751 cmdline_parse_token_string_t cmd_gso_size_segsz = 4752 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 4753 cmd_segsz, "segsz"); 4754 cmdline_parse_token_num_t cmd_gso_size_size = 4755 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result, 4756 cmd_size, UINT16); 4757 4758 cmdline_parse_inst_t cmd_gso_size = { 4759 .f = cmd_gso_size_parsed, 4760 .data = NULL, 4761 .help_str = "set gso segsz <length>", 4762 .tokens = { 4763 (void *)&cmd_gso_size_set, 4764 (void *)&cmd_gso_size_keyword, 4765 (void *)&cmd_gso_size_segsz, 4766 (void *)&cmd_gso_size_size, 4767 NULL, 4768 }, 4769 }; 4770 4771 /* *** SHOW GSO CONFIGURATION *** */ 4772 struct cmd_gso_show_result { 4773 cmdline_fixed_string_t cmd_show; 4774 cmdline_fixed_string_t cmd_port; 4775 cmdline_fixed_string_t cmd_keyword; 4776 portid_t cmd_pid; 4777 }; 4778 4779 static void 4780 cmd_gso_show_parsed(void *parsed_result, 4781 __attribute__((unused)) struct cmdline *cl, 4782 __attribute__((unused)) void *data) 4783 { 4784 struct cmd_gso_show_result *res = parsed_result; 4785 4786 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 4787 printf("invalid port id %u\n", res->cmd_pid); 4788 return; 4789 } 4790 if (!strcmp(res->cmd_keyword, "gso")) { 4791 if (gso_ports[res->cmd_pid].enable) { 4792 printf("Max GSO'd packet size: %uB\n" 4793 "Supported GSO types: TCP/IPv4, " 4794 "VxLAN with inner TCP/IPv4 packet, " 4795 "GRE with inner TCP/IPv4 packet\n", 4796 gso_max_segment_size); 4797 } else 4798 printf("GSO is not enabled on Port %u\n", res->cmd_pid); 4799 } 4800 } 4801 4802 cmdline_parse_token_string_t cmd_gso_show_show = 4803 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 4804 cmd_show, "show"); 4805 cmdline_parse_token_string_t cmd_gso_show_port = 4806 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 4807 cmd_port, "port"); 4808 cmdline_parse_token_string_t cmd_gso_show_keyword = 4809 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 4810 cmd_keyword, "gso"); 4811 cmdline_parse_token_num_t cmd_gso_show_pid = 4812 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result, 4813 cmd_pid, UINT16); 4814 4815 cmdline_parse_inst_t cmd_gso_show = { 4816 .f = cmd_gso_show_parsed, 4817 .data = NULL, 4818 .help_str = "show port <port_id> gso", 4819 .tokens = { 4820 (void *)&cmd_gso_show_show, 4821 (void *)&cmd_gso_show_port, 4822 (void *)&cmd_gso_show_pid, 4823 (void *)&cmd_gso_show_keyword, 4824 NULL, 4825 }, 4826 }; 4827 4828 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */ 4829 struct cmd_set_flush_rx { 4830 cmdline_fixed_string_t set; 4831 cmdline_fixed_string_t flush_rx; 4832 cmdline_fixed_string_t mode; 4833 }; 4834 4835 static void 4836 cmd_set_flush_rx_parsed(void *parsed_result, 4837 __attribute__((unused)) struct cmdline *cl, 4838 __attribute__((unused)) void *data) 4839 { 4840 struct cmd_set_flush_rx *res = parsed_result; 4841 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 4842 } 4843 4844 cmdline_parse_token_string_t cmd_setflushrx_set = 4845 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 4846 set, "set"); 4847 cmdline_parse_token_string_t cmd_setflushrx_flush_rx = 4848 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 4849 flush_rx, "flush_rx"); 4850 cmdline_parse_token_string_t cmd_setflushrx_mode = 4851 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 4852 mode, "on#off"); 4853 4854 4855 cmdline_parse_inst_t cmd_set_flush_rx = { 4856 .f = cmd_set_flush_rx_parsed, 4857 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams", 4858 .data = NULL, 4859 .tokens = { 4860 (void *)&cmd_setflushrx_set, 4861 (void *)&cmd_setflushrx_flush_rx, 4862 (void *)&cmd_setflushrx_mode, 4863 NULL, 4864 }, 4865 }; 4866 4867 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */ 4868 struct cmd_set_link_check { 4869 cmdline_fixed_string_t set; 4870 cmdline_fixed_string_t link_check; 4871 cmdline_fixed_string_t mode; 4872 }; 4873 4874 static void 4875 cmd_set_link_check_parsed(void *parsed_result, 4876 __attribute__((unused)) struct cmdline *cl, 4877 __attribute__((unused)) void *data) 4878 { 4879 struct cmd_set_link_check *res = parsed_result; 4880 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 4881 } 4882 4883 cmdline_parse_token_string_t cmd_setlinkcheck_set = 4884 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 4885 set, "set"); 4886 cmdline_parse_token_string_t cmd_setlinkcheck_link_check = 4887 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 4888 link_check, "link_check"); 4889 cmdline_parse_token_string_t cmd_setlinkcheck_mode = 4890 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 4891 mode, "on#off"); 4892 4893 4894 cmdline_parse_inst_t cmd_set_link_check = { 4895 .f = cmd_set_link_check_parsed, 4896 .help_str = "set link_check on|off: Enable/Disable link status check " 4897 "when starting/stopping a port", 4898 .data = NULL, 4899 .tokens = { 4900 (void *)&cmd_setlinkcheck_set, 4901 (void *)&cmd_setlinkcheck_link_check, 4902 (void *)&cmd_setlinkcheck_mode, 4903 NULL, 4904 }, 4905 }; 4906 4907 /* *** SET NIC BYPASS MODE *** */ 4908 struct cmd_set_bypass_mode_result { 4909 cmdline_fixed_string_t set; 4910 cmdline_fixed_string_t bypass; 4911 cmdline_fixed_string_t mode; 4912 cmdline_fixed_string_t value; 4913 portid_t port_id; 4914 }; 4915 4916 static void 4917 cmd_set_bypass_mode_parsed(void *parsed_result, 4918 __attribute__((unused)) struct cmdline *cl, 4919 __attribute__((unused)) void *data) 4920 { 4921 struct cmd_set_bypass_mode_result *res = parsed_result; 4922 portid_t port_id = res->port_id; 4923 int32_t rc = -EINVAL; 4924 4925 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 4926 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 4927 4928 if (!strcmp(res->value, "bypass")) 4929 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 4930 else if (!strcmp(res->value, "isolate")) 4931 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 4932 else 4933 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 4934 4935 /* Set the bypass mode for the relevant port. */ 4936 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode); 4937 #endif 4938 if (rc != 0) 4939 printf("\t Failed to set bypass mode for port = %d.\n", port_id); 4940 } 4941 4942 cmdline_parse_token_string_t cmd_setbypass_mode_set = 4943 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 4944 set, "set"); 4945 cmdline_parse_token_string_t cmd_setbypass_mode_bypass = 4946 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 4947 bypass, "bypass"); 4948 cmdline_parse_token_string_t cmd_setbypass_mode_mode = 4949 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 4950 mode, "mode"); 4951 cmdline_parse_token_string_t cmd_setbypass_mode_value = 4952 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 4953 value, "normal#bypass#isolate"); 4954 cmdline_parse_token_num_t cmd_setbypass_mode_port = 4955 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result, 4956 port_id, UINT16); 4957 4958 cmdline_parse_inst_t cmd_set_bypass_mode = { 4959 .f = cmd_set_bypass_mode_parsed, 4960 .help_str = "set bypass mode normal|bypass|isolate <port_id>: " 4961 "Set the NIC bypass mode for port_id", 4962 .data = NULL, 4963 .tokens = { 4964 (void *)&cmd_setbypass_mode_set, 4965 (void *)&cmd_setbypass_mode_bypass, 4966 (void *)&cmd_setbypass_mode_mode, 4967 (void *)&cmd_setbypass_mode_value, 4968 (void *)&cmd_setbypass_mode_port, 4969 NULL, 4970 }, 4971 }; 4972 4973 /* *** SET NIC BYPASS EVENT *** */ 4974 struct cmd_set_bypass_event_result { 4975 cmdline_fixed_string_t set; 4976 cmdline_fixed_string_t bypass; 4977 cmdline_fixed_string_t event; 4978 cmdline_fixed_string_t event_value; 4979 cmdline_fixed_string_t mode; 4980 cmdline_fixed_string_t mode_value; 4981 portid_t port_id; 4982 }; 4983 4984 static void 4985 cmd_set_bypass_event_parsed(void *parsed_result, 4986 __attribute__((unused)) struct cmdline *cl, 4987 __attribute__((unused)) void *data) 4988 { 4989 int32_t rc = -EINVAL; 4990 struct cmd_set_bypass_event_result *res = parsed_result; 4991 portid_t port_id = res->port_id; 4992 4993 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 4994 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 4995 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 4996 4997 if (!strcmp(res->event_value, "timeout")) 4998 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT; 4999 else if (!strcmp(res->event_value, "os_on")) 5000 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON; 5001 else if (!strcmp(res->event_value, "os_off")) 5002 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF; 5003 else if (!strcmp(res->event_value, "power_on")) 5004 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON; 5005 else if (!strcmp(res->event_value, "power_off")) 5006 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF; 5007 else 5008 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5009 5010 if (!strcmp(res->mode_value, "bypass")) 5011 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5012 else if (!strcmp(res->mode_value, "isolate")) 5013 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5014 else 5015 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5016 5017 /* Set the watchdog timeout. */ 5018 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) { 5019 5020 rc = -EINVAL; 5021 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) { 5022 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id, 5023 bypass_timeout); 5024 } 5025 if (rc != 0) { 5026 printf("Failed to set timeout value %u " 5027 "for port %d, errto code: %d.\n", 5028 bypass_timeout, port_id, rc); 5029 } 5030 } 5031 5032 /* Set the bypass event to transition to bypass mode. */ 5033 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event, 5034 bypass_mode); 5035 #endif 5036 5037 if (rc != 0) 5038 printf("\t Failed to set bypass event for port = %d.\n", 5039 port_id); 5040 } 5041 5042 cmdline_parse_token_string_t cmd_setbypass_event_set = 5043 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5044 set, "set"); 5045 cmdline_parse_token_string_t cmd_setbypass_event_bypass = 5046 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5047 bypass, "bypass"); 5048 cmdline_parse_token_string_t cmd_setbypass_event_event = 5049 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5050 event, "event"); 5051 cmdline_parse_token_string_t cmd_setbypass_event_event_value = 5052 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5053 event_value, "none#timeout#os_off#os_on#power_on#power_off"); 5054 cmdline_parse_token_string_t cmd_setbypass_event_mode = 5055 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5056 mode, "mode"); 5057 cmdline_parse_token_string_t cmd_setbypass_event_mode_value = 5058 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5059 mode_value, "normal#bypass#isolate"); 5060 cmdline_parse_token_num_t cmd_setbypass_event_port = 5061 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result, 5062 port_id, UINT16); 5063 5064 cmdline_parse_inst_t cmd_set_bypass_event = { 5065 .f = cmd_set_bypass_event_parsed, 5066 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|" 5067 "power_off mode normal|bypass|isolate <port_id>: " 5068 "Set the NIC bypass event mode for port_id", 5069 .data = NULL, 5070 .tokens = { 5071 (void *)&cmd_setbypass_event_set, 5072 (void *)&cmd_setbypass_event_bypass, 5073 (void *)&cmd_setbypass_event_event, 5074 (void *)&cmd_setbypass_event_event_value, 5075 (void *)&cmd_setbypass_event_mode, 5076 (void *)&cmd_setbypass_event_mode_value, 5077 (void *)&cmd_setbypass_event_port, 5078 NULL, 5079 }, 5080 }; 5081 5082 5083 /* *** SET NIC BYPASS TIMEOUT *** */ 5084 struct cmd_set_bypass_timeout_result { 5085 cmdline_fixed_string_t set; 5086 cmdline_fixed_string_t bypass; 5087 cmdline_fixed_string_t timeout; 5088 cmdline_fixed_string_t value; 5089 }; 5090 5091 static void 5092 cmd_set_bypass_timeout_parsed(void *parsed_result, 5093 __attribute__((unused)) struct cmdline *cl, 5094 __attribute__((unused)) void *data) 5095 { 5096 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result; 5097 5098 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5099 if (!strcmp(res->value, "1.5")) 5100 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC; 5101 else if (!strcmp(res->value, "2")) 5102 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC; 5103 else if (!strcmp(res->value, "3")) 5104 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC; 5105 else if (!strcmp(res->value, "4")) 5106 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC; 5107 else if (!strcmp(res->value, "8")) 5108 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC; 5109 else if (!strcmp(res->value, "16")) 5110 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC; 5111 else if (!strcmp(res->value, "32")) 5112 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC; 5113 else 5114 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5115 #endif 5116 } 5117 5118 cmdline_parse_token_string_t cmd_setbypass_timeout_set = 5119 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5120 set, "set"); 5121 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass = 5122 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5123 bypass, "bypass"); 5124 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout = 5125 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5126 timeout, "timeout"); 5127 cmdline_parse_token_string_t cmd_setbypass_timeout_value = 5128 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5129 value, "0#1.5#2#3#4#8#16#32"); 5130 5131 cmdline_parse_inst_t cmd_set_bypass_timeout = { 5132 .f = cmd_set_bypass_timeout_parsed, 5133 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: " 5134 "Set the NIC bypass watchdog timeout in seconds", 5135 .data = NULL, 5136 .tokens = { 5137 (void *)&cmd_setbypass_timeout_set, 5138 (void *)&cmd_setbypass_timeout_bypass, 5139 (void *)&cmd_setbypass_timeout_timeout, 5140 (void *)&cmd_setbypass_timeout_value, 5141 NULL, 5142 }, 5143 }; 5144 5145 /* *** SHOW NIC BYPASS MODE *** */ 5146 struct cmd_show_bypass_config_result { 5147 cmdline_fixed_string_t show; 5148 cmdline_fixed_string_t bypass; 5149 cmdline_fixed_string_t config; 5150 portid_t port_id; 5151 }; 5152 5153 static void 5154 cmd_show_bypass_config_parsed(void *parsed_result, 5155 __attribute__((unused)) struct cmdline *cl, 5156 __attribute__((unused)) void *data) 5157 { 5158 struct cmd_show_bypass_config_result *res = parsed_result; 5159 portid_t port_id = res->port_id; 5160 int rc = -EINVAL; 5161 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5162 uint32_t event_mode; 5163 uint32_t bypass_mode; 5164 uint32_t timeout = bypass_timeout; 5165 int i; 5166 5167 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] = 5168 {"off", "1.5", "2", "3", "4", "8", "16", "32"}; 5169 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] = 5170 {"UNKNOWN", "normal", "bypass", "isolate"}; 5171 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = { 5172 "NONE", 5173 "OS/board on", 5174 "power supply on", 5175 "OS/board off", 5176 "power supply off", 5177 "timeout"}; 5178 int num_events = (sizeof events) / (sizeof events[0]); 5179 5180 /* Display the bypass mode.*/ 5181 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) { 5182 printf("\tFailed to get bypass mode for port = %d\n", port_id); 5183 return; 5184 } 5185 else { 5186 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode)) 5187 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5188 5189 printf("\tbypass mode = %s\n", modes[bypass_mode]); 5190 } 5191 5192 /* Display the bypass timeout.*/ 5193 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout)) 5194 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5195 5196 printf("\tbypass timeout = %s\n", timeouts[timeout]); 5197 5198 /* Display the bypass events and associated modes. */ 5199 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) { 5200 5201 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) { 5202 printf("\tFailed to get bypass mode for event = %s\n", 5203 events[i]); 5204 } else { 5205 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode)) 5206 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5207 5208 printf("\tbypass event: %-16s = %s\n", events[i], 5209 modes[event_mode]); 5210 } 5211 } 5212 #endif 5213 if (rc != 0) 5214 printf("\tFailed to get bypass configuration for port = %d\n", 5215 port_id); 5216 } 5217 5218 cmdline_parse_token_string_t cmd_showbypass_config_show = 5219 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5220 show, "show"); 5221 cmdline_parse_token_string_t cmd_showbypass_config_bypass = 5222 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5223 bypass, "bypass"); 5224 cmdline_parse_token_string_t cmd_showbypass_config_config = 5225 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5226 config, "config"); 5227 cmdline_parse_token_num_t cmd_showbypass_config_port = 5228 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result, 5229 port_id, UINT16); 5230 5231 cmdline_parse_inst_t cmd_show_bypass_config = { 5232 .f = cmd_show_bypass_config_parsed, 5233 .help_str = "show bypass config <port_id>: " 5234 "Show the NIC bypass config for port_id", 5235 .data = NULL, 5236 .tokens = { 5237 (void *)&cmd_showbypass_config_show, 5238 (void *)&cmd_showbypass_config_bypass, 5239 (void *)&cmd_showbypass_config_config, 5240 (void *)&cmd_showbypass_config_port, 5241 NULL, 5242 }, 5243 }; 5244 5245 #ifdef RTE_LIBRTE_PMD_BOND 5246 /* *** SET BONDING MODE *** */ 5247 struct cmd_set_bonding_mode_result { 5248 cmdline_fixed_string_t set; 5249 cmdline_fixed_string_t bonding; 5250 cmdline_fixed_string_t mode; 5251 uint8_t value; 5252 portid_t port_id; 5253 }; 5254 5255 static void cmd_set_bonding_mode_parsed(void *parsed_result, 5256 __attribute__((unused)) struct cmdline *cl, 5257 __attribute__((unused)) void *data) 5258 { 5259 struct cmd_set_bonding_mode_result *res = parsed_result; 5260 portid_t port_id = res->port_id; 5261 5262 /* Set the bonding mode for the relevant port. */ 5263 if (0 != rte_eth_bond_mode_set(port_id, res->value)) 5264 printf("\t Failed to set bonding mode for port = %d.\n", port_id); 5265 } 5266 5267 cmdline_parse_token_string_t cmd_setbonding_mode_set = 5268 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5269 set, "set"); 5270 cmdline_parse_token_string_t cmd_setbonding_mode_bonding = 5271 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5272 bonding, "bonding"); 5273 cmdline_parse_token_string_t cmd_setbonding_mode_mode = 5274 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5275 mode, "mode"); 5276 cmdline_parse_token_num_t cmd_setbonding_mode_value = 5277 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5278 value, UINT8); 5279 cmdline_parse_token_num_t cmd_setbonding_mode_port = 5280 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5281 port_id, UINT16); 5282 5283 cmdline_parse_inst_t cmd_set_bonding_mode = { 5284 .f = cmd_set_bonding_mode_parsed, 5285 .help_str = "set bonding mode <mode_value> <port_id>: " 5286 "Set the bonding mode for port_id", 5287 .data = NULL, 5288 .tokens = { 5289 (void *) &cmd_setbonding_mode_set, 5290 (void *) &cmd_setbonding_mode_bonding, 5291 (void *) &cmd_setbonding_mode_mode, 5292 (void *) &cmd_setbonding_mode_value, 5293 (void *) &cmd_setbonding_mode_port, 5294 NULL 5295 } 5296 }; 5297 5298 /* *** SET BONDING SLOW_QUEUE SW/HW *** */ 5299 struct cmd_set_bonding_lacp_dedicated_queues_result { 5300 cmdline_fixed_string_t set; 5301 cmdline_fixed_string_t bonding; 5302 cmdline_fixed_string_t lacp; 5303 cmdline_fixed_string_t dedicated_queues; 5304 portid_t port_id; 5305 cmdline_fixed_string_t mode; 5306 }; 5307 5308 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result, 5309 __attribute__((unused)) struct cmdline *cl, 5310 __attribute__((unused)) void *data) 5311 { 5312 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result; 5313 portid_t port_id = res->port_id; 5314 struct rte_port *port; 5315 5316 port = &ports[port_id]; 5317 5318 /** Check if the port is not started **/ 5319 if (port->port_status != RTE_PORT_STOPPED) { 5320 printf("Please stop port %d first\n", port_id); 5321 return; 5322 } 5323 5324 if (!strcmp(res->mode, "enable")) { 5325 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0) 5326 printf("Dedicate queues for LACP control packets" 5327 " enabled\n"); 5328 else 5329 printf("Enabling dedicate queues for LACP control " 5330 "packets on port %d failed\n", port_id); 5331 } else if (!strcmp(res->mode, "disable")) { 5332 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0) 5333 printf("Dedicated queues for LACP control packets " 5334 "disabled\n"); 5335 else 5336 printf("Disabling dedicated queues for LACP control " 5337 "traffic on port %d failed\n", port_id); 5338 } 5339 } 5340 5341 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set = 5342 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5343 set, "set"); 5344 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding = 5345 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5346 bonding, "bonding"); 5347 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp = 5348 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5349 lacp, "lacp"); 5350 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues = 5351 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5352 dedicated_queues, "dedicated_queues"); 5353 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id = 5354 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5355 port_id, UINT16); 5356 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode = 5357 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5358 mode, "enable#disable"); 5359 5360 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = { 5361 .f = cmd_set_bonding_lacp_dedicated_queues_parsed, 5362 .help_str = "set bonding lacp dedicated_queues <port_id> " 5363 "enable|disable: " 5364 "Enable/disable dedicated queues for LACP control traffic for port_id", 5365 .data = NULL, 5366 .tokens = { 5367 (void *)&cmd_setbonding_lacp_dedicated_queues_set, 5368 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding, 5369 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp, 5370 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues, 5371 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id, 5372 (void *)&cmd_setbonding_lacp_dedicated_queues_mode, 5373 NULL 5374 } 5375 }; 5376 5377 /* *** SET BALANCE XMIT POLICY *** */ 5378 struct cmd_set_bonding_balance_xmit_policy_result { 5379 cmdline_fixed_string_t set; 5380 cmdline_fixed_string_t bonding; 5381 cmdline_fixed_string_t balance_xmit_policy; 5382 portid_t port_id; 5383 cmdline_fixed_string_t policy; 5384 }; 5385 5386 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result, 5387 __attribute__((unused)) struct cmdline *cl, 5388 __attribute__((unused)) void *data) 5389 { 5390 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; 5391 portid_t port_id = res->port_id; 5392 uint8_t policy; 5393 5394 if (!strcmp(res->policy, "l2")) { 5395 policy = BALANCE_XMIT_POLICY_LAYER2; 5396 } else if (!strcmp(res->policy, "l23")) { 5397 policy = BALANCE_XMIT_POLICY_LAYER23; 5398 } else if (!strcmp(res->policy, "l34")) { 5399 policy = BALANCE_XMIT_POLICY_LAYER34; 5400 } else { 5401 printf("\t Invalid xmit policy selection"); 5402 return; 5403 } 5404 5405 /* Set the bonding mode for the relevant port. */ 5406 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) { 5407 printf("\t Failed to set bonding balance xmit policy for port = %d.\n", 5408 port_id); 5409 } 5410 } 5411 5412 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = 5413 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5414 set, "set"); 5415 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = 5416 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5417 bonding, "bonding"); 5418 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = 5419 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5420 balance_xmit_policy, "balance_xmit_policy"); 5421 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = 5422 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5423 port_id, UINT16); 5424 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = 5425 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5426 policy, "l2#l23#l34"); 5427 5428 cmdline_parse_inst_t cmd_set_balance_xmit_policy = { 5429 .f = cmd_set_bonding_balance_xmit_policy_parsed, 5430 .help_str = "set bonding balance_xmit_policy <port_id> " 5431 "l2|l23|l34: " 5432 "Set the bonding balance_xmit_policy for port_id", 5433 .data = NULL, 5434 .tokens = { 5435 (void *)&cmd_setbonding_balance_xmit_policy_set, 5436 (void *)&cmd_setbonding_balance_xmit_policy_bonding, 5437 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, 5438 (void *)&cmd_setbonding_balance_xmit_policy_port, 5439 (void *)&cmd_setbonding_balance_xmit_policy_policy, 5440 NULL 5441 } 5442 }; 5443 5444 /* *** SHOW NIC BONDING CONFIGURATION *** */ 5445 struct cmd_show_bonding_config_result { 5446 cmdline_fixed_string_t show; 5447 cmdline_fixed_string_t bonding; 5448 cmdline_fixed_string_t config; 5449 portid_t port_id; 5450 }; 5451 5452 static void cmd_show_bonding_config_parsed(void *parsed_result, 5453 __attribute__((unused)) struct cmdline *cl, 5454 __attribute__((unused)) void *data) 5455 { 5456 struct cmd_show_bonding_config_result *res = parsed_result; 5457 int bonding_mode, agg_mode; 5458 portid_t slaves[RTE_MAX_ETHPORTS]; 5459 int num_slaves, num_active_slaves; 5460 int primary_id; 5461 int i; 5462 portid_t port_id = res->port_id; 5463 5464 /* Display the bonding mode.*/ 5465 bonding_mode = rte_eth_bond_mode_get(port_id); 5466 if (bonding_mode < 0) { 5467 printf("\tFailed to get bonding mode for port = %d\n", port_id); 5468 return; 5469 } else 5470 printf("\tBonding mode: %d\n", bonding_mode); 5471 5472 if (bonding_mode == BONDING_MODE_BALANCE) { 5473 int balance_xmit_policy; 5474 5475 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id); 5476 if (balance_xmit_policy < 0) { 5477 printf("\tFailed to get balance xmit policy for port = %d\n", 5478 port_id); 5479 return; 5480 } else { 5481 printf("\tBalance Xmit Policy: "); 5482 5483 switch (balance_xmit_policy) { 5484 case BALANCE_XMIT_POLICY_LAYER2: 5485 printf("BALANCE_XMIT_POLICY_LAYER2"); 5486 break; 5487 case BALANCE_XMIT_POLICY_LAYER23: 5488 printf("BALANCE_XMIT_POLICY_LAYER23"); 5489 break; 5490 case BALANCE_XMIT_POLICY_LAYER34: 5491 printf("BALANCE_XMIT_POLICY_LAYER34"); 5492 break; 5493 } 5494 printf("\n"); 5495 } 5496 } 5497 5498 if (bonding_mode == BONDING_MODE_8023AD) { 5499 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id); 5500 printf("\tIEEE802.3AD Aggregator Mode: "); 5501 switch (agg_mode) { 5502 case AGG_BANDWIDTH: 5503 printf("bandwidth"); 5504 break; 5505 case AGG_STABLE: 5506 printf("stable"); 5507 break; 5508 case AGG_COUNT: 5509 printf("count"); 5510 break; 5511 } 5512 printf("\n"); 5513 } 5514 5515 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS); 5516 5517 if (num_slaves < 0) { 5518 printf("\tFailed to get slave list for port = %d\n", port_id); 5519 return; 5520 } 5521 if (num_slaves > 0) { 5522 printf("\tSlaves (%d): [", num_slaves); 5523 for (i = 0; i < num_slaves - 1; i++) 5524 printf("%d ", slaves[i]); 5525 5526 printf("%d]\n", slaves[num_slaves - 1]); 5527 } else { 5528 printf("\tSlaves: []\n"); 5529 5530 } 5531 5532 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, 5533 RTE_MAX_ETHPORTS); 5534 5535 if (num_active_slaves < 0) { 5536 printf("\tFailed to get active slave list for port = %d\n", port_id); 5537 return; 5538 } 5539 if (num_active_slaves > 0) { 5540 printf("\tActive Slaves (%d): [", num_active_slaves); 5541 for (i = 0; i < num_active_slaves - 1; i++) 5542 printf("%d ", slaves[i]); 5543 5544 printf("%d]\n", slaves[num_active_slaves - 1]); 5545 5546 } else { 5547 printf("\tActive Slaves: []\n"); 5548 5549 } 5550 5551 primary_id = rte_eth_bond_primary_get(port_id); 5552 if (primary_id < 0) { 5553 printf("\tFailed to get primary slave for port = %d\n", port_id); 5554 return; 5555 } else 5556 printf("\tPrimary: [%d]\n", primary_id); 5557 5558 } 5559 5560 cmdline_parse_token_string_t cmd_showbonding_config_show = 5561 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5562 show, "show"); 5563 cmdline_parse_token_string_t cmd_showbonding_config_bonding = 5564 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5565 bonding, "bonding"); 5566 cmdline_parse_token_string_t cmd_showbonding_config_config = 5567 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5568 config, "config"); 5569 cmdline_parse_token_num_t cmd_showbonding_config_port = 5570 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, 5571 port_id, UINT16); 5572 5573 cmdline_parse_inst_t cmd_show_bonding_config = { 5574 .f = cmd_show_bonding_config_parsed, 5575 .help_str = "show bonding config <port_id>: " 5576 "Show the bonding config for port_id", 5577 .data = NULL, 5578 .tokens = { 5579 (void *)&cmd_showbonding_config_show, 5580 (void *)&cmd_showbonding_config_bonding, 5581 (void *)&cmd_showbonding_config_config, 5582 (void *)&cmd_showbonding_config_port, 5583 NULL 5584 } 5585 }; 5586 5587 /* *** SET BONDING PRIMARY *** */ 5588 struct cmd_set_bonding_primary_result { 5589 cmdline_fixed_string_t set; 5590 cmdline_fixed_string_t bonding; 5591 cmdline_fixed_string_t primary; 5592 portid_t slave_id; 5593 portid_t port_id; 5594 }; 5595 5596 static void cmd_set_bonding_primary_parsed(void *parsed_result, 5597 __attribute__((unused)) struct cmdline *cl, 5598 __attribute__((unused)) void *data) 5599 { 5600 struct cmd_set_bonding_primary_result *res = parsed_result; 5601 portid_t master_port_id = res->port_id; 5602 portid_t slave_port_id = res->slave_id; 5603 5604 /* Set the primary slave for a bonded device. */ 5605 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) { 5606 printf("\t Failed to set primary slave for port = %d.\n", 5607 master_port_id); 5608 return; 5609 } 5610 init_port_config(); 5611 } 5612 5613 cmdline_parse_token_string_t cmd_setbonding_primary_set = 5614 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5615 set, "set"); 5616 cmdline_parse_token_string_t cmd_setbonding_primary_bonding = 5617 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5618 bonding, "bonding"); 5619 cmdline_parse_token_string_t cmd_setbonding_primary_primary = 5620 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5621 primary, "primary"); 5622 cmdline_parse_token_num_t cmd_setbonding_primary_slave = 5623 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 5624 slave_id, UINT16); 5625 cmdline_parse_token_num_t cmd_setbonding_primary_port = 5626 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 5627 port_id, UINT16); 5628 5629 cmdline_parse_inst_t cmd_set_bonding_primary = { 5630 .f = cmd_set_bonding_primary_parsed, 5631 .help_str = "set bonding primary <slave_id> <port_id>: " 5632 "Set the primary slave for port_id", 5633 .data = NULL, 5634 .tokens = { 5635 (void *)&cmd_setbonding_primary_set, 5636 (void *)&cmd_setbonding_primary_bonding, 5637 (void *)&cmd_setbonding_primary_primary, 5638 (void *)&cmd_setbonding_primary_slave, 5639 (void *)&cmd_setbonding_primary_port, 5640 NULL 5641 } 5642 }; 5643 5644 /* *** ADD SLAVE *** */ 5645 struct cmd_add_bonding_slave_result { 5646 cmdline_fixed_string_t add; 5647 cmdline_fixed_string_t bonding; 5648 cmdline_fixed_string_t slave; 5649 portid_t slave_id; 5650 portid_t port_id; 5651 }; 5652 5653 static void cmd_add_bonding_slave_parsed(void *parsed_result, 5654 __attribute__((unused)) struct cmdline *cl, 5655 __attribute__((unused)) void *data) 5656 { 5657 struct cmd_add_bonding_slave_result *res = parsed_result; 5658 portid_t master_port_id = res->port_id; 5659 portid_t slave_port_id = res->slave_id; 5660 5661 /* add the slave for a bonded device. */ 5662 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) { 5663 printf("\t Failed to add slave %d to master port = %d.\n", 5664 slave_port_id, master_port_id); 5665 return; 5666 } 5667 init_port_config(); 5668 set_port_slave_flag(slave_port_id); 5669 } 5670 5671 cmdline_parse_token_string_t cmd_addbonding_slave_add = 5672 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5673 add, "add"); 5674 cmdline_parse_token_string_t cmd_addbonding_slave_bonding = 5675 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5676 bonding, "bonding"); 5677 cmdline_parse_token_string_t cmd_addbonding_slave_slave = 5678 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5679 slave, "slave"); 5680 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = 5681 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 5682 slave_id, UINT16); 5683 cmdline_parse_token_num_t cmd_addbonding_slave_port = 5684 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 5685 port_id, UINT16); 5686 5687 cmdline_parse_inst_t cmd_add_bonding_slave = { 5688 .f = cmd_add_bonding_slave_parsed, 5689 .help_str = "add bonding slave <slave_id> <port_id>: " 5690 "Add a slave device to a bonded device", 5691 .data = NULL, 5692 .tokens = { 5693 (void *)&cmd_addbonding_slave_add, 5694 (void *)&cmd_addbonding_slave_bonding, 5695 (void *)&cmd_addbonding_slave_slave, 5696 (void *)&cmd_addbonding_slave_slaveid, 5697 (void *)&cmd_addbonding_slave_port, 5698 NULL 5699 } 5700 }; 5701 5702 /* *** REMOVE SLAVE *** */ 5703 struct cmd_remove_bonding_slave_result { 5704 cmdline_fixed_string_t remove; 5705 cmdline_fixed_string_t bonding; 5706 cmdline_fixed_string_t slave; 5707 portid_t slave_id; 5708 portid_t port_id; 5709 }; 5710 5711 static void cmd_remove_bonding_slave_parsed(void *parsed_result, 5712 __attribute__((unused)) struct cmdline *cl, 5713 __attribute__((unused)) void *data) 5714 { 5715 struct cmd_remove_bonding_slave_result *res = parsed_result; 5716 portid_t master_port_id = res->port_id; 5717 portid_t slave_port_id = res->slave_id; 5718 5719 /* remove the slave from a bonded device. */ 5720 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) { 5721 printf("\t Failed to remove slave %d from master port = %d.\n", 5722 slave_port_id, master_port_id); 5723 return; 5724 } 5725 init_port_config(); 5726 clear_port_slave_flag(slave_port_id); 5727 } 5728 5729 cmdline_parse_token_string_t cmd_removebonding_slave_remove = 5730 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 5731 remove, "remove"); 5732 cmdline_parse_token_string_t cmd_removebonding_slave_bonding = 5733 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 5734 bonding, "bonding"); 5735 cmdline_parse_token_string_t cmd_removebonding_slave_slave = 5736 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 5737 slave, "slave"); 5738 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = 5739 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 5740 slave_id, UINT16); 5741 cmdline_parse_token_num_t cmd_removebonding_slave_port = 5742 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 5743 port_id, UINT16); 5744 5745 cmdline_parse_inst_t cmd_remove_bonding_slave = { 5746 .f = cmd_remove_bonding_slave_parsed, 5747 .help_str = "remove bonding slave <slave_id> <port_id>: " 5748 "Remove a slave device from a bonded device", 5749 .data = NULL, 5750 .tokens = { 5751 (void *)&cmd_removebonding_slave_remove, 5752 (void *)&cmd_removebonding_slave_bonding, 5753 (void *)&cmd_removebonding_slave_slave, 5754 (void *)&cmd_removebonding_slave_slaveid, 5755 (void *)&cmd_removebonding_slave_port, 5756 NULL 5757 } 5758 }; 5759 5760 /* *** CREATE BONDED DEVICE *** */ 5761 struct cmd_create_bonded_device_result { 5762 cmdline_fixed_string_t create; 5763 cmdline_fixed_string_t bonded; 5764 cmdline_fixed_string_t device; 5765 uint8_t mode; 5766 uint8_t socket; 5767 }; 5768 5769 static int bond_dev_num = 0; 5770 5771 static void cmd_create_bonded_device_parsed(void *parsed_result, 5772 __attribute__((unused)) struct cmdline *cl, 5773 __attribute__((unused)) void *data) 5774 { 5775 struct cmd_create_bonded_device_result *res = parsed_result; 5776 char ethdev_name[RTE_ETH_NAME_MAX_LEN]; 5777 int port_id; 5778 5779 if (test_done == 0) { 5780 printf("Please stop forwarding first\n"); 5781 return; 5782 } 5783 5784 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d", 5785 bond_dev_num++); 5786 5787 /* Create a new bonded device. */ 5788 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket); 5789 if (port_id < 0) { 5790 printf("\t Failed to create bonded device.\n"); 5791 return; 5792 } else { 5793 printf("Created new bonded device %s on (port %d).\n", ethdev_name, 5794 port_id); 5795 5796 /* Update number of ports */ 5797 nb_ports = rte_eth_dev_count_avail(); 5798 reconfig(port_id, res->socket); 5799 rte_eth_promiscuous_enable(port_id); 5800 } 5801 5802 } 5803 5804 cmdline_parse_token_string_t cmd_createbonded_device_create = 5805 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 5806 create, "create"); 5807 cmdline_parse_token_string_t cmd_createbonded_device_bonded = 5808 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 5809 bonded, "bonded"); 5810 cmdline_parse_token_string_t cmd_createbonded_device_device = 5811 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 5812 device, "device"); 5813 cmdline_parse_token_num_t cmd_createbonded_device_mode = 5814 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 5815 mode, UINT8); 5816 cmdline_parse_token_num_t cmd_createbonded_device_socket = 5817 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 5818 socket, UINT8); 5819 5820 cmdline_parse_inst_t cmd_create_bonded_device = { 5821 .f = cmd_create_bonded_device_parsed, 5822 .help_str = "create bonded device <mode> <socket>: " 5823 "Create a new bonded device with specific bonding mode and socket", 5824 .data = NULL, 5825 .tokens = { 5826 (void *)&cmd_createbonded_device_create, 5827 (void *)&cmd_createbonded_device_bonded, 5828 (void *)&cmd_createbonded_device_device, 5829 (void *)&cmd_createbonded_device_mode, 5830 (void *)&cmd_createbonded_device_socket, 5831 NULL 5832 } 5833 }; 5834 5835 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */ 5836 struct cmd_set_bond_mac_addr_result { 5837 cmdline_fixed_string_t set; 5838 cmdline_fixed_string_t bonding; 5839 cmdline_fixed_string_t mac_addr; 5840 uint16_t port_num; 5841 struct ether_addr address; 5842 }; 5843 5844 static void cmd_set_bond_mac_addr_parsed(void *parsed_result, 5845 __attribute__((unused)) struct cmdline *cl, 5846 __attribute__((unused)) void *data) 5847 { 5848 struct cmd_set_bond_mac_addr_result *res = parsed_result; 5849 int ret; 5850 5851 if (port_id_is_invalid(res->port_num, ENABLED_WARN)) 5852 return; 5853 5854 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address); 5855 5856 /* check the return value and print it if is < 0 */ 5857 if (ret < 0) 5858 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 5859 } 5860 5861 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set = 5862 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); 5863 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = 5864 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, 5865 "bonding"); 5866 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = 5867 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, 5868 "mac_addr"); 5869 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = 5870 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, 5871 port_num, UINT16); 5872 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = 5873 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); 5874 5875 cmdline_parse_inst_t cmd_set_bond_mac_addr = { 5876 .f = cmd_set_bond_mac_addr_parsed, 5877 .data = (void *) 0, 5878 .help_str = "set bonding mac_addr <port_id> <mac_addr>", 5879 .tokens = { 5880 (void *)&cmd_set_bond_mac_addr_set, 5881 (void *)&cmd_set_bond_mac_addr_bonding, 5882 (void *)&cmd_set_bond_mac_addr_mac, 5883 (void *)&cmd_set_bond_mac_addr_portnum, 5884 (void *)&cmd_set_bond_mac_addr_addr, 5885 NULL 5886 } 5887 }; 5888 5889 5890 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */ 5891 struct cmd_set_bond_mon_period_result { 5892 cmdline_fixed_string_t set; 5893 cmdline_fixed_string_t bonding; 5894 cmdline_fixed_string_t mon_period; 5895 uint16_t port_num; 5896 uint32_t period_ms; 5897 }; 5898 5899 static void cmd_set_bond_mon_period_parsed(void *parsed_result, 5900 __attribute__((unused)) struct cmdline *cl, 5901 __attribute__((unused)) void *data) 5902 { 5903 struct cmd_set_bond_mon_period_result *res = parsed_result; 5904 int ret; 5905 5906 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms); 5907 5908 /* check the return value and print it if is < 0 */ 5909 if (ret < 0) 5910 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 5911 } 5912 5913 cmdline_parse_token_string_t cmd_set_bond_mon_period_set = 5914 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 5915 set, "set"); 5916 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding = 5917 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 5918 bonding, "bonding"); 5919 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period = 5920 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 5921 mon_period, "mon_period"); 5922 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum = 5923 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 5924 port_num, UINT16); 5925 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms = 5926 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 5927 period_ms, UINT32); 5928 5929 cmdline_parse_inst_t cmd_set_bond_mon_period = { 5930 .f = cmd_set_bond_mon_period_parsed, 5931 .data = (void *) 0, 5932 .help_str = "set bonding mon_period <port_id> <period_ms>", 5933 .tokens = { 5934 (void *)&cmd_set_bond_mon_period_set, 5935 (void *)&cmd_set_bond_mon_period_bonding, 5936 (void *)&cmd_set_bond_mon_period_mon_period, 5937 (void *)&cmd_set_bond_mon_period_portnum, 5938 (void *)&cmd_set_bond_mon_period_period_ms, 5939 NULL 5940 } 5941 }; 5942 5943 5944 5945 struct cmd_set_bonding_agg_mode_policy_result { 5946 cmdline_fixed_string_t set; 5947 cmdline_fixed_string_t bonding; 5948 cmdline_fixed_string_t agg_mode; 5949 uint16_t port_num; 5950 cmdline_fixed_string_t policy; 5951 }; 5952 5953 5954 static void 5955 cmd_set_bonding_agg_mode(void *parsed_result, 5956 __attribute__((unused)) struct cmdline *cl, 5957 __attribute__((unused)) void *data) 5958 { 5959 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result; 5960 uint8_t policy = AGG_BANDWIDTH; 5961 5962 if (!strcmp(res->policy, "bandwidth")) 5963 policy = AGG_BANDWIDTH; 5964 else if (!strcmp(res->policy, "stable")) 5965 policy = AGG_STABLE; 5966 else if (!strcmp(res->policy, "count")) 5967 policy = AGG_COUNT; 5968 5969 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy); 5970 } 5971 5972 5973 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set = 5974 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 5975 set, "set"); 5976 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding = 5977 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 5978 bonding, "bonding"); 5979 5980 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode = 5981 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 5982 agg_mode, "agg_mode"); 5983 5984 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum = 5985 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 5986 port_num, UINT16); 5987 5988 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string = 5989 TOKEN_STRING_INITIALIZER( 5990 struct cmd_set_bonding_balance_xmit_policy_result, 5991 policy, "stable#bandwidth#count"); 5992 5993 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = { 5994 .f = cmd_set_bonding_agg_mode, 5995 .data = (void *) 0, 5996 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>", 5997 .tokens = { 5998 (void *)&cmd_set_bonding_agg_mode_set, 5999 (void *)&cmd_set_bonding_agg_mode_bonding, 6000 (void *)&cmd_set_bonding_agg_mode_agg_mode, 6001 (void *)&cmd_set_bonding_agg_mode_portnum, 6002 (void *)&cmd_set_bonding_agg_mode_policy_string, 6003 NULL 6004 } 6005 }; 6006 6007 6008 #endif /* RTE_LIBRTE_PMD_BOND */ 6009 6010 /* *** SET FORWARDING MODE *** */ 6011 struct cmd_set_fwd_mode_result { 6012 cmdline_fixed_string_t set; 6013 cmdline_fixed_string_t fwd; 6014 cmdline_fixed_string_t mode; 6015 }; 6016 6017 static void cmd_set_fwd_mode_parsed(void *parsed_result, 6018 __attribute__((unused)) struct cmdline *cl, 6019 __attribute__((unused)) void *data) 6020 { 6021 struct cmd_set_fwd_mode_result *res = parsed_result; 6022 6023 retry_enabled = 0; 6024 set_pkt_forwarding_mode(res->mode); 6025 } 6026 6027 cmdline_parse_token_string_t cmd_setfwd_set = 6028 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set"); 6029 cmdline_parse_token_string_t cmd_setfwd_fwd = 6030 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd"); 6031 cmdline_parse_token_string_t cmd_setfwd_mode = 6032 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode, 6033 "" /* defined at init */); 6034 6035 cmdline_parse_inst_t cmd_set_fwd_mode = { 6036 .f = cmd_set_fwd_mode_parsed, 6037 .data = NULL, 6038 .help_str = NULL, /* defined at init */ 6039 .tokens = { 6040 (void *)&cmd_setfwd_set, 6041 (void *)&cmd_setfwd_fwd, 6042 (void *)&cmd_setfwd_mode, 6043 NULL, 6044 }, 6045 }; 6046 6047 static void cmd_set_fwd_mode_init(void) 6048 { 6049 char *modes, *c; 6050 static char token[128]; 6051 static char help[256]; 6052 cmdline_parse_token_string_t *token_struct; 6053 6054 modes = list_pkt_forwarding_modes(); 6055 snprintf(help, sizeof(help), "set fwd %s: " 6056 "Set packet forwarding mode", modes); 6057 cmd_set_fwd_mode.help_str = help; 6058 6059 /* string token separator is # */ 6060 for (c = token; *modes != '\0'; modes++) 6061 if (*modes == '|') 6062 *c++ = '#'; 6063 else 6064 *c++ = *modes; 6065 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2]; 6066 token_struct->string_data.str = token; 6067 } 6068 6069 /* *** SET RETRY FORWARDING MODE *** */ 6070 struct cmd_set_fwd_retry_mode_result { 6071 cmdline_fixed_string_t set; 6072 cmdline_fixed_string_t fwd; 6073 cmdline_fixed_string_t mode; 6074 cmdline_fixed_string_t retry; 6075 }; 6076 6077 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result, 6078 __attribute__((unused)) struct cmdline *cl, 6079 __attribute__((unused)) void *data) 6080 { 6081 struct cmd_set_fwd_retry_mode_result *res = parsed_result; 6082 6083 retry_enabled = 1; 6084 set_pkt_forwarding_mode(res->mode); 6085 } 6086 6087 cmdline_parse_token_string_t cmd_setfwd_retry_set = 6088 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6089 set, "set"); 6090 cmdline_parse_token_string_t cmd_setfwd_retry_fwd = 6091 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6092 fwd, "fwd"); 6093 cmdline_parse_token_string_t cmd_setfwd_retry_mode = 6094 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6095 mode, 6096 "" /* defined at init */); 6097 cmdline_parse_token_string_t cmd_setfwd_retry_retry = 6098 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6099 retry, "retry"); 6100 6101 cmdline_parse_inst_t cmd_set_fwd_retry_mode = { 6102 .f = cmd_set_fwd_retry_mode_parsed, 6103 .data = NULL, 6104 .help_str = NULL, /* defined at init */ 6105 .tokens = { 6106 (void *)&cmd_setfwd_retry_set, 6107 (void *)&cmd_setfwd_retry_fwd, 6108 (void *)&cmd_setfwd_retry_mode, 6109 (void *)&cmd_setfwd_retry_retry, 6110 NULL, 6111 }, 6112 }; 6113 6114 static void cmd_set_fwd_retry_mode_init(void) 6115 { 6116 char *modes, *c; 6117 static char token[128]; 6118 static char help[256]; 6119 cmdline_parse_token_string_t *token_struct; 6120 6121 modes = list_pkt_forwarding_retry_modes(); 6122 snprintf(help, sizeof(help), "set fwd %s retry: " 6123 "Set packet forwarding mode with retry", modes); 6124 cmd_set_fwd_retry_mode.help_str = help; 6125 6126 /* string token separator is # */ 6127 for (c = token; *modes != '\0'; modes++) 6128 if (*modes == '|') 6129 *c++ = '#'; 6130 else 6131 *c++ = *modes; 6132 token_struct = (cmdline_parse_token_string_t *) 6133 cmd_set_fwd_retry_mode.tokens[2]; 6134 token_struct->string_data.str = token; 6135 } 6136 6137 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */ 6138 struct cmd_set_burst_tx_retry_result { 6139 cmdline_fixed_string_t set; 6140 cmdline_fixed_string_t burst; 6141 cmdline_fixed_string_t tx; 6142 cmdline_fixed_string_t delay; 6143 uint32_t time; 6144 cmdline_fixed_string_t retry; 6145 uint32_t retry_num; 6146 }; 6147 6148 static void cmd_set_burst_tx_retry_parsed(void *parsed_result, 6149 __attribute__((unused)) struct cmdline *cl, 6150 __attribute__((unused)) void *data) 6151 { 6152 struct cmd_set_burst_tx_retry_result *res = parsed_result; 6153 6154 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst") 6155 && !strcmp(res->tx, "tx")) { 6156 if (!strcmp(res->delay, "delay")) 6157 burst_tx_delay_time = res->time; 6158 if (!strcmp(res->retry, "retry")) 6159 burst_tx_retry_num = res->retry_num; 6160 } 6161 6162 } 6163 6164 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set = 6165 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set"); 6166 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst = 6167 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst, 6168 "burst"); 6169 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx = 6170 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx"); 6171 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay = 6172 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay"); 6173 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time = 6174 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32); 6175 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry = 6176 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry"); 6177 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num = 6178 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32); 6179 6180 cmdline_parse_inst_t cmd_set_burst_tx_retry = { 6181 .f = cmd_set_burst_tx_retry_parsed, 6182 .help_str = "set burst tx delay <delay_usec> retry <num_retry>", 6183 .tokens = { 6184 (void *)&cmd_set_burst_tx_retry_set, 6185 (void *)&cmd_set_burst_tx_retry_burst, 6186 (void *)&cmd_set_burst_tx_retry_tx, 6187 (void *)&cmd_set_burst_tx_retry_delay, 6188 (void *)&cmd_set_burst_tx_retry_time, 6189 (void *)&cmd_set_burst_tx_retry_retry, 6190 (void *)&cmd_set_burst_tx_retry_retry_num, 6191 NULL, 6192 }, 6193 }; 6194 6195 /* *** SET PROMISC MODE *** */ 6196 struct cmd_set_promisc_mode_result { 6197 cmdline_fixed_string_t set; 6198 cmdline_fixed_string_t promisc; 6199 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6200 uint16_t port_num; /* valid if "allports" argument == 0 */ 6201 cmdline_fixed_string_t mode; 6202 }; 6203 6204 static void cmd_set_promisc_mode_parsed(void *parsed_result, 6205 __attribute__((unused)) struct cmdline *cl, 6206 void *allports) 6207 { 6208 struct cmd_set_promisc_mode_result *res = parsed_result; 6209 int enable; 6210 portid_t i; 6211 6212 if (!strcmp(res->mode, "on")) 6213 enable = 1; 6214 else 6215 enable = 0; 6216 6217 /* all ports */ 6218 if (allports) { 6219 RTE_ETH_FOREACH_DEV(i) { 6220 if (enable) 6221 rte_eth_promiscuous_enable(i); 6222 else 6223 rte_eth_promiscuous_disable(i); 6224 } 6225 } 6226 else { 6227 if (enable) 6228 rte_eth_promiscuous_enable(res->port_num); 6229 else 6230 rte_eth_promiscuous_disable(res->port_num); 6231 } 6232 } 6233 6234 cmdline_parse_token_string_t cmd_setpromisc_set = 6235 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set"); 6236 cmdline_parse_token_string_t cmd_setpromisc_promisc = 6237 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc, 6238 "promisc"); 6239 cmdline_parse_token_string_t cmd_setpromisc_portall = 6240 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all, 6241 "all"); 6242 cmdline_parse_token_num_t cmd_setpromisc_portnum = 6243 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num, 6244 UINT16); 6245 cmdline_parse_token_string_t cmd_setpromisc_mode = 6246 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode, 6247 "on#off"); 6248 6249 cmdline_parse_inst_t cmd_set_promisc_mode_all = { 6250 .f = cmd_set_promisc_mode_parsed, 6251 .data = (void *)1, 6252 .help_str = "set promisc all on|off: Set promisc mode for all ports", 6253 .tokens = { 6254 (void *)&cmd_setpromisc_set, 6255 (void *)&cmd_setpromisc_promisc, 6256 (void *)&cmd_setpromisc_portall, 6257 (void *)&cmd_setpromisc_mode, 6258 NULL, 6259 }, 6260 }; 6261 6262 cmdline_parse_inst_t cmd_set_promisc_mode_one = { 6263 .f = cmd_set_promisc_mode_parsed, 6264 .data = (void *)0, 6265 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id", 6266 .tokens = { 6267 (void *)&cmd_setpromisc_set, 6268 (void *)&cmd_setpromisc_promisc, 6269 (void *)&cmd_setpromisc_portnum, 6270 (void *)&cmd_setpromisc_mode, 6271 NULL, 6272 }, 6273 }; 6274 6275 /* *** SET ALLMULTI MODE *** */ 6276 struct cmd_set_allmulti_mode_result { 6277 cmdline_fixed_string_t set; 6278 cmdline_fixed_string_t allmulti; 6279 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6280 uint16_t port_num; /* valid if "allports" argument == 0 */ 6281 cmdline_fixed_string_t mode; 6282 }; 6283 6284 static void cmd_set_allmulti_mode_parsed(void *parsed_result, 6285 __attribute__((unused)) struct cmdline *cl, 6286 void *allports) 6287 { 6288 struct cmd_set_allmulti_mode_result *res = parsed_result; 6289 int enable; 6290 portid_t i; 6291 6292 if (!strcmp(res->mode, "on")) 6293 enable = 1; 6294 else 6295 enable = 0; 6296 6297 /* all ports */ 6298 if (allports) { 6299 RTE_ETH_FOREACH_DEV(i) { 6300 if (enable) 6301 rte_eth_allmulticast_enable(i); 6302 else 6303 rte_eth_allmulticast_disable(i); 6304 } 6305 } 6306 else { 6307 if (enable) 6308 rte_eth_allmulticast_enable(res->port_num); 6309 else 6310 rte_eth_allmulticast_disable(res->port_num); 6311 } 6312 } 6313 6314 cmdline_parse_token_string_t cmd_setallmulti_set = 6315 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set"); 6316 cmdline_parse_token_string_t cmd_setallmulti_allmulti = 6317 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti, 6318 "allmulti"); 6319 cmdline_parse_token_string_t cmd_setallmulti_portall = 6320 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all, 6321 "all"); 6322 cmdline_parse_token_num_t cmd_setallmulti_portnum = 6323 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num, 6324 UINT16); 6325 cmdline_parse_token_string_t cmd_setallmulti_mode = 6326 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode, 6327 "on#off"); 6328 6329 cmdline_parse_inst_t cmd_set_allmulti_mode_all = { 6330 .f = cmd_set_allmulti_mode_parsed, 6331 .data = (void *)1, 6332 .help_str = "set allmulti all on|off: Set allmulti mode for all ports", 6333 .tokens = { 6334 (void *)&cmd_setallmulti_set, 6335 (void *)&cmd_setallmulti_allmulti, 6336 (void *)&cmd_setallmulti_portall, 6337 (void *)&cmd_setallmulti_mode, 6338 NULL, 6339 }, 6340 }; 6341 6342 cmdline_parse_inst_t cmd_set_allmulti_mode_one = { 6343 .f = cmd_set_allmulti_mode_parsed, 6344 .data = (void *)0, 6345 .help_str = "set allmulti <port_id> on|off: " 6346 "Set allmulti mode on port_id", 6347 .tokens = { 6348 (void *)&cmd_setallmulti_set, 6349 (void *)&cmd_setallmulti_allmulti, 6350 (void *)&cmd_setallmulti_portnum, 6351 (void *)&cmd_setallmulti_mode, 6352 NULL, 6353 }, 6354 }; 6355 6356 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */ 6357 struct cmd_link_flow_ctrl_set_result { 6358 cmdline_fixed_string_t set; 6359 cmdline_fixed_string_t flow_ctrl; 6360 cmdline_fixed_string_t rx; 6361 cmdline_fixed_string_t rx_lfc_mode; 6362 cmdline_fixed_string_t tx; 6363 cmdline_fixed_string_t tx_lfc_mode; 6364 cmdline_fixed_string_t mac_ctrl_frame_fwd; 6365 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode; 6366 cmdline_fixed_string_t autoneg_str; 6367 cmdline_fixed_string_t autoneg; 6368 cmdline_fixed_string_t hw_str; 6369 uint32_t high_water; 6370 cmdline_fixed_string_t lw_str; 6371 uint32_t low_water; 6372 cmdline_fixed_string_t pt_str; 6373 uint16_t pause_time; 6374 cmdline_fixed_string_t xon_str; 6375 uint16_t send_xon; 6376 portid_t port_id; 6377 }; 6378 6379 cmdline_parse_token_string_t cmd_lfc_set_set = 6380 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6381 set, "set"); 6382 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl = 6383 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6384 flow_ctrl, "flow_ctrl"); 6385 cmdline_parse_token_string_t cmd_lfc_set_rx = 6386 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6387 rx, "rx"); 6388 cmdline_parse_token_string_t cmd_lfc_set_rx_mode = 6389 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6390 rx_lfc_mode, "on#off"); 6391 cmdline_parse_token_string_t cmd_lfc_set_tx = 6392 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6393 tx, "tx"); 6394 cmdline_parse_token_string_t cmd_lfc_set_tx_mode = 6395 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6396 tx_lfc_mode, "on#off"); 6397 cmdline_parse_token_string_t cmd_lfc_set_high_water_str = 6398 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6399 hw_str, "high_water"); 6400 cmdline_parse_token_num_t cmd_lfc_set_high_water = 6401 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6402 high_water, UINT32); 6403 cmdline_parse_token_string_t cmd_lfc_set_low_water_str = 6404 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6405 lw_str, "low_water"); 6406 cmdline_parse_token_num_t cmd_lfc_set_low_water = 6407 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6408 low_water, UINT32); 6409 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str = 6410 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6411 pt_str, "pause_time"); 6412 cmdline_parse_token_num_t cmd_lfc_set_pause_time = 6413 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6414 pause_time, UINT16); 6415 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str = 6416 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6417 xon_str, "send_xon"); 6418 cmdline_parse_token_num_t cmd_lfc_set_send_xon = 6419 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6420 send_xon, UINT16); 6421 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode = 6422 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6423 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd"); 6424 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd = 6425 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6426 mac_ctrl_frame_fwd_mode, "on#off"); 6427 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str = 6428 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6429 autoneg_str, "autoneg"); 6430 cmdline_parse_token_string_t cmd_lfc_set_autoneg = 6431 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6432 autoneg, "on#off"); 6433 cmdline_parse_token_num_t cmd_lfc_set_portid = 6434 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6435 port_id, UINT16); 6436 6437 /* forward declaration */ 6438 static void 6439 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl, 6440 void *data); 6441 6442 cmdline_parse_inst_t cmd_link_flow_control_set = { 6443 .f = cmd_link_flow_ctrl_set_parsed, 6444 .data = NULL, 6445 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> " 6446 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off " 6447 "autoneg on|off <port_id>: Configure the Ethernet flow control", 6448 .tokens = { 6449 (void *)&cmd_lfc_set_set, 6450 (void *)&cmd_lfc_set_flow_ctrl, 6451 (void *)&cmd_lfc_set_rx, 6452 (void *)&cmd_lfc_set_rx_mode, 6453 (void *)&cmd_lfc_set_tx, 6454 (void *)&cmd_lfc_set_tx_mode, 6455 (void *)&cmd_lfc_set_high_water, 6456 (void *)&cmd_lfc_set_low_water, 6457 (void *)&cmd_lfc_set_pause_time, 6458 (void *)&cmd_lfc_set_send_xon, 6459 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6460 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6461 (void *)&cmd_lfc_set_autoneg_str, 6462 (void *)&cmd_lfc_set_autoneg, 6463 (void *)&cmd_lfc_set_portid, 6464 NULL, 6465 }, 6466 }; 6467 6468 cmdline_parse_inst_t cmd_link_flow_control_set_rx = { 6469 .f = cmd_link_flow_ctrl_set_parsed, 6470 .data = (void *)&cmd_link_flow_control_set_rx, 6471 .help_str = "set flow_ctrl rx on|off <port_id>: " 6472 "Change rx flow control parameter", 6473 .tokens = { 6474 (void *)&cmd_lfc_set_set, 6475 (void *)&cmd_lfc_set_flow_ctrl, 6476 (void *)&cmd_lfc_set_rx, 6477 (void *)&cmd_lfc_set_rx_mode, 6478 (void *)&cmd_lfc_set_portid, 6479 NULL, 6480 }, 6481 }; 6482 6483 cmdline_parse_inst_t cmd_link_flow_control_set_tx = { 6484 .f = cmd_link_flow_ctrl_set_parsed, 6485 .data = (void *)&cmd_link_flow_control_set_tx, 6486 .help_str = "set flow_ctrl tx on|off <port_id>: " 6487 "Change tx flow control parameter", 6488 .tokens = { 6489 (void *)&cmd_lfc_set_set, 6490 (void *)&cmd_lfc_set_flow_ctrl, 6491 (void *)&cmd_lfc_set_tx, 6492 (void *)&cmd_lfc_set_tx_mode, 6493 (void *)&cmd_lfc_set_portid, 6494 NULL, 6495 }, 6496 }; 6497 6498 cmdline_parse_inst_t cmd_link_flow_control_set_hw = { 6499 .f = cmd_link_flow_ctrl_set_parsed, 6500 .data = (void *)&cmd_link_flow_control_set_hw, 6501 .help_str = "set flow_ctrl high_water <value> <port_id>: " 6502 "Change high water flow control parameter", 6503 .tokens = { 6504 (void *)&cmd_lfc_set_set, 6505 (void *)&cmd_lfc_set_flow_ctrl, 6506 (void *)&cmd_lfc_set_high_water_str, 6507 (void *)&cmd_lfc_set_high_water, 6508 (void *)&cmd_lfc_set_portid, 6509 NULL, 6510 }, 6511 }; 6512 6513 cmdline_parse_inst_t cmd_link_flow_control_set_lw = { 6514 .f = cmd_link_flow_ctrl_set_parsed, 6515 .data = (void *)&cmd_link_flow_control_set_lw, 6516 .help_str = "set flow_ctrl low_water <value> <port_id>: " 6517 "Change low water flow control parameter", 6518 .tokens = { 6519 (void *)&cmd_lfc_set_set, 6520 (void *)&cmd_lfc_set_flow_ctrl, 6521 (void *)&cmd_lfc_set_low_water_str, 6522 (void *)&cmd_lfc_set_low_water, 6523 (void *)&cmd_lfc_set_portid, 6524 NULL, 6525 }, 6526 }; 6527 6528 cmdline_parse_inst_t cmd_link_flow_control_set_pt = { 6529 .f = cmd_link_flow_ctrl_set_parsed, 6530 .data = (void *)&cmd_link_flow_control_set_pt, 6531 .help_str = "set flow_ctrl pause_time <value> <port_id>: " 6532 "Change pause time flow control parameter", 6533 .tokens = { 6534 (void *)&cmd_lfc_set_set, 6535 (void *)&cmd_lfc_set_flow_ctrl, 6536 (void *)&cmd_lfc_set_pause_time_str, 6537 (void *)&cmd_lfc_set_pause_time, 6538 (void *)&cmd_lfc_set_portid, 6539 NULL, 6540 }, 6541 }; 6542 6543 cmdline_parse_inst_t cmd_link_flow_control_set_xon = { 6544 .f = cmd_link_flow_ctrl_set_parsed, 6545 .data = (void *)&cmd_link_flow_control_set_xon, 6546 .help_str = "set flow_ctrl send_xon <value> <port_id>: " 6547 "Change send_xon flow control parameter", 6548 .tokens = { 6549 (void *)&cmd_lfc_set_set, 6550 (void *)&cmd_lfc_set_flow_ctrl, 6551 (void *)&cmd_lfc_set_send_xon_str, 6552 (void *)&cmd_lfc_set_send_xon, 6553 (void *)&cmd_lfc_set_portid, 6554 NULL, 6555 }, 6556 }; 6557 6558 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = { 6559 .f = cmd_link_flow_ctrl_set_parsed, 6560 .data = (void *)&cmd_link_flow_control_set_macfwd, 6561 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: " 6562 "Change mac ctrl fwd flow control parameter", 6563 .tokens = { 6564 (void *)&cmd_lfc_set_set, 6565 (void *)&cmd_lfc_set_flow_ctrl, 6566 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6567 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6568 (void *)&cmd_lfc_set_portid, 6569 NULL, 6570 }, 6571 }; 6572 6573 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = { 6574 .f = cmd_link_flow_ctrl_set_parsed, 6575 .data = (void *)&cmd_link_flow_control_set_autoneg, 6576 .help_str = "set flow_ctrl autoneg on|off <port_id>: " 6577 "Change autoneg flow control parameter", 6578 .tokens = { 6579 (void *)&cmd_lfc_set_set, 6580 (void *)&cmd_lfc_set_flow_ctrl, 6581 (void *)&cmd_lfc_set_autoneg_str, 6582 (void *)&cmd_lfc_set_autoneg, 6583 (void *)&cmd_lfc_set_portid, 6584 NULL, 6585 }, 6586 }; 6587 6588 static void 6589 cmd_link_flow_ctrl_set_parsed(void *parsed_result, 6590 __attribute__((unused)) struct cmdline *cl, 6591 void *data) 6592 { 6593 struct cmd_link_flow_ctrl_set_result *res = parsed_result; 6594 cmdline_parse_inst_t *cmd = data; 6595 struct rte_eth_fc_conf fc_conf; 6596 int rx_fc_en = 0; 6597 int tx_fc_en = 0; 6598 int ret; 6599 6600 /* 6601 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6602 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6603 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6604 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6605 */ 6606 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = { 6607 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 6608 }; 6609 6610 /* Partial command line, retrieve current configuration */ 6611 if (cmd) { 6612 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 6613 if (ret != 0) { 6614 printf("cannot get current flow ctrl parameters, return" 6615 "code = %d\n", ret); 6616 return; 6617 } 6618 6619 if ((fc_conf.mode == RTE_FC_RX_PAUSE) || 6620 (fc_conf.mode == RTE_FC_FULL)) 6621 rx_fc_en = 1; 6622 if ((fc_conf.mode == RTE_FC_TX_PAUSE) || 6623 (fc_conf.mode == RTE_FC_FULL)) 6624 tx_fc_en = 1; 6625 } 6626 6627 if (!cmd || cmd == &cmd_link_flow_control_set_rx) 6628 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0; 6629 6630 if (!cmd || cmd == &cmd_link_flow_control_set_tx) 6631 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0; 6632 6633 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en]; 6634 6635 if (!cmd || cmd == &cmd_link_flow_control_set_hw) 6636 fc_conf.high_water = res->high_water; 6637 6638 if (!cmd || cmd == &cmd_link_flow_control_set_lw) 6639 fc_conf.low_water = res->low_water; 6640 6641 if (!cmd || cmd == &cmd_link_flow_control_set_pt) 6642 fc_conf.pause_time = res->pause_time; 6643 6644 if (!cmd || cmd == &cmd_link_flow_control_set_xon) 6645 fc_conf.send_xon = res->send_xon; 6646 6647 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) { 6648 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) 6649 fc_conf.mac_ctrl_frame_fwd = 1; 6650 else 6651 fc_conf.mac_ctrl_frame_fwd = 0; 6652 } 6653 6654 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg) 6655 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0; 6656 6657 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf); 6658 if (ret != 0) 6659 printf("bad flow contrl parameter, return code = %d \n", ret); 6660 } 6661 6662 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */ 6663 struct cmd_priority_flow_ctrl_set_result { 6664 cmdline_fixed_string_t set; 6665 cmdline_fixed_string_t pfc_ctrl; 6666 cmdline_fixed_string_t rx; 6667 cmdline_fixed_string_t rx_pfc_mode; 6668 cmdline_fixed_string_t tx; 6669 cmdline_fixed_string_t tx_pfc_mode; 6670 uint32_t high_water; 6671 uint32_t low_water; 6672 uint16_t pause_time; 6673 uint8_t priority; 6674 portid_t port_id; 6675 }; 6676 6677 static void 6678 cmd_priority_flow_ctrl_set_parsed(void *parsed_result, 6679 __attribute__((unused)) struct cmdline *cl, 6680 __attribute__((unused)) void *data) 6681 { 6682 struct cmd_priority_flow_ctrl_set_result *res = parsed_result; 6683 struct rte_eth_pfc_conf pfc_conf; 6684 int rx_fc_enable, tx_fc_enable; 6685 int ret; 6686 6687 /* 6688 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6689 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6690 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6691 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6692 */ 6693 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = { 6694 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL} 6695 }; 6696 6697 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; 6698 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; 6699 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; 6700 pfc_conf.fc.high_water = res->high_water; 6701 pfc_conf.fc.low_water = res->low_water; 6702 pfc_conf.fc.pause_time = res->pause_time; 6703 pfc_conf.priority = res->priority; 6704 6705 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf); 6706 if (ret != 0) 6707 printf("bad priority flow contrl parameter, return code = %d \n", ret); 6708 } 6709 6710 cmdline_parse_token_string_t cmd_pfc_set_set = 6711 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6712 set, "set"); 6713 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl = 6714 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6715 pfc_ctrl, "pfc_ctrl"); 6716 cmdline_parse_token_string_t cmd_pfc_set_rx = 6717 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6718 rx, "rx"); 6719 cmdline_parse_token_string_t cmd_pfc_set_rx_mode = 6720 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6721 rx_pfc_mode, "on#off"); 6722 cmdline_parse_token_string_t cmd_pfc_set_tx = 6723 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6724 tx, "tx"); 6725 cmdline_parse_token_string_t cmd_pfc_set_tx_mode = 6726 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6727 tx_pfc_mode, "on#off"); 6728 cmdline_parse_token_num_t cmd_pfc_set_high_water = 6729 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6730 high_water, UINT32); 6731 cmdline_parse_token_num_t cmd_pfc_set_low_water = 6732 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6733 low_water, UINT32); 6734 cmdline_parse_token_num_t cmd_pfc_set_pause_time = 6735 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6736 pause_time, UINT16); 6737 cmdline_parse_token_num_t cmd_pfc_set_priority = 6738 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6739 priority, UINT8); 6740 cmdline_parse_token_num_t cmd_pfc_set_portid = 6741 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6742 port_id, UINT16); 6743 6744 cmdline_parse_inst_t cmd_priority_flow_control_set = { 6745 .f = cmd_priority_flow_ctrl_set_parsed, 6746 .data = NULL, 6747 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> " 6748 "<pause_time> <priority> <port_id>: " 6749 "Configure the Ethernet priority flow control", 6750 .tokens = { 6751 (void *)&cmd_pfc_set_set, 6752 (void *)&cmd_pfc_set_flow_ctrl, 6753 (void *)&cmd_pfc_set_rx, 6754 (void *)&cmd_pfc_set_rx_mode, 6755 (void *)&cmd_pfc_set_tx, 6756 (void *)&cmd_pfc_set_tx_mode, 6757 (void *)&cmd_pfc_set_high_water, 6758 (void *)&cmd_pfc_set_low_water, 6759 (void *)&cmd_pfc_set_pause_time, 6760 (void *)&cmd_pfc_set_priority, 6761 (void *)&cmd_pfc_set_portid, 6762 NULL, 6763 }, 6764 }; 6765 6766 /* *** RESET CONFIGURATION *** */ 6767 struct cmd_reset_result { 6768 cmdline_fixed_string_t reset; 6769 cmdline_fixed_string_t def; 6770 }; 6771 6772 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result, 6773 struct cmdline *cl, 6774 __attribute__((unused)) void *data) 6775 { 6776 cmdline_printf(cl, "Reset to default forwarding configuration...\n"); 6777 set_def_fwd_config(); 6778 } 6779 6780 cmdline_parse_token_string_t cmd_reset_set = 6781 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set"); 6782 cmdline_parse_token_string_t cmd_reset_def = 6783 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def, 6784 "default"); 6785 6786 cmdline_parse_inst_t cmd_reset = { 6787 .f = cmd_reset_parsed, 6788 .data = NULL, 6789 .help_str = "set default: Reset default forwarding configuration", 6790 .tokens = { 6791 (void *)&cmd_reset_set, 6792 (void *)&cmd_reset_def, 6793 NULL, 6794 }, 6795 }; 6796 6797 /* *** START FORWARDING *** */ 6798 struct cmd_start_result { 6799 cmdline_fixed_string_t start; 6800 }; 6801 6802 cmdline_parse_token_string_t cmd_start_start = 6803 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start"); 6804 6805 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result, 6806 __attribute__((unused)) struct cmdline *cl, 6807 __attribute__((unused)) void *data) 6808 { 6809 start_packet_forwarding(0); 6810 } 6811 6812 cmdline_parse_inst_t cmd_start = { 6813 .f = cmd_start_parsed, 6814 .data = NULL, 6815 .help_str = "start: Start packet forwarding", 6816 .tokens = { 6817 (void *)&cmd_start_start, 6818 NULL, 6819 }, 6820 }; 6821 6822 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */ 6823 struct cmd_start_tx_first_result { 6824 cmdline_fixed_string_t start; 6825 cmdline_fixed_string_t tx_first; 6826 }; 6827 6828 static void 6829 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result, 6830 __attribute__((unused)) struct cmdline *cl, 6831 __attribute__((unused)) void *data) 6832 { 6833 start_packet_forwarding(1); 6834 } 6835 6836 cmdline_parse_token_string_t cmd_start_tx_first_start = 6837 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start, 6838 "start"); 6839 cmdline_parse_token_string_t cmd_start_tx_first_tx_first = 6840 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, 6841 tx_first, "tx_first"); 6842 6843 cmdline_parse_inst_t cmd_start_tx_first = { 6844 .f = cmd_start_tx_first_parsed, 6845 .data = NULL, 6846 .help_str = "start tx_first: Start packet forwarding, " 6847 "after sending 1 burst of packets", 6848 .tokens = { 6849 (void *)&cmd_start_tx_first_start, 6850 (void *)&cmd_start_tx_first_tx_first, 6851 NULL, 6852 }, 6853 }; 6854 6855 /* *** START FORWARDING WITH N TX BURST FIRST *** */ 6856 struct cmd_start_tx_first_n_result { 6857 cmdline_fixed_string_t start; 6858 cmdline_fixed_string_t tx_first; 6859 uint32_t tx_num; 6860 }; 6861 6862 static void 6863 cmd_start_tx_first_n_parsed(void *parsed_result, 6864 __attribute__((unused)) struct cmdline *cl, 6865 __attribute__((unused)) void *data) 6866 { 6867 struct cmd_start_tx_first_n_result *res = parsed_result; 6868 6869 start_packet_forwarding(res->tx_num); 6870 } 6871 6872 cmdline_parse_token_string_t cmd_start_tx_first_n_start = 6873 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 6874 start, "start"); 6875 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first = 6876 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 6877 tx_first, "tx_first"); 6878 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num = 6879 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result, 6880 tx_num, UINT32); 6881 6882 cmdline_parse_inst_t cmd_start_tx_first_n = { 6883 .f = cmd_start_tx_first_n_parsed, 6884 .data = NULL, 6885 .help_str = "start tx_first <num>: " 6886 "packet forwarding, after sending <num> bursts of packets", 6887 .tokens = { 6888 (void *)&cmd_start_tx_first_n_start, 6889 (void *)&cmd_start_tx_first_n_tx_first, 6890 (void *)&cmd_start_tx_first_n_tx_num, 6891 NULL, 6892 }, 6893 }; 6894 6895 /* *** SET LINK UP *** */ 6896 struct cmd_set_link_up_result { 6897 cmdline_fixed_string_t set; 6898 cmdline_fixed_string_t link_up; 6899 cmdline_fixed_string_t port; 6900 portid_t port_id; 6901 }; 6902 6903 cmdline_parse_token_string_t cmd_set_link_up_set = 6904 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set"); 6905 cmdline_parse_token_string_t cmd_set_link_up_link_up = 6906 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up, 6907 "link-up"); 6908 cmdline_parse_token_string_t cmd_set_link_up_port = 6909 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port"); 6910 cmdline_parse_token_num_t cmd_set_link_up_port_id = 6911 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16); 6912 6913 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result, 6914 __attribute__((unused)) struct cmdline *cl, 6915 __attribute__((unused)) void *data) 6916 { 6917 struct cmd_set_link_up_result *res = parsed_result; 6918 dev_set_link_up(res->port_id); 6919 } 6920 6921 cmdline_parse_inst_t cmd_set_link_up = { 6922 .f = cmd_set_link_up_parsed, 6923 .data = NULL, 6924 .help_str = "set link-up port <port id>", 6925 .tokens = { 6926 (void *)&cmd_set_link_up_set, 6927 (void *)&cmd_set_link_up_link_up, 6928 (void *)&cmd_set_link_up_port, 6929 (void *)&cmd_set_link_up_port_id, 6930 NULL, 6931 }, 6932 }; 6933 6934 /* *** SET LINK DOWN *** */ 6935 struct cmd_set_link_down_result { 6936 cmdline_fixed_string_t set; 6937 cmdline_fixed_string_t link_down; 6938 cmdline_fixed_string_t port; 6939 portid_t port_id; 6940 }; 6941 6942 cmdline_parse_token_string_t cmd_set_link_down_set = 6943 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set"); 6944 cmdline_parse_token_string_t cmd_set_link_down_link_down = 6945 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down, 6946 "link-down"); 6947 cmdline_parse_token_string_t cmd_set_link_down_port = 6948 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port"); 6949 cmdline_parse_token_num_t cmd_set_link_down_port_id = 6950 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16); 6951 6952 static void cmd_set_link_down_parsed( 6953 __attribute__((unused)) void *parsed_result, 6954 __attribute__((unused)) struct cmdline *cl, 6955 __attribute__((unused)) void *data) 6956 { 6957 struct cmd_set_link_down_result *res = parsed_result; 6958 dev_set_link_down(res->port_id); 6959 } 6960 6961 cmdline_parse_inst_t cmd_set_link_down = { 6962 .f = cmd_set_link_down_parsed, 6963 .data = NULL, 6964 .help_str = "set link-down port <port id>", 6965 .tokens = { 6966 (void *)&cmd_set_link_down_set, 6967 (void *)&cmd_set_link_down_link_down, 6968 (void *)&cmd_set_link_down_port, 6969 (void *)&cmd_set_link_down_port_id, 6970 NULL, 6971 }, 6972 }; 6973 6974 /* *** SHOW CFG *** */ 6975 struct cmd_showcfg_result { 6976 cmdline_fixed_string_t show; 6977 cmdline_fixed_string_t cfg; 6978 cmdline_fixed_string_t what; 6979 }; 6980 6981 static void cmd_showcfg_parsed(void *parsed_result, 6982 __attribute__((unused)) struct cmdline *cl, 6983 __attribute__((unused)) void *data) 6984 { 6985 struct cmd_showcfg_result *res = parsed_result; 6986 if (!strcmp(res->what, "rxtx")) 6987 rxtx_config_display(); 6988 else if (!strcmp(res->what, "cores")) 6989 fwd_lcores_config_display(); 6990 else if (!strcmp(res->what, "fwd")) 6991 pkt_fwd_config_display(&cur_fwd_config); 6992 else if (!strcmp(res->what, "txpkts")) 6993 show_tx_pkt_segments(); 6994 } 6995 6996 cmdline_parse_token_string_t cmd_showcfg_show = 6997 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show"); 6998 cmdline_parse_token_string_t cmd_showcfg_port = 6999 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); 7000 cmdline_parse_token_string_t cmd_showcfg_what = 7001 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, 7002 "rxtx#cores#fwd#txpkts"); 7003 7004 cmdline_parse_inst_t cmd_showcfg = { 7005 .f = cmd_showcfg_parsed, 7006 .data = NULL, 7007 .help_str = "show config rxtx|cores|fwd|txpkts", 7008 .tokens = { 7009 (void *)&cmd_showcfg_show, 7010 (void *)&cmd_showcfg_port, 7011 (void *)&cmd_showcfg_what, 7012 NULL, 7013 }, 7014 }; 7015 7016 /* *** SHOW ALL PORT INFO *** */ 7017 struct cmd_showportall_result { 7018 cmdline_fixed_string_t show; 7019 cmdline_fixed_string_t port; 7020 cmdline_fixed_string_t what; 7021 cmdline_fixed_string_t all; 7022 }; 7023 7024 static void cmd_showportall_parsed(void *parsed_result, 7025 __attribute__((unused)) struct cmdline *cl, 7026 __attribute__((unused)) void *data) 7027 { 7028 portid_t i; 7029 7030 struct cmd_showportall_result *res = parsed_result; 7031 if (!strcmp(res->show, "clear")) { 7032 if (!strcmp(res->what, "stats")) 7033 RTE_ETH_FOREACH_DEV(i) 7034 nic_stats_clear(i); 7035 else if (!strcmp(res->what, "xstats")) 7036 RTE_ETH_FOREACH_DEV(i) 7037 nic_xstats_clear(i); 7038 } else if (!strcmp(res->what, "info")) 7039 RTE_ETH_FOREACH_DEV(i) 7040 port_infos_display(i); 7041 else if (!strcmp(res->what, "stats")) 7042 RTE_ETH_FOREACH_DEV(i) 7043 nic_stats_display(i); 7044 else if (!strcmp(res->what, "xstats")) 7045 RTE_ETH_FOREACH_DEV(i) 7046 nic_xstats_display(i); 7047 else if (!strcmp(res->what, "fdir")) 7048 RTE_ETH_FOREACH_DEV(i) 7049 fdir_get_infos(i); 7050 else if (!strcmp(res->what, "stat_qmap")) 7051 RTE_ETH_FOREACH_DEV(i) 7052 nic_stats_mapping_display(i); 7053 else if (!strcmp(res->what, "dcb_tc")) 7054 RTE_ETH_FOREACH_DEV(i) 7055 port_dcb_info_display(i); 7056 else if (!strcmp(res->what, "cap")) 7057 RTE_ETH_FOREACH_DEV(i) 7058 port_offload_cap_display(i); 7059 } 7060 7061 cmdline_parse_token_string_t cmd_showportall_show = 7062 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show, 7063 "show#clear"); 7064 cmdline_parse_token_string_t cmd_showportall_port = 7065 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); 7066 cmdline_parse_token_string_t cmd_showportall_what = 7067 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, 7068 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7069 cmdline_parse_token_string_t cmd_showportall_all = 7070 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); 7071 cmdline_parse_inst_t cmd_showportall = { 7072 .f = cmd_showportall_parsed, 7073 .data = NULL, 7074 .help_str = "show|clear port " 7075 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all", 7076 .tokens = { 7077 (void *)&cmd_showportall_show, 7078 (void *)&cmd_showportall_port, 7079 (void *)&cmd_showportall_what, 7080 (void *)&cmd_showportall_all, 7081 NULL, 7082 }, 7083 }; 7084 7085 /* *** SHOW PORT INFO *** */ 7086 struct cmd_showport_result { 7087 cmdline_fixed_string_t show; 7088 cmdline_fixed_string_t port; 7089 cmdline_fixed_string_t what; 7090 uint16_t portnum; 7091 }; 7092 7093 static void cmd_showport_parsed(void *parsed_result, 7094 __attribute__((unused)) struct cmdline *cl, 7095 __attribute__((unused)) void *data) 7096 { 7097 struct cmd_showport_result *res = parsed_result; 7098 if (!strcmp(res->show, "clear")) { 7099 if (!strcmp(res->what, "stats")) 7100 nic_stats_clear(res->portnum); 7101 else if (!strcmp(res->what, "xstats")) 7102 nic_xstats_clear(res->portnum); 7103 } else if (!strcmp(res->what, "info")) 7104 port_infos_display(res->portnum); 7105 else if (!strcmp(res->what, "stats")) 7106 nic_stats_display(res->portnum); 7107 else if (!strcmp(res->what, "xstats")) 7108 nic_xstats_display(res->portnum); 7109 else if (!strcmp(res->what, "fdir")) 7110 fdir_get_infos(res->portnum); 7111 else if (!strcmp(res->what, "stat_qmap")) 7112 nic_stats_mapping_display(res->portnum); 7113 else if (!strcmp(res->what, "dcb_tc")) 7114 port_dcb_info_display(res->portnum); 7115 else if (!strcmp(res->what, "cap")) 7116 port_offload_cap_display(res->portnum); 7117 } 7118 7119 cmdline_parse_token_string_t cmd_showport_show = 7120 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show, 7121 "show#clear"); 7122 cmdline_parse_token_string_t cmd_showport_port = 7123 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); 7124 cmdline_parse_token_string_t cmd_showport_what = 7125 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, 7126 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7127 cmdline_parse_token_num_t cmd_showport_portnum = 7128 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16); 7129 7130 cmdline_parse_inst_t cmd_showport = { 7131 .f = cmd_showport_parsed, 7132 .data = NULL, 7133 .help_str = "show|clear port " 7134 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap " 7135 "<port_id>", 7136 .tokens = { 7137 (void *)&cmd_showport_show, 7138 (void *)&cmd_showport_port, 7139 (void *)&cmd_showport_what, 7140 (void *)&cmd_showport_portnum, 7141 NULL, 7142 }, 7143 }; 7144 7145 /* *** SHOW QUEUE INFO *** */ 7146 struct cmd_showqueue_result { 7147 cmdline_fixed_string_t show; 7148 cmdline_fixed_string_t type; 7149 cmdline_fixed_string_t what; 7150 uint16_t portnum; 7151 uint16_t queuenum; 7152 }; 7153 7154 static void 7155 cmd_showqueue_parsed(void *parsed_result, 7156 __attribute__((unused)) struct cmdline *cl, 7157 __attribute__((unused)) void *data) 7158 { 7159 struct cmd_showqueue_result *res = parsed_result; 7160 7161 if (!strcmp(res->type, "rxq")) 7162 rx_queue_infos_display(res->portnum, res->queuenum); 7163 else if (!strcmp(res->type, "txq")) 7164 tx_queue_infos_display(res->portnum, res->queuenum); 7165 } 7166 7167 cmdline_parse_token_string_t cmd_showqueue_show = 7168 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show"); 7169 cmdline_parse_token_string_t cmd_showqueue_type = 7170 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq"); 7171 cmdline_parse_token_string_t cmd_showqueue_what = 7172 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info"); 7173 cmdline_parse_token_num_t cmd_showqueue_portnum = 7174 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16); 7175 cmdline_parse_token_num_t cmd_showqueue_queuenum = 7176 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16); 7177 7178 cmdline_parse_inst_t cmd_showqueue = { 7179 .f = cmd_showqueue_parsed, 7180 .data = NULL, 7181 .help_str = "show rxq|txq info <port_id> <queue_id>", 7182 .tokens = { 7183 (void *)&cmd_showqueue_show, 7184 (void *)&cmd_showqueue_type, 7185 (void *)&cmd_showqueue_what, 7186 (void *)&cmd_showqueue_portnum, 7187 (void *)&cmd_showqueue_queuenum, 7188 NULL, 7189 }, 7190 }; 7191 7192 /* *** READ PORT REGISTER *** */ 7193 struct cmd_read_reg_result { 7194 cmdline_fixed_string_t read; 7195 cmdline_fixed_string_t reg; 7196 portid_t port_id; 7197 uint32_t reg_off; 7198 }; 7199 7200 static void 7201 cmd_read_reg_parsed(void *parsed_result, 7202 __attribute__((unused)) struct cmdline *cl, 7203 __attribute__((unused)) void *data) 7204 { 7205 struct cmd_read_reg_result *res = parsed_result; 7206 port_reg_display(res->port_id, res->reg_off); 7207 } 7208 7209 cmdline_parse_token_string_t cmd_read_reg_read = 7210 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read"); 7211 cmdline_parse_token_string_t cmd_read_reg_reg = 7212 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg"); 7213 cmdline_parse_token_num_t cmd_read_reg_port_id = 7214 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16); 7215 cmdline_parse_token_num_t cmd_read_reg_reg_off = 7216 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32); 7217 7218 cmdline_parse_inst_t cmd_read_reg = { 7219 .f = cmd_read_reg_parsed, 7220 .data = NULL, 7221 .help_str = "read reg <port_id> <reg_off>", 7222 .tokens = { 7223 (void *)&cmd_read_reg_read, 7224 (void *)&cmd_read_reg_reg, 7225 (void *)&cmd_read_reg_port_id, 7226 (void *)&cmd_read_reg_reg_off, 7227 NULL, 7228 }, 7229 }; 7230 7231 /* *** READ PORT REGISTER BIT FIELD *** */ 7232 struct cmd_read_reg_bit_field_result { 7233 cmdline_fixed_string_t read; 7234 cmdline_fixed_string_t regfield; 7235 portid_t port_id; 7236 uint32_t reg_off; 7237 uint8_t bit1_pos; 7238 uint8_t bit2_pos; 7239 }; 7240 7241 static void 7242 cmd_read_reg_bit_field_parsed(void *parsed_result, 7243 __attribute__((unused)) struct cmdline *cl, 7244 __attribute__((unused)) void *data) 7245 { 7246 struct cmd_read_reg_bit_field_result *res = parsed_result; 7247 port_reg_bit_field_display(res->port_id, res->reg_off, 7248 res->bit1_pos, res->bit2_pos); 7249 } 7250 7251 cmdline_parse_token_string_t cmd_read_reg_bit_field_read = 7252 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read, 7253 "read"); 7254 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield = 7255 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, 7256 regfield, "regfield"); 7257 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id = 7258 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id, 7259 UINT16); 7260 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off = 7261 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off, 7262 UINT32); 7263 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos = 7264 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos, 7265 UINT8); 7266 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos = 7267 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos, 7268 UINT8); 7269 7270 cmdline_parse_inst_t cmd_read_reg_bit_field = { 7271 .f = cmd_read_reg_bit_field_parsed, 7272 .data = NULL, 7273 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: " 7274 "Read register bit field between bit_x and bit_y included", 7275 .tokens = { 7276 (void *)&cmd_read_reg_bit_field_read, 7277 (void *)&cmd_read_reg_bit_field_regfield, 7278 (void *)&cmd_read_reg_bit_field_port_id, 7279 (void *)&cmd_read_reg_bit_field_reg_off, 7280 (void *)&cmd_read_reg_bit_field_bit1_pos, 7281 (void *)&cmd_read_reg_bit_field_bit2_pos, 7282 NULL, 7283 }, 7284 }; 7285 7286 /* *** READ PORT REGISTER BIT *** */ 7287 struct cmd_read_reg_bit_result { 7288 cmdline_fixed_string_t read; 7289 cmdline_fixed_string_t regbit; 7290 portid_t port_id; 7291 uint32_t reg_off; 7292 uint8_t bit_pos; 7293 }; 7294 7295 static void 7296 cmd_read_reg_bit_parsed(void *parsed_result, 7297 __attribute__((unused)) struct cmdline *cl, 7298 __attribute__((unused)) void *data) 7299 { 7300 struct cmd_read_reg_bit_result *res = parsed_result; 7301 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos); 7302 } 7303 7304 cmdline_parse_token_string_t cmd_read_reg_bit_read = 7305 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read"); 7306 cmdline_parse_token_string_t cmd_read_reg_bit_regbit = 7307 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, 7308 regbit, "regbit"); 7309 cmdline_parse_token_num_t cmd_read_reg_bit_port_id = 7310 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16); 7311 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off = 7312 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32); 7313 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos = 7314 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8); 7315 7316 cmdline_parse_inst_t cmd_read_reg_bit = { 7317 .f = cmd_read_reg_bit_parsed, 7318 .data = NULL, 7319 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31", 7320 .tokens = { 7321 (void *)&cmd_read_reg_bit_read, 7322 (void *)&cmd_read_reg_bit_regbit, 7323 (void *)&cmd_read_reg_bit_port_id, 7324 (void *)&cmd_read_reg_bit_reg_off, 7325 (void *)&cmd_read_reg_bit_bit_pos, 7326 NULL, 7327 }, 7328 }; 7329 7330 /* *** WRITE PORT REGISTER *** */ 7331 struct cmd_write_reg_result { 7332 cmdline_fixed_string_t write; 7333 cmdline_fixed_string_t reg; 7334 portid_t port_id; 7335 uint32_t reg_off; 7336 uint32_t value; 7337 }; 7338 7339 static void 7340 cmd_write_reg_parsed(void *parsed_result, 7341 __attribute__((unused)) struct cmdline *cl, 7342 __attribute__((unused)) void *data) 7343 { 7344 struct cmd_write_reg_result *res = parsed_result; 7345 port_reg_set(res->port_id, res->reg_off, res->value); 7346 } 7347 7348 cmdline_parse_token_string_t cmd_write_reg_write = 7349 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write"); 7350 cmdline_parse_token_string_t cmd_write_reg_reg = 7351 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg"); 7352 cmdline_parse_token_num_t cmd_write_reg_port_id = 7353 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16); 7354 cmdline_parse_token_num_t cmd_write_reg_reg_off = 7355 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32); 7356 cmdline_parse_token_num_t cmd_write_reg_value = 7357 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32); 7358 7359 cmdline_parse_inst_t cmd_write_reg = { 7360 .f = cmd_write_reg_parsed, 7361 .data = NULL, 7362 .help_str = "write reg <port_id> <reg_off> <reg_value>", 7363 .tokens = { 7364 (void *)&cmd_write_reg_write, 7365 (void *)&cmd_write_reg_reg, 7366 (void *)&cmd_write_reg_port_id, 7367 (void *)&cmd_write_reg_reg_off, 7368 (void *)&cmd_write_reg_value, 7369 NULL, 7370 }, 7371 }; 7372 7373 /* *** WRITE PORT REGISTER BIT FIELD *** */ 7374 struct cmd_write_reg_bit_field_result { 7375 cmdline_fixed_string_t write; 7376 cmdline_fixed_string_t regfield; 7377 portid_t port_id; 7378 uint32_t reg_off; 7379 uint8_t bit1_pos; 7380 uint8_t bit2_pos; 7381 uint32_t value; 7382 }; 7383 7384 static void 7385 cmd_write_reg_bit_field_parsed(void *parsed_result, 7386 __attribute__((unused)) struct cmdline *cl, 7387 __attribute__((unused)) void *data) 7388 { 7389 struct cmd_write_reg_bit_field_result *res = parsed_result; 7390 port_reg_bit_field_set(res->port_id, res->reg_off, 7391 res->bit1_pos, res->bit2_pos, res->value); 7392 } 7393 7394 cmdline_parse_token_string_t cmd_write_reg_bit_field_write = 7395 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write, 7396 "write"); 7397 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield = 7398 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, 7399 regfield, "regfield"); 7400 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id = 7401 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id, 7402 UINT16); 7403 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off = 7404 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off, 7405 UINT32); 7406 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos = 7407 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos, 7408 UINT8); 7409 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos = 7410 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos, 7411 UINT8); 7412 cmdline_parse_token_num_t cmd_write_reg_bit_field_value = 7413 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value, 7414 UINT32); 7415 7416 cmdline_parse_inst_t cmd_write_reg_bit_field = { 7417 .f = cmd_write_reg_bit_field_parsed, 7418 .data = NULL, 7419 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> " 7420 "<reg_value>: " 7421 "Set register bit field between bit_x and bit_y included", 7422 .tokens = { 7423 (void *)&cmd_write_reg_bit_field_write, 7424 (void *)&cmd_write_reg_bit_field_regfield, 7425 (void *)&cmd_write_reg_bit_field_port_id, 7426 (void *)&cmd_write_reg_bit_field_reg_off, 7427 (void *)&cmd_write_reg_bit_field_bit1_pos, 7428 (void *)&cmd_write_reg_bit_field_bit2_pos, 7429 (void *)&cmd_write_reg_bit_field_value, 7430 NULL, 7431 }, 7432 }; 7433 7434 /* *** WRITE PORT REGISTER BIT *** */ 7435 struct cmd_write_reg_bit_result { 7436 cmdline_fixed_string_t write; 7437 cmdline_fixed_string_t regbit; 7438 portid_t port_id; 7439 uint32_t reg_off; 7440 uint8_t bit_pos; 7441 uint8_t value; 7442 }; 7443 7444 static void 7445 cmd_write_reg_bit_parsed(void *parsed_result, 7446 __attribute__((unused)) struct cmdline *cl, 7447 __attribute__((unused)) void *data) 7448 { 7449 struct cmd_write_reg_bit_result *res = parsed_result; 7450 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value); 7451 } 7452 7453 cmdline_parse_token_string_t cmd_write_reg_bit_write = 7454 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write, 7455 "write"); 7456 cmdline_parse_token_string_t cmd_write_reg_bit_regbit = 7457 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, 7458 regbit, "regbit"); 7459 cmdline_parse_token_num_t cmd_write_reg_bit_port_id = 7460 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16); 7461 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off = 7462 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32); 7463 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos = 7464 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8); 7465 cmdline_parse_token_num_t cmd_write_reg_bit_value = 7466 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8); 7467 7468 cmdline_parse_inst_t cmd_write_reg_bit = { 7469 .f = cmd_write_reg_bit_parsed, 7470 .data = NULL, 7471 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: " 7472 "0 <= bit_x <= 31", 7473 .tokens = { 7474 (void *)&cmd_write_reg_bit_write, 7475 (void *)&cmd_write_reg_bit_regbit, 7476 (void *)&cmd_write_reg_bit_port_id, 7477 (void *)&cmd_write_reg_bit_reg_off, 7478 (void *)&cmd_write_reg_bit_bit_pos, 7479 (void *)&cmd_write_reg_bit_value, 7480 NULL, 7481 }, 7482 }; 7483 7484 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */ 7485 struct cmd_read_rxd_txd_result { 7486 cmdline_fixed_string_t read; 7487 cmdline_fixed_string_t rxd_txd; 7488 portid_t port_id; 7489 uint16_t queue_id; 7490 uint16_t desc_id; 7491 }; 7492 7493 static void 7494 cmd_read_rxd_txd_parsed(void *parsed_result, 7495 __attribute__((unused)) struct cmdline *cl, 7496 __attribute__((unused)) void *data) 7497 { 7498 struct cmd_read_rxd_txd_result *res = parsed_result; 7499 7500 if (!strcmp(res->rxd_txd, "rxd")) 7501 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7502 else if (!strcmp(res->rxd_txd, "txd")) 7503 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7504 } 7505 7506 cmdline_parse_token_string_t cmd_read_rxd_txd_read = 7507 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read"); 7508 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd = 7509 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd, 7510 "rxd#txd"); 7511 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id = 7512 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16); 7513 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id = 7514 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16); 7515 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id = 7516 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16); 7517 7518 cmdline_parse_inst_t cmd_read_rxd_txd = { 7519 .f = cmd_read_rxd_txd_parsed, 7520 .data = NULL, 7521 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>", 7522 .tokens = { 7523 (void *)&cmd_read_rxd_txd_read, 7524 (void *)&cmd_read_rxd_txd_rxd_txd, 7525 (void *)&cmd_read_rxd_txd_port_id, 7526 (void *)&cmd_read_rxd_txd_queue_id, 7527 (void *)&cmd_read_rxd_txd_desc_id, 7528 NULL, 7529 }, 7530 }; 7531 7532 /* *** QUIT *** */ 7533 struct cmd_quit_result { 7534 cmdline_fixed_string_t quit; 7535 }; 7536 7537 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result, 7538 struct cmdline *cl, 7539 __attribute__((unused)) void *data) 7540 { 7541 pmd_test_exit(); 7542 cmdline_quit(cl); 7543 } 7544 7545 cmdline_parse_token_string_t cmd_quit_quit = 7546 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit"); 7547 7548 cmdline_parse_inst_t cmd_quit = { 7549 .f = cmd_quit_parsed, 7550 .data = NULL, 7551 .help_str = "quit: Exit application", 7552 .tokens = { 7553 (void *)&cmd_quit_quit, 7554 NULL, 7555 }, 7556 }; 7557 7558 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */ 7559 struct cmd_mac_addr_result { 7560 cmdline_fixed_string_t mac_addr_cmd; 7561 cmdline_fixed_string_t what; 7562 uint16_t port_num; 7563 struct ether_addr address; 7564 }; 7565 7566 static void cmd_mac_addr_parsed(void *parsed_result, 7567 __attribute__((unused)) struct cmdline *cl, 7568 __attribute__((unused)) void *data) 7569 { 7570 struct cmd_mac_addr_result *res = parsed_result; 7571 int ret; 7572 7573 if (strcmp(res->what, "add") == 0) 7574 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0); 7575 else if (strcmp(res->what, "set") == 0) 7576 ret = rte_eth_dev_default_mac_addr_set(res->port_num, 7577 &res->address); 7578 else 7579 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address); 7580 7581 /* check the return value and print it if is < 0 */ 7582 if(ret < 0) 7583 printf("mac_addr_cmd error: (%s)\n", strerror(-ret)); 7584 7585 } 7586 7587 cmdline_parse_token_string_t cmd_mac_addr_cmd = 7588 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd, 7589 "mac_addr"); 7590 cmdline_parse_token_string_t cmd_mac_addr_what = 7591 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what, 7592 "add#remove#set"); 7593 cmdline_parse_token_num_t cmd_mac_addr_portnum = 7594 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, 7595 UINT16); 7596 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr = 7597 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 7598 7599 cmdline_parse_inst_t cmd_mac_addr = { 7600 .f = cmd_mac_addr_parsed, 7601 .data = (void *)0, 7602 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: " 7603 "Add/Remove/Set MAC address on port_id", 7604 .tokens = { 7605 (void *)&cmd_mac_addr_cmd, 7606 (void *)&cmd_mac_addr_what, 7607 (void *)&cmd_mac_addr_portnum, 7608 (void *)&cmd_mac_addr_addr, 7609 NULL, 7610 }, 7611 }; 7612 7613 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */ 7614 struct cmd_eth_peer_result { 7615 cmdline_fixed_string_t set; 7616 cmdline_fixed_string_t eth_peer; 7617 portid_t port_id; 7618 cmdline_fixed_string_t peer_addr; 7619 }; 7620 7621 static void cmd_set_eth_peer_parsed(void *parsed_result, 7622 __attribute__((unused)) struct cmdline *cl, 7623 __attribute__((unused)) void *data) 7624 { 7625 struct cmd_eth_peer_result *res = parsed_result; 7626 7627 if (test_done == 0) { 7628 printf("Please stop forwarding first\n"); 7629 return; 7630 } 7631 if (!strcmp(res->eth_peer, "eth-peer")) { 7632 set_fwd_eth_peer(res->port_id, res->peer_addr); 7633 fwd_config_setup(); 7634 } 7635 } 7636 cmdline_parse_token_string_t cmd_eth_peer_set = 7637 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set"); 7638 cmdline_parse_token_string_t cmd_eth_peer = 7639 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer"); 7640 cmdline_parse_token_num_t cmd_eth_peer_port_id = 7641 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16); 7642 cmdline_parse_token_string_t cmd_eth_peer_addr = 7643 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL); 7644 7645 cmdline_parse_inst_t cmd_set_fwd_eth_peer = { 7646 .f = cmd_set_eth_peer_parsed, 7647 .data = NULL, 7648 .help_str = "set eth-peer <port_id> <peer_mac>", 7649 .tokens = { 7650 (void *)&cmd_eth_peer_set, 7651 (void *)&cmd_eth_peer, 7652 (void *)&cmd_eth_peer_port_id, 7653 (void *)&cmd_eth_peer_addr, 7654 NULL, 7655 }, 7656 }; 7657 7658 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ 7659 struct cmd_set_qmap_result { 7660 cmdline_fixed_string_t set; 7661 cmdline_fixed_string_t qmap; 7662 cmdline_fixed_string_t what; 7663 portid_t port_id; 7664 uint16_t queue_id; 7665 uint8_t map_value; 7666 }; 7667 7668 static void 7669 cmd_set_qmap_parsed(void *parsed_result, 7670 __attribute__((unused)) struct cmdline *cl, 7671 __attribute__((unused)) void *data) 7672 { 7673 struct cmd_set_qmap_result *res = parsed_result; 7674 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1; 7675 7676 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value); 7677 } 7678 7679 cmdline_parse_token_string_t cmd_setqmap_set = 7680 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7681 set, "set"); 7682 cmdline_parse_token_string_t cmd_setqmap_qmap = 7683 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7684 qmap, "stat_qmap"); 7685 cmdline_parse_token_string_t cmd_setqmap_what = 7686 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7687 what, "tx#rx"); 7688 cmdline_parse_token_num_t cmd_setqmap_portid = 7689 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7690 port_id, UINT16); 7691 cmdline_parse_token_num_t cmd_setqmap_queueid = 7692 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7693 queue_id, UINT16); 7694 cmdline_parse_token_num_t cmd_setqmap_mapvalue = 7695 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7696 map_value, UINT8); 7697 7698 cmdline_parse_inst_t cmd_set_qmap = { 7699 .f = cmd_set_qmap_parsed, 7700 .data = NULL, 7701 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: " 7702 "Set statistics mapping value on tx|rx queue_id of port_id", 7703 .tokens = { 7704 (void *)&cmd_setqmap_set, 7705 (void *)&cmd_setqmap_qmap, 7706 (void *)&cmd_setqmap_what, 7707 (void *)&cmd_setqmap_portid, 7708 (void *)&cmd_setqmap_queueid, 7709 (void *)&cmd_setqmap_mapvalue, 7710 NULL, 7711 }, 7712 }; 7713 7714 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */ 7715 struct cmd_set_xstats_hide_zero_result { 7716 cmdline_fixed_string_t keyword; 7717 cmdline_fixed_string_t name; 7718 cmdline_fixed_string_t on_off; 7719 }; 7720 7721 static void 7722 cmd_set_xstats_hide_zero_parsed(void *parsed_result, 7723 __attribute__((unused)) struct cmdline *cl, 7724 __attribute__((unused)) void *data) 7725 { 7726 struct cmd_set_xstats_hide_zero_result *res; 7727 uint16_t on_off = 0; 7728 7729 res = parsed_result; 7730 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 7731 set_xstats_hide_zero(on_off); 7732 } 7733 7734 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword = 7735 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 7736 keyword, "set"); 7737 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name = 7738 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 7739 name, "xstats-hide-zero"); 7740 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off = 7741 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 7742 on_off, "on#off"); 7743 7744 cmdline_parse_inst_t cmd_set_xstats_hide_zero = { 7745 .f = cmd_set_xstats_hide_zero_parsed, 7746 .data = NULL, 7747 .help_str = "set xstats-hide-zero on|off", 7748 .tokens = { 7749 (void *)&cmd_set_xstats_hide_zero_keyword, 7750 (void *)&cmd_set_xstats_hide_zero_name, 7751 (void *)&cmd_set_xstats_hide_zero_on_off, 7752 NULL, 7753 }, 7754 }; 7755 7756 /* *** CONFIGURE UNICAST HASH TABLE *** */ 7757 struct cmd_set_uc_hash_table { 7758 cmdline_fixed_string_t set; 7759 cmdline_fixed_string_t port; 7760 portid_t port_id; 7761 cmdline_fixed_string_t what; 7762 struct ether_addr address; 7763 cmdline_fixed_string_t mode; 7764 }; 7765 7766 static void 7767 cmd_set_uc_hash_parsed(void *parsed_result, 7768 __attribute__((unused)) struct cmdline *cl, 7769 __attribute__((unused)) void *data) 7770 { 7771 int ret=0; 7772 struct cmd_set_uc_hash_table *res = parsed_result; 7773 7774 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 7775 7776 if (strcmp(res->what, "uta") == 0) 7777 ret = rte_eth_dev_uc_hash_table_set(res->port_id, 7778 &res->address,(uint8_t)is_on); 7779 if (ret < 0) 7780 printf("bad unicast hash table parameter, return code = %d \n", ret); 7781 7782 } 7783 7784 cmdline_parse_token_string_t cmd_set_uc_hash_set = 7785 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 7786 set, "set"); 7787 cmdline_parse_token_string_t cmd_set_uc_hash_port = 7788 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 7789 port, "port"); 7790 cmdline_parse_token_num_t cmd_set_uc_hash_portid = 7791 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table, 7792 port_id, UINT16); 7793 cmdline_parse_token_string_t cmd_set_uc_hash_what = 7794 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 7795 what, "uta"); 7796 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac = 7797 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table, 7798 address); 7799 cmdline_parse_token_string_t cmd_set_uc_hash_mode = 7800 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 7801 mode, "on#off"); 7802 7803 cmdline_parse_inst_t cmd_set_uc_hash_filter = { 7804 .f = cmd_set_uc_hash_parsed, 7805 .data = NULL, 7806 .help_str = "set port <port_id> uta <mac_addr> on|off)", 7807 .tokens = { 7808 (void *)&cmd_set_uc_hash_set, 7809 (void *)&cmd_set_uc_hash_port, 7810 (void *)&cmd_set_uc_hash_portid, 7811 (void *)&cmd_set_uc_hash_what, 7812 (void *)&cmd_set_uc_hash_mac, 7813 (void *)&cmd_set_uc_hash_mode, 7814 NULL, 7815 }, 7816 }; 7817 7818 struct cmd_set_uc_all_hash_table { 7819 cmdline_fixed_string_t set; 7820 cmdline_fixed_string_t port; 7821 portid_t port_id; 7822 cmdline_fixed_string_t what; 7823 cmdline_fixed_string_t value; 7824 cmdline_fixed_string_t mode; 7825 }; 7826 7827 static void 7828 cmd_set_uc_all_hash_parsed(void *parsed_result, 7829 __attribute__((unused)) struct cmdline *cl, 7830 __attribute__((unused)) void *data) 7831 { 7832 int ret=0; 7833 struct cmd_set_uc_all_hash_table *res = parsed_result; 7834 7835 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 7836 7837 if ((strcmp(res->what, "uta") == 0) && 7838 (strcmp(res->value, "all") == 0)) 7839 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on); 7840 if (ret < 0) 7841 printf("bad unicast hash table parameter," 7842 "return code = %d \n", ret); 7843 } 7844 7845 cmdline_parse_token_string_t cmd_set_uc_all_hash_set = 7846 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7847 set, "set"); 7848 cmdline_parse_token_string_t cmd_set_uc_all_hash_port = 7849 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7850 port, "port"); 7851 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid = 7852 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table, 7853 port_id, UINT16); 7854 cmdline_parse_token_string_t cmd_set_uc_all_hash_what = 7855 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7856 what, "uta"); 7857 cmdline_parse_token_string_t cmd_set_uc_all_hash_value = 7858 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7859 value,"all"); 7860 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode = 7861 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7862 mode, "on#off"); 7863 7864 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = { 7865 .f = cmd_set_uc_all_hash_parsed, 7866 .data = NULL, 7867 .help_str = "set port <port_id> uta all on|off", 7868 .tokens = { 7869 (void *)&cmd_set_uc_all_hash_set, 7870 (void *)&cmd_set_uc_all_hash_port, 7871 (void *)&cmd_set_uc_all_hash_portid, 7872 (void *)&cmd_set_uc_all_hash_what, 7873 (void *)&cmd_set_uc_all_hash_value, 7874 (void *)&cmd_set_uc_all_hash_mode, 7875 NULL, 7876 }, 7877 }; 7878 7879 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */ 7880 struct cmd_set_vf_macvlan_filter { 7881 cmdline_fixed_string_t set; 7882 cmdline_fixed_string_t port; 7883 portid_t port_id; 7884 cmdline_fixed_string_t vf; 7885 uint8_t vf_id; 7886 struct ether_addr address; 7887 cmdline_fixed_string_t filter_type; 7888 cmdline_fixed_string_t mode; 7889 }; 7890 7891 static void 7892 cmd_set_vf_macvlan_parsed(void *parsed_result, 7893 __attribute__((unused)) struct cmdline *cl, 7894 __attribute__((unused)) void *data) 7895 { 7896 int is_on, ret = 0; 7897 struct cmd_set_vf_macvlan_filter *res = parsed_result; 7898 struct rte_eth_mac_filter filter; 7899 7900 memset(&filter, 0, sizeof(struct rte_eth_mac_filter)); 7901 7902 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN); 7903 7904 /* set VF MAC filter */ 7905 filter.is_vf = 1; 7906 7907 /* set VF ID */ 7908 filter.dst_id = res->vf_id; 7909 7910 if (!strcmp(res->filter_type, "exact-mac")) 7911 filter.filter_type = RTE_MAC_PERFECT_MATCH; 7912 else if (!strcmp(res->filter_type, "exact-mac-vlan")) 7913 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH; 7914 else if (!strcmp(res->filter_type, "hashmac")) 7915 filter.filter_type = RTE_MAC_HASH_MATCH; 7916 else if (!strcmp(res->filter_type, "hashmac-vlan")) 7917 filter.filter_type = RTE_MACVLAN_HASH_MATCH; 7918 7919 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 7920 7921 if (is_on) 7922 ret = rte_eth_dev_filter_ctrl(res->port_id, 7923 RTE_ETH_FILTER_MACVLAN, 7924 RTE_ETH_FILTER_ADD, 7925 &filter); 7926 else 7927 ret = rte_eth_dev_filter_ctrl(res->port_id, 7928 RTE_ETH_FILTER_MACVLAN, 7929 RTE_ETH_FILTER_DELETE, 7930 &filter); 7931 7932 if (ret < 0) 7933 printf("bad set MAC hash parameter, return code = %d\n", ret); 7934 7935 } 7936 7937 cmdline_parse_token_string_t cmd_set_vf_macvlan_set = 7938 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7939 set, "set"); 7940 cmdline_parse_token_string_t cmd_set_vf_macvlan_port = 7941 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7942 port, "port"); 7943 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid = 7944 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7945 port_id, UINT16); 7946 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf = 7947 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7948 vf, "vf"); 7949 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id = 7950 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7951 vf_id, UINT8); 7952 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac = 7953 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7954 address); 7955 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type = 7956 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7957 filter_type, "exact-mac#exact-mac-vlan" 7958 "#hashmac#hashmac-vlan"); 7959 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode = 7960 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 7961 mode, "on#off"); 7962 7963 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = { 7964 .f = cmd_set_vf_macvlan_parsed, 7965 .data = NULL, 7966 .help_str = "set port <port_id> vf <vf_id> <mac_addr> " 7967 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: " 7968 "Exact match rule: exact match of MAC or MAC and VLAN; " 7969 "hash match rule: hash match of MAC and exact match of VLAN", 7970 .tokens = { 7971 (void *)&cmd_set_vf_macvlan_set, 7972 (void *)&cmd_set_vf_macvlan_port, 7973 (void *)&cmd_set_vf_macvlan_portid, 7974 (void *)&cmd_set_vf_macvlan_vf, 7975 (void *)&cmd_set_vf_macvlan_vf_id, 7976 (void *)&cmd_set_vf_macvlan_mac, 7977 (void *)&cmd_set_vf_macvlan_filter_type, 7978 (void *)&cmd_set_vf_macvlan_mode, 7979 NULL, 7980 }, 7981 }; 7982 7983 /* *** CONFIGURE VF TRAFFIC CONTROL *** */ 7984 struct cmd_set_vf_traffic { 7985 cmdline_fixed_string_t set; 7986 cmdline_fixed_string_t port; 7987 portid_t port_id; 7988 cmdline_fixed_string_t vf; 7989 uint8_t vf_id; 7990 cmdline_fixed_string_t what; 7991 cmdline_fixed_string_t mode; 7992 }; 7993 7994 static void 7995 cmd_set_vf_traffic_parsed(void *parsed_result, 7996 __attribute__((unused)) struct cmdline *cl, 7997 __attribute__((unused)) void *data) 7998 { 7999 struct cmd_set_vf_traffic *res = parsed_result; 8000 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0; 8001 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8002 8003 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on); 8004 } 8005 8006 cmdline_parse_token_string_t cmd_setvf_traffic_set = 8007 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8008 set, "set"); 8009 cmdline_parse_token_string_t cmd_setvf_traffic_port = 8010 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8011 port, "port"); 8012 cmdline_parse_token_num_t cmd_setvf_traffic_portid = 8013 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8014 port_id, UINT16); 8015 cmdline_parse_token_string_t cmd_setvf_traffic_vf = 8016 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8017 vf, "vf"); 8018 cmdline_parse_token_num_t cmd_setvf_traffic_vfid = 8019 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8020 vf_id, UINT8); 8021 cmdline_parse_token_string_t cmd_setvf_traffic_what = 8022 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8023 what, "tx#rx"); 8024 cmdline_parse_token_string_t cmd_setvf_traffic_mode = 8025 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8026 mode, "on#off"); 8027 8028 cmdline_parse_inst_t cmd_set_vf_traffic = { 8029 .f = cmd_set_vf_traffic_parsed, 8030 .data = NULL, 8031 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off", 8032 .tokens = { 8033 (void *)&cmd_setvf_traffic_set, 8034 (void *)&cmd_setvf_traffic_port, 8035 (void *)&cmd_setvf_traffic_portid, 8036 (void *)&cmd_setvf_traffic_vf, 8037 (void *)&cmd_setvf_traffic_vfid, 8038 (void *)&cmd_setvf_traffic_what, 8039 (void *)&cmd_setvf_traffic_mode, 8040 NULL, 8041 }, 8042 }; 8043 8044 /* *** CONFIGURE VF RECEIVE MODE *** */ 8045 struct cmd_set_vf_rxmode { 8046 cmdline_fixed_string_t set; 8047 cmdline_fixed_string_t port; 8048 portid_t port_id; 8049 cmdline_fixed_string_t vf; 8050 uint8_t vf_id; 8051 cmdline_fixed_string_t what; 8052 cmdline_fixed_string_t mode; 8053 cmdline_fixed_string_t on; 8054 }; 8055 8056 static void 8057 cmd_set_vf_rxmode_parsed(void *parsed_result, 8058 __attribute__((unused)) struct cmdline *cl, 8059 __attribute__((unused)) void *data) 8060 { 8061 int ret = -ENOTSUP; 8062 uint16_t rx_mode = 0; 8063 struct cmd_set_vf_rxmode *res = parsed_result; 8064 8065 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0; 8066 if (!strcmp(res->what,"rxmode")) { 8067 if (!strcmp(res->mode, "AUPE")) 8068 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG; 8069 else if (!strcmp(res->mode, "ROPE")) 8070 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC; 8071 else if (!strcmp(res->mode, "BAM")) 8072 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST; 8073 else if (!strncmp(res->mode, "MPE",3)) 8074 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST; 8075 } 8076 8077 RTE_SET_USED(is_on); 8078 8079 #ifdef RTE_LIBRTE_IXGBE_PMD 8080 if (ret == -ENOTSUP) 8081 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, 8082 rx_mode, (uint8_t)is_on); 8083 #endif 8084 #ifdef RTE_LIBRTE_BNXT_PMD 8085 if (ret == -ENOTSUP) 8086 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id, 8087 rx_mode, (uint8_t)is_on); 8088 #endif 8089 if (ret < 0) 8090 printf("bad VF receive mode parameter, return code = %d \n", 8091 ret); 8092 } 8093 8094 cmdline_parse_token_string_t cmd_set_vf_rxmode_set = 8095 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8096 set, "set"); 8097 cmdline_parse_token_string_t cmd_set_vf_rxmode_port = 8098 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8099 port, "port"); 8100 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid = 8101 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8102 port_id, UINT16); 8103 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf = 8104 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8105 vf, "vf"); 8106 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid = 8107 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8108 vf_id, UINT8); 8109 cmdline_parse_token_string_t cmd_set_vf_rxmode_what = 8110 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8111 what, "rxmode"); 8112 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode = 8113 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8114 mode, "AUPE#ROPE#BAM#MPE"); 8115 cmdline_parse_token_string_t cmd_set_vf_rxmode_on = 8116 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8117 on, "on#off"); 8118 8119 cmdline_parse_inst_t cmd_set_vf_rxmode = { 8120 .f = cmd_set_vf_rxmode_parsed, 8121 .data = NULL, 8122 .help_str = "set port <port_id> vf <vf_id> rxmode " 8123 "AUPE|ROPE|BAM|MPE on|off", 8124 .tokens = { 8125 (void *)&cmd_set_vf_rxmode_set, 8126 (void *)&cmd_set_vf_rxmode_port, 8127 (void *)&cmd_set_vf_rxmode_portid, 8128 (void *)&cmd_set_vf_rxmode_vf, 8129 (void *)&cmd_set_vf_rxmode_vfid, 8130 (void *)&cmd_set_vf_rxmode_what, 8131 (void *)&cmd_set_vf_rxmode_mode, 8132 (void *)&cmd_set_vf_rxmode_on, 8133 NULL, 8134 }, 8135 }; 8136 8137 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */ 8138 struct cmd_vf_mac_addr_result { 8139 cmdline_fixed_string_t mac_addr_cmd; 8140 cmdline_fixed_string_t what; 8141 cmdline_fixed_string_t port; 8142 uint16_t port_num; 8143 cmdline_fixed_string_t vf; 8144 uint8_t vf_num; 8145 struct ether_addr address; 8146 }; 8147 8148 static void cmd_vf_mac_addr_parsed(void *parsed_result, 8149 __attribute__((unused)) struct cmdline *cl, 8150 __attribute__((unused)) void *data) 8151 { 8152 struct cmd_vf_mac_addr_result *res = parsed_result; 8153 int ret = -ENOTSUP; 8154 8155 if (strcmp(res->what, "add") != 0) 8156 return; 8157 8158 #ifdef RTE_LIBRTE_I40E_PMD 8159 if (ret == -ENOTSUP) 8160 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num, 8161 &res->address); 8162 #endif 8163 #ifdef RTE_LIBRTE_BNXT_PMD 8164 if (ret == -ENOTSUP) 8165 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address, 8166 res->vf_num); 8167 #endif 8168 8169 if(ret < 0) 8170 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret)); 8171 8172 } 8173 8174 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd = 8175 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8176 mac_addr_cmd,"mac_addr"); 8177 cmdline_parse_token_string_t cmd_vf_mac_addr_what = 8178 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8179 what,"add"); 8180 cmdline_parse_token_string_t cmd_vf_mac_addr_port = 8181 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8182 port,"port"); 8183 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum = 8184 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8185 port_num, UINT16); 8186 cmdline_parse_token_string_t cmd_vf_mac_addr_vf = 8187 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8188 vf,"vf"); 8189 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum = 8190 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8191 vf_num, UINT8); 8192 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr = 8193 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result, 8194 address); 8195 8196 cmdline_parse_inst_t cmd_vf_mac_addr_filter = { 8197 .f = cmd_vf_mac_addr_parsed, 8198 .data = (void *)0, 8199 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: " 8200 "Add MAC address filtering for a VF on port_id", 8201 .tokens = { 8202 (void *)&cmd_vf_mac_addr_cmd, 8203 (void *)&cmd_vf_mac_addr_what, 8204 (void *)&cmd_vf_mac_addr_port, 8205 (void *)&cmd_vf_mac_addr_portnum, 8206 (void *)&cmd_vf_mac_addr_vf, 8207 (void *)&cmd_vf_mac_addr_vfnum, 8208 (void *)&cmd_vf_mac_addr_addr, 8209 NULL, 8210 }, 8211 }; 8212 8213 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 8214 struct cmd_vf_rx_vlan_filter { 8215 cmdline_fixed_string_t rx_vlan; 8216 cmdline_fixed_string_t what; 8217 uint16_t vlan_id; 8218 cmdline_fixed_string_t port; 8219 portid_t port_id; 8220 cmdline_fixed_string_t vf; 8221 uint64_t vf_mask; 8222 }; 8223 8224 static void 8225 cmd_vf_rx_vlan_filter_parsed(void *parsed_result, 8226 __attribute__((unused)) struct cmdline *cl, 8227 __attribute__((unused)) void *data) 8228 { 8229 struct cmd_vf_rx_vlan_filter *res = parsed_result; 8230 int ret = -ENOTSUP; 8231 8232 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0; 8233 8234 #ifdef RTE_LIBRTE_IXGBE_PMD 8235 if (ret == -ENOTSUP) 8236 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id, 8237 res->vlan_id, res->vf_mask, is_add); 8238 #endif 8239 #ifdef RTE_LIBRTE_I40E_PMD 8240 if (ret == -ENOTSUP) 8241 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id, 8242 res->vlan_id, res->vf_mask, is_add); 8243 #endif 8244 #ifdef RTE_LIBRTE_BNXT_PMD 8245 if (ret == -ENOTSUP) 8246 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id, 8247 res->vlan_id, res->vf_mask, is_add); 8248 #endif 8249 8250 switch (ret) { 8251 case 0: 8252 break; 8253 case -EINVAL: 8254 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n", 8255 res->vlan_id, res->vf_mask); 8256 break; 8257 case -ENODEV: 8258 printf("invalid port_id %d\n", res->port_id); 8259 break; 8260 case -ENOTSUP: 8261 printf("function not implemented or supported\n"); 8262 break; 8263 default: 8264 printf("programming error: (%s)\n", strerror(-ret)); 8265 } 8266 } 8267 8268 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan = 8269 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8270 rx_vlan, "rx_vlan"); 8271 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what = 8272 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8273 what, "add#rm"); 8274 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid = 8275 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8276 vlan_id, UINT16); 8277 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port = 8278 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8279 port, "port"); 8280 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid = 8281 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8282 port_id, UINT16); 8283 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf = 8284 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8285 vf, "vf"); 8286 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask = 8287 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8288 vf_mask, UINT64); 8289 8290 cmdline_parse_inst_t cmd_vf_rxvlan_filter = { 8291 .f = cmd_vf_rx_vlan_filter_parsed, 8292 .data = NULL, 8293 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: " 8294 "(vf_mask = hexadecimal VF mask)", 8295 .tokens = { 8296 (void *)&cmd_vf_rx_vlan_filter_rx_vlan, 8297 (void *)&cmd_vf_rx_vlan_filter_what, 8298 (void *)&cmd_vf_rx_vlan_filter_vlanid, 8299 (void *)&cmd_vf_rx_vlan_filter_port, 8300 (void *)&cmd_vf_rx_vlan_filter_portid, 8301 (void *)&cmd_vf_rx_vlan_filter_vf, 8302 (void *)&cmd_vf_rx_vlan_filter_vf_mask, 8303 NULL, 8304 }, 8305 }; 8306 8307 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */ 8308 struct cmd_queue_rate_limit_result { 8309 cmdline_fixed_string_t set; 8310 cmdline_fixed_string_t port; 8311 uint16_t port_num; 8312 cmdline_fixed_string_t queue; 8313 uint8_t queue_num; 8314 cmdline_fixed_string_t rate; 8315 uint16_t rate_num; 8316 }; 8317 8318 static void cmd_queue_rate_limit_parsed(void *parsed_result, 8319 __attribute__((unused)) struct cmdline *cl, 8320 __attribute__((unused)) void *data) 8321 { 8322 struct cmd_queue_rate_limit_result *res = parsed_result; 8323 int ret = 0; 8324 8325 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8326 && (strcmp(res->queue, "queue") == 0) 8327 && (strcmp(res->rate, "rate") == 0)) 8328 ret = set_queue_rate_limit(res->port_num, res->queue_num, 8329 res->rate_num); 8330 if (ret < 0) 8331 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8332 8333 } 8334 8335 cmdline_parse_token_string_t cmd_queue_rate_limit_set = 8336 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8337 set, "set"); 8338 cmdline_parse_token_string_t cmd_queue_rate_limit_port = 8339 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8340 port, "port"); 8341 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum = 8342 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8343 port_num, UINT16); 8344 cmdline_parse_token_string_t cmd_queue_rate_limit_queue = 8345 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8346 queue, "queue"); 8347 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum = 8348 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8349 queue_num, UINT8); 8350 cmdline_parse_token_string_t cmd_queue_rate_limit_rate = 8351 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8352 rate, "rate"); 8353 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum = 8354 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8355 rate_num, UINT16); 8356 8357 cmdline_parse_inst_t cmd_queue_rate_limit = { 8358 .f = cmd_queue_rate_limit_parsed, 8359 .data = (void *)0, 8360 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: " 8361 "Set rate limit for a queue on port_id", 8362 .tokens = { 8363 (void *)&cmd_queue_rate_limit_set, 8364 (void *)&cmd_queue_rate_limit_port, 8365 (void *)&cmd_queue_rate_limit_portnum, 8366 (void *)&cmd_queue_rate_limit_queue, 8367 (void *)&cmd_queue_rate_limit_queuenum, 8368 (void *)&cmd_queue_rate_limit_rate, 8369 (void *)&cmd_queue_rate_limit_ratenum, 8370 NULL, 8371 }, 8372 }; 8373 8374 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */ 8375 struct cmd_vf_rate_limit_result { 8376 cmdline_fixed_string_t set; 8377 cmdline_fixed_string_t port; 8378 uint16_t port_num; 8379 cmdline_fixed_string_t vf; 8380 uint8_t vf_num; 8381 cmdline_fixed_string_t rate; 8382 uint16_t rate_num; 8383 cmdline_fixed_string_t q_msk; 8384 uint64_t q_msk_val; 8385 }; 8386 8387 static void cmd_vf_rate_limit_parsed(void *parsed_result, 8388 __attribute__((unused)) struct cmdline *cl, 8389 __attribute__((unused)) void *data) 8390 { 8391 struct cmd_vf_rate_limit_result *res = parsed_result; 8392 int ret = 0; 8393 8394 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8395 && (strcmp(res->vf, "vf") == 0) 8396 && (strcmp(res->rate, "rate") == 0) 8397 && (strcmp(res->q_msk, "queue_mask") == 0)) 8398 ret = set_vf_rate_limit(res->port_num, res->vf_num, 8399 res->rate_num, res->q_msk_val); 8400 if (ret < 0) 8401 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8402 8403 } 8404 8405 cmdline_parse_token_string_t cmd_vf_rate_limit_set = 8406 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8407 set, "set"); 8408 cmdline_parse_token_string_t cmd_vf_rate_limit_port = 8409 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8410 port, "port"); 8411 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum = 8412 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8413 port_num, UINT16); 8414 cmdline_parse_token_string_t cmd_vf_rate_limit_vf = 8415 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8416 vf, "vf"); 8417 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum = 8418 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8419 vf_num, UINT8); 8420 cmdline_parse_token_string_t cmd_vf_rate_limit_rate = 8421 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8422 rate, "rate"); 8423 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum = 8424 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8425 rate_num, UINT16); 8426 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk = 8427 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8428 q_msk, "queue_mask"); 8429 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val = 8430 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8431 q_msk_val, UINT64); 8432 8433 cmdline_parse_inst_t cmd_vf_rate_limit = { 8434 .f = cmd_vf_rate_limit_parsed, 8435 .data = (void *)0, 8436 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> " 8437 "queue_mask <queue_mask_value>: " 8438 "Set rate limit for queues of VF on port_id", 8439 .tokens = { 8440 (void *)&cmd_vf_rate_limit_set, 8441 (void *)&cmd_vf_rate_limit_port, 8442 (void *)&cmd_vf_rate_limit_portnum, 8443 (void *)&cmd_vf_rate_limit_vf, 8444 (void *)&cmd_vf_rate_limit_vfnum, 8445 (void *)&cmd_vf_rate_limit_rate, 8446 (void *)&cmd_vf_rate_limit_ratenum, 8447 (void *)&cmd_vf_rate_limit_q_msk, 8448 (void *)&cmd_vf_rate_limit_q_msk_val, 8449 NULL, 8450 }, 8451 }; 8452 8453 /* *** ADD TUNNEL FILTER OF A PORT *** */ 8454 struct cmd_tunnel_filter_result { 8455 cmdline_fixed_string_t cmd; 8456 cmdline_fixed_string_t what; 8457 portid_t port_id; 8458 struct ether_addr outer_mac; 8459 struct ether_addr inner_mac; 8460 cmdline_ipaddr_t ip_value; 8461 uint16_t inner_vlan; 8462 cmdline_fixed_string_t tunnel_type; 8463 cmdline_fixed_string_t filter_type; 8464 uint32_t tenant_id; 8465 uint16_t queue_num; 8466 }; 8467 8468 static void 8469 cmd_tunnel_filter_parsed(void *parsed_result, 8470 __attribute__((unused)) struct cmdline *cl, 8471 __attribute__((unused)) void *data) 8472 { 8473 struct cmd_tunnel_filter_result *res = parsed_result; 8474 struct rte_eth_tunnel_filter_conf tunnel_filter_conf; 8475 int ret = 0; 8476 8477 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf)); 8478 8479 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac); 8480 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac); 8481 tunnel_filter_conf.inner_vlan = res->inner_vlan; 8482 8483 if (res->ip_value.family == AF_INET) { 8484 tunnel_filter_conf.ip_addr.ipv4_addr = 8485 res->ip_value.addr.ipv4.s_addr; 8486 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4; 8487 } else { 8488 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr), 8489 &(res->ip_value.addr.ipv6), 8490 sizeof(struct in6_addr)); 8491 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6; 8492 } 8493 8494 if (!strcmp(res->filter_type, "imac-ivlan")) 8495 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN; 8496 else if (!strcmp(res->filter_type, "imac-ivlan-tenid")) 8497 tunnel_filter_conf.filter_type = 8498 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID; 8499 else if (!strcmp(res->filter_type, "imac-tenid")) 8500 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID; 8501 else if (!strcmp(res->filter_type, "imac")) 8502 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC; 8503 else if (!strcmp(res->filter_type, "omac-imac-tenid")) 8504 tunnel_filter_conf.filter_type = 8505 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC; 8506 else if (!strcmp(res->filter_type, "oip")) 8507 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP; 8508 else if (!strcmp(res->filter_type, "iip")) 8509 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP; 8510 else { 8511 printf("The filter type is not supported"); 8512 return; 8513 } 8514 8515 if (!strcmp(res->tunnel_type, "vxlan")) 8516 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN; 8517 else if (!strcmp(res->tunnel_type, "nvgre")) 8518 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE; 8519 else if (!strcmp(res->tunnel_type, "ipingre")) 8520 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE; 8521 else { 8522 printf("The tunnel type %s not supported.\n", res->tunnel_type); 8523 return; 8524 } 8525 8526 tunnel_filter_conf.tenant_id = res->tenant_id; 8527 tunnel_filter_conf.queue_id = res->queue_num; 8528 if (!strcmp(res->what, "add")) 8529 ret = rte_eth_dev_filter_ctrl(res->port_id, 8530 RTE_ETH_FILTER_TUNNEL, 8531 RTE_ETH_FILTER_ADD, 8532 &tunnel_filter_conf); 8533 else 8534 ret = rte_eth_dev_filter_ctrl(res->port_id, 8535 RTE_ETH_FILTER_TUNNEL, 8536 RTE_ETH_FILTER_DELETE, 8537 &tunnel_filter_conf); 8538 if (ret < 0) 8539 printf("cmd_tunnel_filter_parsed error: (%s)\n", 8540 strerror(-ret)); 8541 8542 } 8543 cmdline_parse_token_string_t cmd_tunnel_filter_cmd = 8544 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8545 cmd, "tunnel_filter"); 8546 cmdline_parse_token_string_t cmd_tunnel_filter_what = 8547 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8548 what, "add#rm"); 8549 cmdline_parse_token_num_t cmd_tunnel_filter_port_id = 8550 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8551 port_id, UINT16); 8552 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac = 8553 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8554 outer_mac); 8555 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac = 8556 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8557 inner_mac); 8558 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan = 8559 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8560 inner_vlan, UINT16); 8561 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value = 8562 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8563 ip_value); 8564 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type = 8565 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8566 tunnel_type, "vxlan#nvgre#ipingre"); 8567 8568 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type = 8569 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8570 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#" 8571 "imac#omac-imac-tenid"); 8572 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id = 8573 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8574 tenant_id, UINT32); 8575 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num = 8576 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8577 queue_num, UINT16); 8578 8579 cmdline_parse_inst_t cmd_tunnel_filter = { 8580 .f = cmd_tunnel_filter_parsed, 8581 .data = (void *)0, 8582 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> " 8583 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|" 8584 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> " 8585 "<queue_id>: Add/Rm tunnel filter of a port", 8586 .tokens = { 8587 (void *)&cmd_tunnel_filter_cmd, 8588 (void *)&cmd_tunnel_filter_what, 8589 (void *)&cmd_tunnel_filter_port_id, 8590 (void *)&cmd_tunnel_filter_outer_mac, 8591 (void *)&cmd_tunnel_filter_inner_mac, 8592 (void *)&cmd_tunnel_filter_ip_value, 8593 (void *)&cmd_tunnel_filter_innner_vlan, 8594 (void *)&cmd_tunnel_filter_tunnel_type, 8595 (void *)&cmd_tunnel_filter_filter_type, 8596 (void *)&cmd_tunnel_filter_tenant_id, 8597 (void *)&cmd_tunnel_filter_queue_num, 8598 NULL, 8599 }, 8600 }; 8601 8602 /* *** CONFIGURE TUNNEL UDP PORT *** */ 8603 struct cmd_tunnel_udp_config { 8604 cmdline_fixed_string_t cmd; 8605 cmdline_fixed_string_t what; 8606 uint16_t udp_port; 8607 portid_t port_id; 8608 }; 8609 8610 static void 8611 cmd_tunnel_udp_config_parsed(void *parsed_result, 8612 __attribute__((unused)) struct cmdline *cl, 8613 __attribute__((unused)) void *data) 8614 { 8615 struct cmd_tunnel_udp_config *res = parsed_result; 8616 struct rte_eth_udp_tunnel tunnel_udp; 8617 int ret; 8618 8619 tunnel_udp.udp_port = res->udp_port; 8620 8621 if (!strcmp(res->cmd, "rx_vxlan_port")) 8622 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 8623 8624 if (!strcmp(res->what, "add")) 8625 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 8626 &tunnel_udp); 8627 else 8628 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 8629 &tunnel_udp); 8630 8631 if (ret < 0) 8632 printf("udp tunneling add error: (%s)\n", strerror(-ret)); 8633 } 8634 8635 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd = 8636 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 8637 cmd, "rx_vxlan_port"); 8638 cmdline_parse_token_string_t cmd_tunnel_udp_config_what = 8639 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 8640 what, "add#rm"); 8641 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port = 8642 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 8643 udp_port, UINT16); 8644 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id = 8645 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 8646 port_id, UINT16); 8647 8648 cmdline_parse_inst_t cmd_tunnel_udp_config = { 8649 .f = cmd_tunnel_udp_config_parsed, 8650 .data = (void *)0, 8651 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: " 8652 "Add/Remove a tunneling UDP port filter", 8653 .tokens = { 8654 (void *)&cmd_tunnel_udp_config_cmd, 8655 (void *)&cmd_tunnel_udp_config_what, 8656 (void *)&cmd_tunnel_udp_config_udp_port, 8657 (void *)&cmd_tunnel_udp_config_port_id, 8658 NULL, 8659 }, 8660 }; 8661 8662 struct cmd_config_tunnel_udp_port { 8663 cmdline_fixed_string_t port; 8664 cmdline_fixed_string_t config; 8665 portid_t port_id; 8666 cmdline_fixed_string_t udp_tunnel_port; 8667 cmdline_fixed_string_t action; 8668 cmdline_fixed_string_t tunnel_type; 8669 uint16_t udp_port; 8670 }; 8671 8672 static void 8673 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result, 8674 __attribute__((unused)) struct cmdline *cl, 8675 __attribute__((unused)) void *data) 8676 { 8677 struct cmd_config_tunnel_udp_port *res = parsed_result; 8678 struct rte_eth_udp_tunnel tunnel_udp; 8679 int ret = 0; 8680 8681 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 8682 return; 8683 8684 tunnel_udp.udp_port = res->udp_port; 8685 8686 if (!strcmp(res->tunnel_type, "vxlan")) { 8687 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 8688 } else if (!strcmp(res->tunnel_type, "geneve")) { 8689 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE; 8690 } else { 8691 printf("Invalid tunnel type\n"); 8692 return; 8693 } 8694 8695 if (!strcmp(res->action, "add")) 8696 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 8697 &tunnel_udp); 8698 else 8699 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 8700 &tunnel_udp); 8701 8702 if (ret < 0) 8703 printf("udp tunneling port add error: (%s)\n", strerror(-ret)); 8704 } 8705 8706 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port = 8707 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port, 8708 "port"); 8709 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config = 8710 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config, 8711 "config"); 8712 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id = 8713 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id, 8714 UINT16); 8715 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port = 8716 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, 8717 udp_tunnel_port, 8718 "udp_tunnel_port"); 8719 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action = 8720 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action, 8721 "add#rm"); 8722 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type = 8723 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type, 8724 "vxlan#geneve"); 8725 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value = 8726 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port, 8727 UINT16); 8728 8729 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = { 8730 .f = cmd_cfg_tunnel_udp_port_parsed, 8731 .data = NULL, 8732 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>", 8733 .tokens = { 8734 (void *)&cmd_config_tunnel_udp_port_port, 8735 (void *)&cmd_config_tunnel_udp_port_config, 8736 (void *)&cmd_config_tunnel_udp_port_port_id, 8737 (void *)&cmd_config_tunnel_udp_port_tunnel_port, 8738 (void *)&cmd_config_tunnel_udp_port_action, 8739 (void *)&cmd_config_tunnel_udp_port_tunnel_type, 8740 (void *)&cmd_config_tunnel_udp_port_value, 8741 NULL, 8742 }, 8743 }; 8744 8745 /* *** GLOBAL CONFIG *** */ 8746 struct cmd_global_config_result { 8747 cmdline_fixed_string_t cmd; 8748 portid_t port_id; 8749 cmdline_fixed_string_t cfg_type; 8750 uint8_t len; 8751 }; 8752 8753 static void 8754 cmd_global_config_parsed(void *parsed_result, 8755 __attribute__((unused)) struct cmdline *cl, 8756 __attribute__((unused)) void *data) 8757 { 8758 struct cmd_global_config_result *res = parsed_result; 8759 struct rte_eth_global_cfg conf; 8760 int ret; 8761 8762 memset(&conf, 0, sizeof(conf)); 8763 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN; 8764 conf.cfg.gre_key_len = res->len; 8765 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE, 8766 RTE_ETH_FILTER_SET, &conf); 8767 if (ret != 0) 8768 printf("Global config error\n"); 8769 } 8770 8771 cmdline_parse_token_string_t cmd_global_config_cmd = 8772 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd, 8773 "global_config"); 8774 cmdline_parse_token_num_t cmd_global_config_port_id = 8775 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, 8776 UINT16); 8777 cmdline_parse_token_string_t cmd_global_config_type = 8778 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, 8779 cfg_type, "gre-key-len"); 8780 cmdline_parse_token_num_t cmd_global_config_gre_key_len = 8781 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, 8782 len, UINT8); 8783 8784 cmdline_parse_inst_t cmd_global_config = { 8785 .f = cmd_global_config_parsed, 8786 .data = (void *)NULL, 8787 .help_str = "global_config <port_id> gre-key-len <key_len>", 8788 .tokens = { 8789 (void *)&cmd_global_config_cmd, 8790 (void *)&cmd_global_config_port_id, 8791 (void *)&cmd_global_config_type, 8792 (void *)&cmd_global_config_gre_key_len, 8793 NULL, 8794 }, 8795 }; 8796 8797 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */ 8798 struct cmd_set_mirror_mask_result { 8799 cmdline_fixed_string_t set; 8800 cmdline_fixed_string_t port; 8801 portid_t port_id; 8802 cmdline_fixed_string_t mirror; 8803 uint8_t rule_id; 8804 cmdline_fixed_string_t what; 8805 cmdline_fixed_string_t value; 8806 cmdline_fixed_string_t dstpool; 8807 uint8_t dstpool_id; 8808 cmdline_fixed_string_t on; 8809 }; 8810 8811 cmdline_parse_token_string_t cmd_mirror_mask_set = 8812 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8813 set, "set"); 8814 cmdline_parse_token_string_t cmd_mirror_mask_port = 8815 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8816 port, "port"); 8817 cmdline_parse_token_num_t cmd_mirror_mask_portid = 8818 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 8819 port_id, UINT16); 8820 cmdline_parse_token_string_t cmd_mirror_mask_mirror = 8821 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8822 mirror, "mirror-rule"); 8823 cmdline_parse_token_num_t cmd_mirror_mask_ruleid = 8824 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 8825 rule_id, UINT8); 8826 cmdline_parse_token_string_t cmd_mirror_mask_what = 8827 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8828 what, "pool-mirror-up#pool-mirror-down" 8829 "#vlan-mirror"); 8830 cmdline_parse_token_string_t cmd_mirror_mask_value = 8831 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8832 value, NULL); 8833 cmdline_parse_token_string_t cmd_mirror_mask_dstpool = 8834 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8835 dstpool, "dst-pool"); 8836 cmdline_parse_token_num_t cmd_mirror_mask_poolid = 8837 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 8838 dstpool_id, UINT8); 8839 cmdline_parse_token_string_t cmd_mirror_mask_on = 8840 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8841 on, "on#off"); 8842 8843 static void 8844 cmd_set_mirror_mask_parsed(void *parsed_result, 8845 __attribute__((unused)) struct cmdline *cl, 8846 __attribute__((unused)) void *data) 8847 { 8848 int ret,nb_item,i; 8849 struct cmd_set_mirror_mask_result *res = parsed_result; 8850 struct rte_eth_mirror_conf mr_conf; 8851 8852 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 8853 8854 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS]; 8855 8856 mr_conf.dst_pool = res->dstpool_id; 8857 8858 if (!strcmp(res->what, "pool-mirror-up")) { 8859 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 8860 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP; 8861 } else if (!strcmp(res->what, "pool-mirror-down")) { 8862 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 8863 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN; 8864 } else if (!strcmp(res->what, "vlan-mirror")) { 8865 mr_conf.rule_type = ETH_MIRROR_VLAN; 8866 nb_item = parse_item_list(res->value, "vlan", 8867 ETH_MIRROR_MAX_VLANS, vlan_list, 1); 8868 if (nb_item <= 0) 8869 return; 8870 8871 for (i = 0; i < nb_item; i++) { 8872 if (vlan_list[i] > ETHER_MAX_VLAN_ID) { 8873 printf("Invalid vlan_id: must be < 4096\n"); 8874 return; 8875 } 8876 8877 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i]; 8878 mr_conf.vlan.vlan_mask |= 1ULL << i; 8879 } 8880 } 8881 8882 if (!strcmp(res->on, "on")) 8883 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 8884 res->rule_id, 1); 8885 else 8886 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 8887 res->rule_id, 0); 8888 if (ret < 0) 8889 printf("mirror rule add error: (%s)\n", strerror(-ret)); 8890 } 8891 8892 cmdline_parse_inst_t cmd_set_mirror_mask = { 8893 .f = cmd_set_mirror_mask_parsed, 8894 .data = NULL, 8895 .help_str = "set port <port_id> mirror-rule <rule_id> " 8896 "pool-mirror-up|pool-mirror-down|vlan-mirror " 8897 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off", 8898 .tokens = { 8899 (void *)&cmd_mirror_mask_set, 8900 (void *)&cmd_mirror_mask_port, 8901 (void *)&cmd_mirror_mask_portid, 8902 (void *)&cmd_mirror_mask_mirror, 8903 (void *)&cmd_mirror_mask_ruleid, 8904 (void *)&cmd_mirror_mask_what, 8905 (void *)&cmd_mirror_mask_value, 8906 (void *)&cmd_mirror_mask_dstpool, 8907 (void *)&cmd_mirror_mask_poolid, 8908 (void *)&cmd_mirror_mask_on, 8909 NULL, 8910 }, 8911 }; 8912 8913 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */ 8914 struct cmd_set_mirror_link_result { 8915 cmdline_fixed_string_t set; 8916 cmdline_fixed_string_t port; 8917 portid_t port_id; 8918 cmdline_fixed_string_t mirror; 8919 uint8_t rule_id; 8920 cmdline_fixed_string_t what; 8921 cmdline_fixed_string_t dstpool; 8922 uint8_t dstpool_id; 8923 cmdline_fixed_string_t on; 8924 }; 8925 8926 cmdline_parse_token_string_t cmd_mirror_link_set = 8927 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 8928 set, "set"); 8929 cmdline_parse_token_string_t cmd_mirror_link_port = 8930 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 8931 port, "port"); 8932 cmdline_parse_token_num_t cmd_mirror_link_portid = 8933 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 8934 port_id, UINT16); 8935 cmdline_parse_token_string_t cmd_mirror_link_mirror = 8936 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 8937 mirror, "mirror-rule"); 8938 cmdline_parse_token_num_t cmd_mirror_link_ruleid = 8939 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 8940 rule_id, UINT8); 8941 cmdline_parse_token_string_t cmd_mirror_link_what = 8942 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 8943 what, "uplink-mirror#downlink-mirror"); 8944 cmdline_parse_token_string_t cmd_mirror_link_dstpool = 8945 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 8946 dstpool, "dst-pool"); 8947 cmdline_parse_token_num_t cmd_mirror_link_poolid = 8948 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 8949 dstpool_id, UINT8); 8950 cmdline_parse_token_string_t cmd_mirror_link_on = 8951 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 8952 on, "on#off"); 8953 8954 static void 8955 cmd_set_mirror_link_parsed(void *parsed_result, 8956 __attribute__((unused)) struct cmdline *cl, 8957 __attribute__((unused)) void *data) 8958 { 8959 int ret; 8960 struct cmd_set_mirror_link_result *res = parsed_result; 8961 struct rte_eth_mirror_conf mr_conf; 8962 8963 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 8964 if (!strcmp(res->what, "uplink-mirror")) 8965 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT; 8966 else 8967 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT; 8968 8969 mr_conf.dst_pool = res->dstpool_id; 8970 8971 if (!strcmp(res->on, "on")) 8972 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 8973 res->rule_id, 1); 8974 else 8975 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 8976 res->rule_id, 0); 8977 8978 /* check the return value and print it if is < 0 */ 8979 if (ret < 0) 8980 printf("mirror rule add error: (%s)\n", strerror(-ret)); 8981 8982 } 8983 8984 cmdline_parse_inst_t cmd_set_mirror_link = { 8985 .f = cmd_set_mirror_link_parsed, 8986 .data = NULL, 8987 .help_str = "set port <port_id> mirror-rule <rule_id> " 8988 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off", 8989 .tokens = { 8990 (void *)&cmd_mirror_link_set, 8991 (void *)&cmd_mirror_link_port, 8992 (void *)&cmd_mirror_link_portid, 8993 (void *)&cmd_mirror_link_mirror, 8994 (void *)&cmd_mirror_link_ruleid, 8995 (void *)&cmd_mirror_link_what, 8996 (void *)&cmd_mirror_link_dstpool, 8997 (void *)&cmd_mirror_link_poolid, 8998 (void *)&cmd_mirror_link_on, 8999 NULL, 9000 }, 9001 }; 9002 9003 /* *** RESET VM MIRROR RULE *** */ 9004 struct cmd_rm_mirror_rule_result { 9005 cmdline_fixed_string_t reset; 9006 cmdline_fixed_string_t port; 9007 portid_t port_id; 9008 cmdline_fixed_string_t mirror; 9009 uint8_t rule_id; 9010 }; 9011 9012 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset = 9013 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9014 reset, "reset"); 9015 cmdline_parse_token_string_t cmd_rm_mirror_rule_port = 9016 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9017 port, "port"); 9018 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid = 9019 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9020 port_id, UINT16); 9021 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror = 9022 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9023 mirror, "mirror-rule"); 9024 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid = 9025 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9026 rule_id, UINT8); 9027 9028 static void 9029 cmd_reset_mirror_rule_parsed(void *parsed_result, 9030 __attribute__((unused)) struct cmdline *cl, 9031 __attribute__((unused)) void *data) 9032 { 9033 int ret; 9034 struct cmd_set_mirror_link_result *res = parsed_result; 9035 /* check rule_id */ 9036 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id); 9037 if(ret < 0) 9038 printf("mirror rule remove error: (%s)\n", strerror(-ret)); 9039 } 9040 9041 cmdline_parse_inst_t cmd_reset_mirror_rule = { 9042 .f = cmd_reset_mirror_rule_parsed, 9043 .data = NULL, 9044 .help_str = "reset port <port_id> mirror-rule <rule_id>", 9045 .tokens = { 9046 (void *)&cmd_rm_mirror_rule_reset, 9047 (void *)&cmd_rm_mirror_rule_port, 9048 (void *)&cmd_rm_mirror_rule_portid, 9049 (void *)&cmd_rm_mirror_rule_mirror, 9050 (void *)&cmd_rm_mirror_rule_ruleid, 9051 NULL, 9052 }, 9053 }; 9054 9055 /* ******************************************************************************** */ 9056 9057 struct cmd_dump_result { 9058 cmdline_fixed_string_t dump; 9059 }; 9060 9061 static void 9062 dump_struct_sizes(void) 9063 { 9064 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t)); 9065 DUMP_SIZE(struct rte_mbuf); 9066 DUMP_SIZE(struct rte_mempool); 9067 DUMP_SIZE(struct rte_ring); 9068 #undef DUMP_SIZE 9069 } 9070 9071 static void cmd_dump_parsed(void *parsed_result, 9072 __attribute__((unused)) struct cmdline *cl, 9073 __attribute__((unused)) void *data) 9074 { 9075 struct cmd_dump_result *res = parsed_result; 9076 9077 if (!strcmp(res->dump, "dump_physmem")) 9078 rte_dump_physmem_layout(stdout); 9079 else if (!strcmp(res->dump, "dump_memzone")) 9080 rte_memzone_dump(stdout); 9081 else if (!strcmp(res->dump, "dump_struct_sizes")) 9082 dump_struct_sizes(); 9083 else if (!strcmp(res->dump, "dump_ring")) 9084 rte_ring_list_dump(stdout); 9085 else if (!strcmp(res->dump, "dump_mempool")) 9086 rte_mempool_list_dump(stdout); 9087 else if (!strcmp(res->dump, "dump_devargs")) 9088 rte_devargs_dump(stdout); 9089 else if (!strcmp(res->dump, "dump_log_types")) 9090 rte_log_dump(stdout); 9091 } 9092 9093 cmdline_parse_token_string_t cmd_dump_dump = 9094 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, 9095 "dump_physmem#" 9096 "dump_memzone#" 9097 "dump_struct_sizes#" 9098 "dump_ring#" 9099 "dump_mempool#" 9100 "dump_devargs#" 9101 "dump_log_types"); 9102 9103 cmdline_parse_inst_t cmd_dump = { 9104 .f = cmd_dump_parsed, /* function to call */ 9105 .data = NULL, /* 2nd arg of func */ 9106 .help_str = "Dump status", 9107 .tokens = { /* token list, NULL terminated */ 9108 (void *)&cmd_dump_dump, 9109 NULL, 9110 }, 9111 }; 9112 9113 /* ******************************************************************************** */ 9114 9115 struct cmd_dump_one_result { 9116 cmdline_fixed_string_t dump; 9117 cmdline_fixed_string_t name; 9118 }; 9119 9120 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, 9121 __attribute__((unused)) void *data) 9122 { 9123 struct cmd_dump_one_result *res = parsed_result; 9124 9125 if (!strcmp(res->dump, "dump_ring")) { 9126 struct rte_ring *r; 9127 r = rte_ring_lookup(res->name); 9128 if (r == NULL) { 9129 cmdline_printf(cl, "Cannot find ring\n"); 9130 return; 9131 } 9132 rte_ring_dump(stdout, r); 9133 } else if (!strcmp(res->dump, "dump_mempool")) { 9134 struct rte_mempool *mp; 9135 mp = rte_mempool_lookup(res->name); 9136 if (mp == NULL) { 9137 cmdline_printf(cl, "Cannot find mempool\n"); 9138 return; 9139 } 9140 rte_mempool_dump(stdout, mp); 9141 } 9142 } 9143 9144 cmdline_parse_token_string_t cmd_dump_one_dump = 9145 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump, 9146 "dump_ring#dump_mempool"); 9147 9148 cmdline_parse_token_string_t cmd_dump_one_name = 9149 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL); 9150 9151 cmdline_parse_inst_t cmd_dump_one = { 9152 .f = cmd_dump_one_parsed, /* function to call */ 9153 .data = NULL, /* 2nd arg of func */ 9154 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool", 9155 .tokens = { /* token list, NULL terminated */ 9156 (void *)&cmd_dump_one_dump, 9157 (void *)&cmd_dump_one_name, 9158 NULL, 9159 }, 9160 }; 9161 9162 /* *** Add/Del syn filter *** */ 9163 struct cmd_syn_filter_result { 9164 cmdline_fixed_string_t filter; 9165 portid_t port_id; 9166 cmdline_fixed_string_t ops; 9167 cmdline_fixed_string_t priority; 9168 cmdline_fixed_string_t high; 9169 cmdline_fixed_string_t queue; 9170 uint16_t queue_id; 9171 }; 9172 9173 static void 9174 cmd_syn_filter_parsed(void *parsed_result, 9175 __attribute__((unused)) struct cmdline *cl, 9176 __attribute__((unused)) void *data) 9177 { 9178 struct cmd_syn_filter_result *res = parsed_result; 9179 struct rte_eth_syn_filter syn_filter; 9180 int ret = 0; 9181 9182 ret = rte_eth_dev_filter_supported(res->port_id, 9183 RTE_ETH_FILTER_SYN); 9184 if (ret < 0) { 9185 printf("syn filter is not supported on port %u.\n", 9186 res->port_id); 9187 return; 9188 } 9189 9190 memset(&syn_filter, 0, sizeof(syn_filter)); 9191 9192 if (!strcmp(res->ops, "add")) { 9193 if (!strcmp(res->high, "high")) 9194 syn_filter.hig_pri = 1; 9195 else 9196 syn_filter.hig_pri = 0; 9197 9198 syn_filter.queue = res->queue_id; 9199 ret = rte_eth_dev_filter_ctrl(res->port_id, 9200 RTE_ETH_FILTER_SYN, 9201 RTE_ETH_FILTER_ADD, 9202 &syn_filter); 9203 } else 9204 ret = rte_eth_dev_filter_ctrl(res->port_id, 9205 RTE_ETH_FILTER_SYN, 9206 RTE_ETH_FILTER_DELETE, 9207 &syn_filter); 9208 9209 if (ret < 0) 9210 printf("syn filter programming error: (%s)\n", 9211 strerror(-ret)); 9212 } 9213 9214 cmdline_parse_token_string_t cmd_syn_filter_filter = 9215 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9216 filter, "syn_filter"); 9217 cmdline_parse_token_num_t cmd_syn_filter_port_id = 9218 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 9219 port_id, UINT16); 9220 cmdline_parse_token_string_t cmd_syn_filter_ops = 9221 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9222 ops, "add#del"); 9223 cmdline_parse_token_string_t cmd_syn_filter_priority = 9224 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9225 priority, "priority"); 9226 cmdline_parse_token_string_t cmd_syn_filter_high = 9227 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9228 high, "high#low"); 9229 cmdline_parse_token_string_t cmd_syn_filter_queue = 9230 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9231 queue, "queue"); 9232 cmdline_parse_token_num_t cmd_syn_filter_queue_id = 9233 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 9234 queue_id, UINT16); 9235 9236 cmdline_parse_inst_t cmd_syn_filter = { 9237 .f = cmd_syn_filter_parsed, 9238 .data = NULL, 9239 .help_str = "syn_filter <port_id> add|del priority high|low queue " 9240 "<queue_id>: Add/Delete syn filter", 9241 .tokens = { 9242 (void *)&cmd_syn_filter_filter, 9243 (void *)&cmd_syn_filter_port_id, 9244 (void *)&cmd_syn_filter_ops, 9245 (void *)&cmd_syn_filter_priority, 9246 (void *)&cmd_syn_filter_high, 9247 (void *)&cmd_syn_filter_queue, 9248 (void *)&cmd_syn_filter_queue_id, 9249 NULL, 9250 }, 9251 }; 9252 9253 /* *** queue region set *** */ 9254 struct cmd_queue_region_result { 9255 cmdline_fixed_string_t set; 9256 cmdline_fixed_string_t port; 9257 portid_t port_id; 9258 cmdline_fixed_string_t cmd; 9259 cmdline_fixed_string_t region; 9260 uint8_t region_id; 9261 cmdline_fixed_string_t queue_start_index; 9262 uint8_t queue_id; 9263 cmdline_fixed_string_t queue_num; 9264 uint8_t queue_num_value; 9265 }; 9266 9267 static void 9268 cmd_queue_region_parsed(void *parsed_result, 9269 __attribute__((unused)) struct cmdline *cl, 9270 __attribute__((unused)) void *data) 9271 { 9272 struct cmd_queue_region_result *res = parsed_result; 9273 int ret = -ENOTSUP; 9274 #ifdef RTE_LIBRTE_I40E_PMD 9275 struct rte_pmd_i40e_queue_region_conf region_conf; 9276 enum rte_pmd_i40e_queue_region_op op_type; 9277 #endif 9278 9279 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9280 return; 9281 9282 #ifdef RTE_LIBRTE_I40E_PMD 9283 memset(®ion_conf, 0, sizeof(region_conf)); 9284 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET; 9285 region_conf.region_id = res->region_id; 9286 region_conf.queue_num = res->queue_num_value; 9287 region_conf.queue_start_index = res->queue_id; 9288 9289 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9290 op_type, ®ion_conf); 9291 #endif 9292 9293 switch (ret) { 9294 case 0: 9295 break; 9296 case -ENOTSUP: 9297 printf("function not implemented or supported\n"); 9298 break; 9299 default: 9300 printf("queue region config error: (%s)\n", strerror(-ret)); 9301 } 9302 } 9303 9304 cmdline_parse_token_string_t cmd_queue_region_set = 9305 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9306 set, "set"); 9307 cmdline_parse_token_string_t cmd_queue_region_port = 9308 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port"); 9309 cmdline_parse_token_num_t cmd_queue_region_port_id = 9310 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9311 port_id, UINT16); 9312 cmdline_parse_token_string_t cmd_queue_region_cmd = 9313 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9314 cmd, "queue-region"); 9315 cmdline_parse_token_string_t cmd_queue_region_id = 9316 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9317 region, "region_id"); 9318 cmdline_parse_token_num_t cmd_queue_region_index = 9319 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9320 region_id, UINT8); 9321 cmdline_parse_token_string_t cmd_queue_region_queue_start_index = 9322 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9323 queue_start_index, "queue_start_index"); 9324 cmdline_parse_token_num_t cmd_queue_region_queue_id = 9325 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9326 queue_id, UINT8); 9327 cmdline_parse_token_string_t cmd_queue_region_queue_num = 9328 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9329 queue_num, "queue_num"); 9330 cmdline_parse_token_num_t cmd_queue_region_queue_num_value = 9331 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9332 queue_num_value, UINT8); 9333 9334 cmdline_parse_inst_t cmd_queue_region = { 9335 .f = cmd_queue_region_parsed, 9336 .data = NULL, 9337 .help_str = "set port <port_id> queue-region region_id <value> " 9338 "queue_start_index <value> queue_num <value>: Set a queue region", 9339 .tokens = { 9340 (void *)&cmd_queue_region_set, 9341 (void *)&cmd_queue_region_port, 9342 (void *)&cmd_queue_region_port_id, 9343 (void *)&cmd_queue_region_cmd, 9344 (void *)&cmd_queue_region_id, 9345 (void *)&cmd_queue_region_index, 9346 (void *)&cmd_queue_region_queue_start_index, 9347 (void *)&cmd_queue_region_queue_id, 9348 (void *)&cmd_queue_region_queue_num, 9349 (void *)&cmd_queue_region_queue_num_value, 9350 NULL, 9351 }, 9352 }; 9353 9354 /* *** queue region and flowtype set *** */ 9355 struct cmd_region_flowtype_result { 9356 cmdline_fixed_string_t set; 9357 cmdline_fixed_string_t port; 9358 portid_t port_id; 9359 cmdline_fixed_string_t cmd; 9360 cmdline_fixed_string_t region; 9361 uint8_t region_id; 9362 cmdline_fixed_string_t flowtype; 9363 uint8_t flowtype_id; 9364 }; 9365 9366 static void 9367 cmd_region_flowtype_parsed(void *parsed_result, 9368 __attribute__((unused)) struct cmdline *cl, 9369 __attribute__((unused)) void *data) 9370 { 9371 struct cmd_region_flowtype_result *res = parsed_result; 9372 int ret = -ENOTSUP; 9373 #ifdef RTE_LIBRTE_I40E_PMD 9374 struct rte_pmd_i40e_queue_region_conf region_conf; 9375 enum rte_pmd_i40e_queue_region_op op_type; 9376 #endif 9377 9378 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9379 return; 9380 9381 #ifdef RTE_LIBRTE_I40E_PMD 9382 memset(®ion_conf, 0, sizeof(region_conf)); 9383 9384 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET; 9385 region_conf.region_id = res->region_id; 9386 region_conf.hw_flowtype = res->flowtype_id; 9387 9388 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9389 op_type, ®ion_conf); 9390 #endif 9391 9392 switch (ret) { 9393 case 0: 9394 break; 9395 case -ENOTSUP: 9396 printf("function not implemented or supported\n"); 9397 break; 9398 default: 9399 printf("region flowtype config error: (%s)\n", strerror(-ret)); 9400 } 9401 } 9402 9403 cmdline_parse_token_string_t cmd_region_flowtype_set = 9404 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9405 set, "set"); 9406 cmdline_parse_token_string_t cmd_region_flowtype_port = 9407 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9408 port, "port"); 9409 cmdline_parse_token_num_t cmd_region_flowtype_port_index = 9410 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9411 port_id, UINT16); 9412 cmdline_parse_token_string_t cmd_region_flowtype_cmd = 9413 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9414 cmd, "queue-region"); 9415 cmdline_parse_token_string_t cmd_region_flowtype_index = 9416 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9417 region, "region_id"); 9418 cmdline_parse_token_num_t cmd_region_flowtype_id = 9419 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9420 region_id, UINT8); 9421 cmdline_parse_token_string_t cmd_region_flowtype_flow_index = 9422 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9423 flowtype, "flowtype"); 9424 cmdline_parse_token_num_t cmd_region_flowtype_flow_id = 9425 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9426 flowtype_id, UINT8); 9427 cmdline_parse_inst_t cmd_region_flowtype = { 9428 .f = cmd_region_flowtype_parsed, 9429 .data = NULL, 9430 .help_str = "set port <port_id> queue-region region_id <value> " 9431 "flowtype <value>: Set a flowtype region index", 9432 .tokens = { 9433 (void *)&cmd_region_flowtype_set, 9434 (void *)&cmd_region_flowtype_port, 9435 (void *)&cmd_region_flowtype_port_index, 9436 (void *)&cmd_region_flowtype_cmd, 9437 (void *)&cmd_region_flowtype_index, 9438 (void *)&cmd_region_flowtype_id, 9439 (void *)&cmd_region_flowtype_flow_index, 9440 (void *)&cmd_region_flowtype_flow_id, 9441 NULL, 9442 }, 9443 }; 9444 9445 /* *** User Priority (UP) to queue region (region_id) set *** */ 9446 struct cmd_user_priority_region_result { 9447 cmdline_fixed_string_t set; 9448 cmdline_fixed_string_t port; 9449 portid_t port_id; 9450 cmdline_fixed_string_t cmd; 9451 cmdline_fixed_string_t user_priority; 9452 uint8_t user_priority_id; 9453 cmdline_fixed_string_t region; 9454 uint8_t region_id; 9455 }; 9456 9457 static void 9458 cmd_user_priority_region_parsed(void *parsed_result, 9459 __attribute__((unused)) struct cmdline *cl, 9460 __attribute__((unused)) void *data) 9461 { 9462 struct cmd_user_priority_region_result *res = parsed_result; 9463 int ret = -ENOTSUP; 9464 #ifdef RTE_LIBRTE_I40E_PMD 9465 struct rte_pmd_i40e_queue_region_conf region_conf; 9466 enum rte_pmd_i40e_queue_region_op op_type; 9467 #endif 9468 9469 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9470 return; 9471 9472 #ifdef RTE_LIBRTE_I40E_PMD 9473 memset(®ion_conf, 0, sizeof(region_conf)); 9474 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET; 9475 region_conf.user_priority = res->user_priority_id; 9476 region_conf.region_id = res->region_id; 9477 9478 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9479 op_type, ®ion_conf); 9480 #endif 9481 9482 switch (ret) { 9483 case 0: 9484 break; 9485 case -ENOTSUP: 9486 printf("function not implemented or supported\n"); 9487 break; 9488 default: 9489 printf("user_priority region config error: (%s)\n", 9490 strerror(-ret)); 9491 } 9492 } 9493 9494 cmdline_parse_token_string_t cmd_user_priority_region_set = 9495 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9496 set, "set"); 9497 cmdline_parse_token_string_t cmd_user_priority_region_port = 9498 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9499 port, "port"); 9500 cmdline_parse_token_num_t cmd_user_priority_region_port_index = 9501 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9502 port_id, UINT16); 9503 cmdline_parse_token_string_t cmd_user_priority_region_cmd = 9504 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9505 cmd, "queue-region"); 9506 cmdline_parse_token_string_t cmd_user_priority_region_UP = 9507 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9508 user_priority, "UP"); 9509 cmdline_parse_token_num_t cmd_user_priority_region_UP_id = 9510 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9511 user_priority_id, UINT8); 9512 cmdline_parse_token_string_t cmd_user_priority_region_region = 9513 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9514 region, "region_id"); 9515 cmdline_parse_token_num_t cmd_user_priority_region_region_id = 9516 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9517 region_id, UINT8); 9518 9519 cmdline_parse_inst_t cmd_user_priority_region = { 9520 .f = cmd_user_priority_region_parsed, 9521 .data = NULL, 9522 .help_str = "set port <port_id> queue-region UP <value> " 9523 "region_id <value>: Set the mapping of User Priority (UP) " 9524 "to queue region (region_id) ", 9525 .tokens = { 9526 (void *)&cmd_user_priority_region_set, 9527 (void *)&cmd_user_priority_region_port, 9528 (void *)&cmd_user_priority_region_port_index, 9529 (void *)&cmd_user_priority_region_cmd, 9530 (void *)&cmd_user_priority_region_UP, 9531 (void *)&cmd_user_priority_region_UP_id, 9532 (void *)&cmd_user_priority_region_region, 9533 (void *)&cmd_user_priority_region_region_id, 9534 NULL, 9535 }, 9536 }; 9537 9538 /* *** flush all queue region related configuration *** */ 9539 struct cmd_flush_queue_region_result { 9540 cmdline_fixed_string_t set; 9541 cmdline_fixed_string_t port; 9542 portid_t port_id; 9543 cmdline_fixed_string_t cmd; 9544 cmdline_fixed_string_t flush; 9545 cmdline_fixed_string_t what; 9546 }; 9547 9548 static void 9549 cmd_flush_queue_region_parsed(void *parsed_result, 9550 __attribute__((unused)) struct cmdline *cl, 9551 __attribute__((unused)) void *data) 9552 { 9553 struct cmd_flush_queue_region_result *res = parsed_result; 9554 int ret = -ENOTSUP; 9555 #ifdef RTE_LIBRTE_I40E_PMD 9556 struct rte_pmd_i40e_queue_region_conf region_conf; 9557 enum rte_pmd_i40e_queue_region_op op_type; 9558 #endif 9559 9560 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9561 return; 9562 9563 #ifdef RTE_LIBRTE_I40E_PMD 9564 memset(®ion_conf, 0, sizeof(region_conf)); 9565 9566 if (strcmp(res->what, "on") == 0) 9567 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON; 9568 else 9569 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF; 9570 9571 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9572 op_type, ®ion_conf); 9573 #endif 9574 9575 switch (ret) { 9576 case 0: 9577 break; 9578 case -ENOTSUP: 9579 printf("function not implemented or supported\n"); 9580 break; 9581 default: 9582 printf("queue region config flush error: (%s)\n", 9583 strerror(-ret)); 9584 } 9585 } 9586 9587 cmdline_parse_token_string_t cmd_flush_queue_region_set = 9588 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9589 set, "set"); 9590 cmdline_parse_token_string_t cmd_flush_queue_region_port = 9591 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9592 port, "port"); 9593 cmdline_parse_token_num_t cmd_flush_queue_region_port_index = 9594 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result, 9595 port_id, UINT16); 9596 cmdline_parse_token_string_t cmd_flush_queue_region_cmd = 9597 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9598 cmd, "queue-region"); 9599 cmdline_parse_token_string_t cmd_flush_queue_region_flush = 9600 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9601 flush, "flush"); 9602 cmdline_parse_token_string_t cmd_flush_queue_region_what = 9603 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9604 what, "on#off"); 9605 9606 cmdline_parse_inst_t cmd_flush_queue_region = { 9607 .f = cmd_flush_queue_region_parsed, 9608 .data = NULL, 9609 .help_str = "set port <port_id> queue-region flush on|off" 9610 ": flush all queue region related configuration", 9611 .tokens = { 9612 (void *)&cmd_flush_queue_region_set, 9613 (void *)&cmd_flush_queue_region_port, 9614 (void *)&cmd_flush_queue_region_port_index, 9615 (void *)&cmd_flush_queue_region_cmd, 9616 (void *)&cmd_flush_queue_region_flush, 9617 (void *)&cmd_flush_queue_region_what, 9618 NULL, 9619 }, 9620 }; 9621 9622 /* *** get all queue region related configuration info *** */ 9623 struct cmd_show_queue_region_info { 9624 cmdline_fixed_string_t show; 9625 cmdline_fixed_string_t port; 9626 portid_t port_id; 9627 cmdline_fixed_string_t cmd; 9628 }; 9629 9630 static void 9631 cmd_show_queue_region_info_parsed(void *parsed_result, 9632 __attribute__((unused)) struct cmdline *cl, 9633 __attribute__((unused)) void *data) 9634 { 9635 struct cmd_show_queue_region_info *res = parsed_result; 9636 int ret = -ENOTSUP; 9637 #ifdef RTE_LIBRTE_I40E_PMD 9638 struct rte_pmd_i40e_queue_regions rte_pmd_regions; 9639 enum rte_pmd_i40e_queue_region_op op_type; 9640 #endif 9641 9642 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9643 return; 9644 9645 #ifdef RTE_LIBRTE_I40E_PMD 9646 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions)); 9647 9648 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET; 9649 9650 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9651 op_type, &rte_pmd_regions); 9652 9653 port_queue_region_info_display(res->port_id, &rte_pmd_regions); 9654 #endif 9655 9656 switch (ret) { 9657 case 0: 9658 break; 9659 case -ENOTSUP: 9660 printf("function not implemented or supported\n"); 9661 break; 9662 default: 9663 printf("queue region config info show error: (%s)\n", 9664 strerror(-ret)); 9665 } 9666 } 9667 9668 cmdline_parse_token_string_t cmd_show_queue_region_info_get = 9669 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9670 show, "show"); 9671 cmdline_parse_token_string_t cmd_show_queue_region_info_port = 9672 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9673 port, "port"); 9674 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index = 9675 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info, 9676 port_id, UINT16); 9677 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd = 9678 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9679 cmd, "queue-region"); 9680 9681 cmdline_parse_inst_t cmd_show_queue_region_info_all = { 9682 .f = cmd_show_queue_region_info_parsed, 9683 .data = NULL, 9684 .help_str = "show port <port_id> queue-region" 9685 ": show all queue region related configuration info", 9686 .tokens = { 9687 (void *)&cmd_show_queue_region_info_get, 9688 (void *)&cmd_show_queue_region_info_port, 9689 (void *)&cmd_show_queue_region_info_port_index, 9690 (void *)&cmd_show_queue_region_info_cmd, 9691 NULL, 9692 }, 9693 }; 9694 9695 /* *** ADD/REMOVE A 2tuple FILTER *** */ 9696 struct cmd_2tuple_filter_result { 9697 cmdline_fixed_string_t filter; 9698 portid_t port_id; 9699 cmdline_fixed_string_t ops; 9700 cmdline_fixed_string_t dst_port; 9701 uint16_t dst_port_value; 9702 cmdline_fixed_string_t protocol; 9703 uint8_t protocol_value; 9704 cmdline_fixed_string_t mask; 9705 uint8_t mask_value; 9706 cmdline_fixed_string_t tcp_flags; 9707 uint8_t tcp_flags_value; 9708 cmdline_fixed_string_t priority; 9709 uint8_t priority_value; 9710 cmdline_fixed_string_t queue; 9711 uint16_t queue_id; 9712 }; 9713 9714 static void 9715 cmd_2tuple_filter_parsed(void *parsed_result, 9716 __attribute__((unused)) struct cmdline *cl, 9717 __attribute__((unused)) void *data) 9718 { 9719 struct rte_eth_ntuple_filter filter; 9720 struct cmd_2tuple_filter_result *res = parsed_result; 9721 int ret = 0; 9722 9723 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 9724 if (ret < 0) { 9725 printf("ntuple filter is not supported on port %u.\n", 9726 res->port_id); 9727 return; 9728 } 9729 9730 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 9731 9732 filter.flags = RTE_2TUPLE_FLAGS; 9733 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 9734 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 9735 filter.proto = res->protocol_value; 9736 filter.priority = res->priority_value; 9737 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 9738 printf("nonzero tcp_flags is only meaningful" 9739 " when protocol is TCP.\n"); 9740 return; 9741 } 9742 if (res->tcp_flags_value > TCP_FLAG_ALL) { 9743 printf("invalid TCP flags.\n"); 9744 return; 9745 } 9746 9747 if (res->tcp_flags_value != 0) { 9748 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 9749 filter.tcp_flags = res->tcp_flags_value; 9750 } 9751 9752 /* need convert to big endian. */ 9753 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 9754 filter.queue = res->queue_id; 9755 9756 if (!strcmp(res->ops, "add")) 9757 ret = rte_eth_dev_filter_ctrl(res->port_id, 9758 RTE_ETH_FILTER_NTUPLE, 9759 RTE_ETH_FILTER_ADD, 9760 &filter); 9761 else 9762 ret = rte_eth_dev_filter_ctrl(res->port_id, 9763 RTE_ETH_FILTER_NTUPLE, 9764 RTE_ETH_FILTER_DELETE, 9765 &filter); 9766 if (ret < 0) 9767 printf("2tuple filter programming error: (%s)\n", 9768 strerror(-ret)); 9769 9770 } 9771 9772 cmdline_parse_token_string_t cmd_2tuple_filter_filter = 9773 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9774 filter, "2tuple_filter"); 9775 cmdline_parse_token_num_t cmd_2tuple_filter_port_id = 9776 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9777 port_id, UINT16); 9778 cmdline_parse_token_string_t cmd_2tuple_filter_ops = 9779 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9780 ops, "add#del"); 9781 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port = 9782 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9783 dst_port, "dst_port"); 9784 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value = 9785 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9786 dst_port_value, UINT16); 9787 cmdline_parse_token_string_t cmd_2tuple_filter_protocol = 9788 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9789 protocol, "protocol"); 9790 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value = 9791 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9792 protocol_value, UINT8); 9793 cmdline_parse_token_string_t cmd_2tuple_filter_mask = 9794 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9795 mask, "mask"); 9796 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value = 9797 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9798 mask_value, INT8); 9799 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags = 9800 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9801 tcp_flags, "tcp_flags"); 9802 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value = 9803 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9804 tcp_flags_value, UINT8); 9805 cmdline_parse_token_string_t cmd_2tuple_filter_priority = 9806 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9807 priority, "priority"); 9808 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value = 9809 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9810 priority_value, UINT8); 9811 cmdline_parse_token_string_t cmd_2tuple_filter_queue = 9812 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9813 queue, "queue"); 9814 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id = 9815 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9816 queue_id, UINT16); 9817 9818 cmdline_parse_inst_t cmd_2tuple_filter = { 9819 .f = cmd_2tuple_filter_parsed, 9820 .data = NULL, 9821 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol " 9822 "<value> mask <value> tcp_flags <value> priority <value> queue " 9823 "<queue_id>: Add a 2tuple filter", 9824 .tokens = { 9825 (void *)&cmd_2tuple_filter_filter, 9826 (void *)&cmd_2tuple_filter_port_id, 9827 (void *)&cmd_2tuple_filter_ops, 9828 (void *)&cmd_2tuple_filter_dst_port, 9829 (void *)&cmd_2tuple_filter_dst_port_value, 9830 (void *)&cmd_2tuple_filter_protocol, 9831 (void *)&cmd_2tuple_filter_protocol_value, 9832 (void *)&cmd_2tuple_filter_mask, 9833 (void *)&cmd_2tuple_filter_mask_value, 9834 (void *)&cmd_2tuple_filter_tcp_flags, 9835 (void *)&cmd_2tuple_filter_tcp_flags_value, 9836 (void *)&cmd_2tuple_filter_priority, 9837 (void *)&cmd_2tuple_filter_priority_value, 9838 (void *)&cmd_2tuple_filter_queue, 9839 (void *)&cmd_2tuple_filter_queue_id, 9840 NULL, 9841 }, 9842 }; 9843 9844 /* *** ADD/REMOVE A 5tuple FILTER *** */ 9845 struct cmd_5tuple_filter_result { 9846 cmdline_fixed_string_t filter; 9847 portid_t port_id; 9848 cmdline_fixed_string_t ops; 9849 cmdline_fixed_string_t dst_ip; 9850 cmdline_ipaddr_t dst_ip_value; 9851 cmdline_fixed_string_t src_ip; 9852 cmdline_ipaddr_t src_ip_value; 9853 cmdline_fixed_string_t dst_port; 9854 uint16_t dst_port_value; 9855 cmdline_fixed_string_t src_port; 9856 uint16_t src_port_value; 9857 cmdline_fixed_string_t protocol; 9858 uint8_t protocol_value; 9859 cmdline_fixed_string_t mask; 9860 uint8_t mask_value; 9861 cmdline_fixed_string_t tcp_flags; 9862 uint8_t tcp_flags_value; 9863 cmdline_fixed_string_t priority; 9864 uint8_t priority_value; 9865 cmdline_fixed_string_t queue; 9866 uint16_t queue_id; 9867 }; 9868 9869 static void 9870 cmd_5tuple_filter_parsed(void *parsed_result, 9871 __attribute__((unused)) struct cmdline *cl, 9872 __attribute__((unused)) void *data) 9873 { 9874 struct rte_eth_ntuple_filter filter; 9875 struct cmd_5tuple_filter_result *res = parsed_result; 9876 int ret = 0; 9877 9878 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 9879 if (ret < 0) { 9880 printf("ntuple filter is not supported on port %u.\n", 9881 res->port_id); 9882 return; 9883 } 9884 9885 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 9886 9887 filter.flags = RTE_5TUPLE_FLAGS; 9888 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0; 9889 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0; 9890 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0; 9891 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 9892 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 9893 filter.proto = res->protocol_value; 9894 filter.priority = res->priority_value; 9895 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 9896 printf("nonzero tcp_flags is only meaningful" 9897 " when protocol is TCP.\n"); 9898 return; 9899 } 9900 if (res->tcp_flags_value > TCP_FLAG_ALL) { 9901 printf("invalid TCP flags.\n"); 9902 return; 9903 } 9904 9905 if (res->tcp_flags_value != 0) { 9906 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 9907 filter.tcp_flags = res->tcp_flags_value; 9908 } 9909 9910 if (res->dst_ip_value.family == AF_INET) 9911 /* no need to convert, already big endian. */ 9912 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr; 9913 else { 9914 if (filter.dst_ip_mask == 0) { 9915 printf("can not support ipv6 involved compare.\n"); 9916 return; 9917 } 9918 filter.dst_ip = 0; 9919 } 9920 9921 if (res->src_ip_value.family == AF_INET) 9922 /* no need to convert, already big endian. */ 9923 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr; 9924 else { 9925 if (filter.src_ip_mask == 0) { 9926 printf("can not support ipv6 involved compare.\n"); 9927 return; 9928 } 9929 filter.src_ip = 0; 9930 } 9931 /* need convert to big endian. */ 9932 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 9933 filter.src_port = rte_cpu_to_be_16(res->src_port_value); 9934 filter.queue = res->queue_id; 9935 9936 if (!strcmp(res->ops, "add")) 9937 ret = rte_eth_dev_filter_ctrl(res->port_id, 9938 RTE_ETH_FILTER_NTUPLE, 9939 RTE_ETH_FILTER_ADD, 9940 &filter); 9941 else 9942 ret = rte_eth_dev_filter_ctrl(res->port_id, 9943 RTE_ETH_FILTER_NTUPLE, 9944 RTE_ETH_FILTER_DELETE, 9945 &filter); 9946 if (ret < 0) 9947 printf("5tuple filter programming error: (%s)\n", 9948 strerror(-ret)); 9949 } 9950 9951 cmdline_parse_token_string_t cmd_5tuple_filter_filter = 9952 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9953 filter, "5tuple_filter"); 9954 cmdline_parse_token_num_t cmd_5tuple_filter_port_id = 9955 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9956 port_id, UINT16); 9957 cmdline_parse_token_string_t cmd_5tuple_filter_ops = 9958 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9959 ops, "add#del"); 9960 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip = 9961 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9962 dst_ip, "dst_ip"); 9963 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value = 9964 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 9965 dst_ip_value); 9966 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip = 9967 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9968 src_ip, "src_ip"); 9969 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value = 9970 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 9971 src_ip_value); 9972 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port = 9973 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9974 dst_port, "dst_port"); 9975 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value = 9976 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9977 dst_port_value, UINT16); 9978 cmdline_parse_token_string_t cmd_5tuple_filter_src_port = 9979 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9980 src_port, "src_port"); 9981 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value = 9982 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9983 src_port_value, UINT16); 9984 cmdline_parse_token_string_t cmd_5tuple_filter_protocol = 9985 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9986 protocol, "protocol"); 9987 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value = 9988 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9989 protocol_value, UINT8); 9990 cmdline_parse_token_string_t cmd_5tuple_filter_mask = 9991 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9992 mask, "mask"); 9993 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value = 9994 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 9995 mask_value, INT8); 9996 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags = 9997 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 9998 tcp_flags, "tcp_flags"); 9999 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value = 10000 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10001 tcp_flags_value, UINT8); 10002 cmdline_parse_token_string_t cmd_5tuple_filter_priority = 10003 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10004 priority, "priority"); 10005 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value = 10006 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10007 priority_value, UINT8); 10008 cmdline_parse_token_string_t cmd_5tuple_filter_queue = 10009 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10010 queue, "queue"); 10011 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id = 10012 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10013 queue_id, UINT16); 10014 10015 cmdline_parse_inst_t cmd_5tuple_filter = { 10016 .f = cmd_5tuple_filter_parsed, 10017 .data = NULL, 10018 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> " 10019 "src_ip <value> dst_port <value> src_port <value> " 10020 "protocol <value> mask <value> tcp_flags <value> " 10021 "priority <value> queue <queue_id>: Add/Del a 5tuple filter", 10022 .tokens = { 10023 (void *)&cmd_5tuple_filter_filter, 10024 (void *)&cmd_5tuple_filter_port_id, 10025 (void *)&cmd_5tuple_filter_ops, 10026 (void *)&cmd_5tuple_filter_dst_ip, 10027 (void *)&cmd_5tuple_filter_dst_ip_value, 10028 (void *)&cmd_5tuple_filter_src_ip, 10029 (void *)&cmd_5tuple_filter_src_ip_value, 10030 (void *)&cmd_5tuple_filter_dst_port, 10031 (void *)&cmd_5tuple_filter_dst_port_value, 10032 (void *)&cmd_5tuple_filter_src_port, 10033 (void *)&cmd_5tuple_filter_src_port_value, 10034 (void *)&cmd_5tuple_filter_protocol, 10035 (void *)&cmd_5tuple_filter_protocol_value, 10036 (void *)&cmd_5tuple_filter_mask, 10037 (void *)&cmd_5tuple_filter_mask_value, 10038 (void *)&cmd_5tuple_filter_tcp_flags, 10039 (void *)&cmd_5tuple_filter_tcp_flags_value, 10040 (void *)&cmd_5tuple_filter_priority, 10041 (void *)&cmd_5tuple_filter_priority_value, 10042 (void *)&cmd_5tuple_filter_queue, 10043 (void *)&cmd_5tuple_filter_queue_id, 10044 NULL, 10045 }, 10046 }; 10047 10048 /* *** ADD/REMOVE A flex FILTER *** */ 10049 struct cmd_flex_filter_result { 10050 cmdline_fixed_string_t filter; 10051 cmdline_fixed_string_t ops; 10052 portid_t port_id; 10053 cmdline_fixed_string_t len; 10054 uint8_t len_value; 10055 cmdline_fixed_string_t bytes; 10056 cmdline_fixed_string_t bytes_value; 10057 cmdline_fixed_string_t mask; 10058 cmdline_fixed_string_t mask_value; 10059 cmdline_fixed_string_t priority; 10060 uint8_t priority_value; 10061 cmdline_fixed_string_t queue; 10062 uint16_t queue_id; 10063 }; 10064 10065 static int xdigit2val(unsigned char c) 10066 { 10067 int val; 10068 if (isdigit(c)) 10069 val = c - '0'; 10070 else if (isupper(c)) 10071 val = c - 'A' + 10; 10072 else 10073 val = c - 'a' + 10; 10074 return val; 10075 } 10076 10077 static void 10078 cmd_flex_filter_parsed(void *parsed_result, 10079 __attribute__((unused)) struct cmdline *cl, 10080 __attribute__((unused)) void *data) 10081 { 10082 int ret = 0; 10083 struct rte_eth_flex_filter filter; 10084 struct cmd_flex_filter_result *res = parsed_result; 10085 char *bytes_ptr, *mask_ptr; 10086 uint16_t len, i, j = 0; 10087 char c; 10088 int val; 10089 uint8_t byte = 0; 10090 10091 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) { 10092 printf("the len exceed the max length 128\n"); 10093 return; 10094 } 10095 memset(&filter, 0, sizeof(struct rte_eth_flex_filter)); 10096 filter.len = res->len_value; 10097 filter.priority = res->priority_value; 10098 filter.queue = res->queue_id; 10099 bytes_ptr = res->bytes_value; 10100 mask_ptr = res->mask_value; 10101 10102 /* translate bytes string to array. */ 10103 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') || 10104 (bytes_ptr[1] == 'X'))) 10105 bytes_ptr += 2; 10106 len = strnlen(bytes_ptr, res->len_value * 2); 10107 if (len == 0 || (len % 8 != 0)) { 10108 printf("please check len and bytes input\n"); 10109 return; 10110 } 10111 for (i = 0; i < len; i++) { 10112 c = bytes_ptr[i]; 10113 if (isxdigit(c) == 0) { 10114 /* invalid characters. */ 10115 printf("invalid input\n"); 10116 return; 10117 } 10118 val = xdigit2val(c); 10119 if (i % 2) { 10120 byte |= val; 10121 filter.bytes[j] = byte; 10122 printf("bytes[%d]:%02x ", j, filter.bytes[j]); 10123 j++; 10124 byte = 0; 10125 } else 10126 byte |= val << 4; 10127 } 10128 printf("\n"); 10129 /* translate mask string to uint8_t array. */ 10130 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') || 10131 (mask_ptr[1] == 'X'))) 10132 mask_ptr += 2; 10133 len = strnlen(mask_ptr, (res->len_value + 3) / 4); 10134 if (len == 0) { 10135 printf("invalid input\n"); 10136 return; 10137 } 10138 j = 0; 10139 byte = 0; 10140 for (i = 0; i < len; i++) { 10141 c = mask_ptr[i]; 10142 if (isxdigit(c) == 0) { 10143 /* invalid characters. */ 10144 printf("invalid input\n"); 10145 return; 10146 } 10147 val = xdigit2val(c); 10148 if (i % 2) { 10149 byte |= val; 10150 filter.mask[j] = byte; 10151 printf("mask[%d]:%02x ", j, filter.mask[j]); 10152 j++; 10153 byte = 0; 10154 } else 10155 byte |= val << 4; 10156 } 10157 printf("\n"); 10158 10159 if (!strcmp(res->ops, "add")) 10160 ret = rte_eth_dev_filter_ctrl(res->port_id, 10161 RTE_ETH_FILTER_FLEXIBLE, 10162 RTE_ETH_FILTER_ADD, 10163 &filter); 10164 else 10165 ret = rte_eth_dev_filter_ctrl(res->port_id, 10166 RTE_ETH_FILTER_FLEXIBLE, 10167 RTE_ETH_FILTER_DELETE, 10168 &filter); 10169 10170 if (ret < 0) 10171 printf("flex filter setting error: (%s)\n", strerror(-ret)); 10172 } 10173 10174 cmdline_parse_token_string_t cmd_flex_filter_filter = 10175 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10176 filter, "flex_filter"); 10177 cmdline_parse_token_num_t cmd_flex_filter_port_id = 10178 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10179 port_id, UINT16); 10180 cmdline_parse_token_string_t cmd_flex_filter_ops = 10181 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10182 ops, "add#del"); 10183 cmdline_parse_token_string_t cmd_flex_filter_len = 10184 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10185 len, "len"); 10186 cmdline_parse_token_num_t cmd_flex_filter_len_value = 10187 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10188 len_value, UINT8); 10189 cmdline_parse_token_string_t cmd_flex_filter_bytes = 10190 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10191 bytes, "bytes"); 10192 cmdline_parse_token_string_t cmd_flex_filter_bytes_value = 10193 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10194 bytes_value, NULL); 10195 cmdline_parse_token_string_t cmd_flex_filter_mask = 10196 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10197 mask, "mask"); 10198 cmdline_parse_token_string_t cmd_flex_filter_mask_value = 10199 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10200 mask_value, NULL); 10201 cmdline_parse_token_string_t cmd_flex_filter_priority = 10202 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10203 priority, "priority"); 10204 cmdline_parse_token_num_t cmd_flex_filter_priority_value = 10205 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10206 priority_value, UINT8); 10207 cmdline_parse_token_string_t cmd_flex_filter_queue = 10208 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10209 queue, "queue"); 10210 cmdline_parse_token_num_t cmd_flex_filter_queue_id = 10211 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10212 queue_id, UINT16); 10213 cmdline_parse_inst_t cmd_flex_filter = { 10214 .f = cmd_flex_filter_parsed, 10215 .data = NULL, 10216 .help_str = "flex_filter <port_id> add|del len <value> bytes " 10217 "<value> mask <value> priority <value> queue <queue_id>: " 10218 "Add/Del a flex filter", 10219 .tokens = { 10220 (void *)&cmd_flex_filter_filter, 10221 (void *)&cmd_flex_filter_port_id, 10222 (void *)&cmd_flex_filter_ops, 10223 (void *)&cmd_flex_filter_len, 10224 (void *)&cmd_flex_filter_len_value, 10225 (void *)&cmd_flex_filter_bytes, 10226 (void *)&cmd_flex_filter_bytes_value, 10227 (void *)&cmd_flex_filter_mask, 10228 (void *)&cmd_flex_filter_mask_value, 10229 (void *)&cmd_flex_filter_priority, 10230 (void *)&cmd_flex_filter_priority_value, 10231 (void *)&cmd_flex_filter_queue, 10232 (void *)&cmd_flex_filter_queue_id, 10233 NULL, 10234 }, 10235 }; 10236 10237 /* *** Filters Control *** */ 10238 10239 /* *** deal with ethertype filter *** */ 10240 struct cmd_ethertype_filter_result { 10241 cmdline_fixed_string_t filter; 10242 portid_t port_id; 10243 cmdline_fixed_string_t ops; 10244 cmdline_fixed_string_t mac; 10245 struct ether_addr mac_addr; 10246 cmdline_fixed_string_t ethertype; 10247 uint16_t ethertype_value; 10248 cmdline_fixed_string_t drop; 10249 cmdline_fixed_string_t queue; 10250 uint16_t queue_id; 10251 }; 10252 10253 cmdline_parse_token_string_t cmd_ethertype_filter_filter = 10254 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10255 filter, "ethertype_filter"); 10256 cmdline_parse_token_num_t cmd_ethertype_filter_port_id = 10257 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10258 port_id, UINT16); 10259 cmdline_parse_token_string_t cmd_ethertype_filter_ops = 10260 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10261 ops, "add#del"); 10262 cmdline_parse_token_string_t cmd_ethertype_filter_mac = 10263 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10264 mac, "mac_addr#mac_ignr"); 10265 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr = 10266 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result, 10267 mac_addr); 10268 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype = 10269 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10270 ethertype, "ethertype"); 10271 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value = 10272 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10273 ethertype_value, UINT16); 10274 cmdline_parse_token_string_t cmd_ethertype_filter_drop = 10275 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10276 drop, "drop#fwd"); 10277 cmdline_parse_token_string_t cmd_ethertype_filter_queue = 10278 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10279 queue, "queue"); 10280 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id = 10281 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10282 queue_id, UINT16); 10283 10284 static void 10285 cmd_ethertype_filter_parsed(void *parsed_result, 10286 __attribute__((unused)) struct cmdline *cl, 10287 __attribute__((unused)) void *data) 10288 { 10289 struct cmd_ethertype_filter_result *res = parsed_result; 10290 struct rte_eth_ethertype_filter filter; 10291 int ret = 0; 10292 10293 ret = rte_eth_dev_filter_supported(res->port_id, 10294 RTE_ETH_FILTER_ETHERTYPE); 10295 if (ret < 0) { 10296 printf("ethertype filter is not supported on port %u.\n", 10297 res->port_id); 10298 return; 10299 } 10300 10301 memset(&filter, 0, sizeof(filter)); 10302 if (!strcmp(res->mac, "mac_addr")) { 10303 filter.flags |= RTE_ETHTYPE_FLAGS_MAC; 10304 rte_memcpy(&filter.mac_addr, &res->mac_addr, 10305 sizeof(struct ether_addr)); 10306 } 10307 if (!strcmp(res->drop, "drop")) 10308 filter.flags |= RTE_ETHTYPE_FLAGS_DROP; 10309 filter.ether_type = res->ethertype_value; 10310 filter.queue = res->queue_id; 10311 10312 if (!strcmp(res->ops, "add")) 10313 ret = rte_eth_dev_filter_ctrl(res->port_id, 10314 RTE_ETH_FILTER_ETHERTYPE, 10315 RTE_ETH_FILTER_ADD, 10316 &filter); 10317 else 10318 ret = rte_eth_dev_filter_ctrl(res->port_id, 10319 RTE_ETH_FILTER_ETHERTYPE, 10320 RTE_ETH_FILTER_DELETE, 10321 &filter); 10322 if (ret < 0) 10323 printf("ethertype filter programming error: (%s)\n", 10324 strerror(-ret)); 10325 } 10326 10327 cmdline_parse_inst_t cmd_ethertype_filter = { 10328 .f = cmd_ethertype_filter_parsed, 10329 .data = NULL, 10330 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr " 10331 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: " 10332 "Add or delete an ethertype filter entry", 10333 .tokens = { 10334 (void *)&cmd_ethertype_filter_filter, 10335 (void *)&cmd_ethertype_filter_port_id, 10336 (void *)&cmd_ethertype_filter_ops, 10337 (void *)&cmd_ethertype_filter_mac, 10338 (void *)&cmd_ethertype_filter_mac_addr, 10339 (void *)&cmd_ethertype_filter_ethertype, 10340 (void *)&cmd_ethertype_filter_ethertype_value, 10341 (void *)&cmd_ethertype_filter_drop, 10342 (void *)&cmd_ethertype_filter_queue, 10343 (void *)&cmd_ethertype_filter_queue_id, 10344 NULL, 10345 }, 10346 }; 10347 10348 /* *** deal with flow director filter *** */ 10349 struct cmd_flow_director_result { 10350 cmdline_fixed_string_t flow_director_filter; 10351 portid_t port_id; 10352 cmdline_fixed_string_t mode; 10353 cmdline_fixed_string_t mode_value; 10354 cmdline_fixed_string_t ops; 10355 cmdline_fixed_string_t flow; 10356 cmdline_fixed_string_t flow_type; 10357 cmdline_fixed_string_t ether; 10358 uint16_t ether_type; 10359 cmdline_fixed_string_t src; 10360 cmdline_ipaddr_t ip_src; 10361 uint16_t port_src; 10362 cmdline_fixed_string_t dst; 10363 cmdline_ipaddr_t ip_dst; 10364 uint16_t port_dst; 10365 cmdline_fixed_string_t verify_tag; 10366 uint32_t verify_tag_value; 10367 cmdline_fixed_string_t tos; 10368 uint8_t tos_value; 10369 cmdline_fixed_string_t proto; 10370 uint8_t proto_value; 10371 cmdline_fixed_string_t ttl; 10372 uint8_t ttl_value; 10373 cmdline_fixed_string_t vlan; 10374 uint16_t vlan_value; 10375 cmdline_fixed_string_t flexbytes; 10376 cmdline_fixed_string_t flexbytes_value; 10377 cmdline_fixed_string_t pf_vf; 10378 cmdline_fixed_string_t drop; 10379 cmdline_fixed_string_t queue; 10380 uint16_t queue_id; 10381 cmdline_fixed_string_t fd_id; 10382 uint32_t fd_id_value; 10383 cmdline_fixed_string_t mac; 10384 struct ether_addr mac_addr; 10385 cmdline_fixed_string_t tunnel; 10386 cmdline_fixed_string_t tunnel_type; 10387 cmdline_fixed_string_t tunnel_id; 10388 uint32_t tunnel_id_value; 10389 cmdline_fixed_string_t packet; 10390 char filepath[]; 10391 }; 10392 10393 static inline int 10394 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num) 10395 { 10396 char s[256]; 10397 const char *p, *p0 = q_arg; 10398 char *end; 10399 unsigned long int_fld; 10400 char *str_fld[max_num]; 10401 int i; 10402 unsigned size; 10403 int ret = -1; 10404 10405 p = strchr(p0, '('); 10406 if (p == NULL) 10407 return -1; 10408 ++p; 10409 p0 = strchr(p, ')'); 10410 if (p0 == NULL) 10411 return -1; 10412 10413 size = p0 - p; 10414 if (size >= sizeof(s)) 10415 return -1; 10416 10417 snprintf(s, sizeof(s), "%.*s", size, p); 10418 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 10419 if (ret < 0 || ret > max_num) 10420 return -1; 10421 for (i = 0; i < ret; i++) { 10422 errno = 0; 10423 int_fld = strtoul(str_fld[i], &end, 0); 10424 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX) 10425 return -1; 10426 flexbytes[i] = (uint8_t)int_fld; 10427 } 10428 return ret; 10429 } 10430 10431 static uint16_t 10432 str2flowtype(char *string) 10433 { 10434 uint8_t i = 0; 10435 static const struct { 10436 char str[32]; 10437 uint16_t type; 10438 } flowtype_str[] = { 10439 {"raw", RTE_ETH_FLOW_RAW}, 10440 {"ipv4", RTE_ETH_FLOW_IPV4}, 10441 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 10442 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 10443 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 10444 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 10445 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 10446 {"ipv6", RTE_ETH_FLOW_IPV6}, 10447 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 10448 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 10449 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 10450 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 10451 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 10452 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 10453 }; 10454 10455 for (i = 0; i < RTE_DIM(flowtype_str); i++) { 10456 if (!strcmp(flowtype_str[i].str, string)) 10457 return flowtype_str[i].type; 10458 } 10459 10460 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) 10461 return (uint16_t)atoi(string); 10462 10463 return RTE_ETH_FLOW_UNKNOWN; 10464 } 10465 10466 static enum rte_eth_fdir_tunnel_type 10467 str2fdir_tunneltype(char *string) 10468 { 10469 uint8_t i = 0; 10470 10471 static const struct { 10472 char str[32]; 10473 enum rte_eth_fdir_tunnel_type type; 10474 } tunneltype_str[] = { 10475 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE}, 10476 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN}, 10477 }; 10478 10479 for (i = 0; i < RTE_DIM(tunneltype_str); i++) { 10480 if (!strcmp(tunneltype_str[i].str, string)) 10481 return tunneltype_str[i].type; 10482 } 10483 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN; 10484 } 10485 10486 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \ 10487 do { \ 10488 if ((ip_addr).family == AF_INET) \ 10489 (ip) = (ip_addr).addr.ipv4.s_addr; \ 10490 else { \ 10491 printf("invalid parameter.\n"); \ 10492 return; \ 10493 } \ 10494 } while (0) 10495 10496 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \ 10497 do { \ 10498 if ((ip_addr).family == AF_INET6) \ 10499 rte_memcpy(&(ip), \ 10500 &((ip_addr).addr.ipv6), \ 10501 sizeof(struct in6_addr)); \ 10502 else { \ 10503 printf("invalid parameter.\n"); \ 10504 return; \ 10505 } \ 10506 } while (0) 10507 10508 static void 10509 cmd_flow_director_filter_parsed(void *parsed_result, 10510 __attribute__((unused)) struct cmdline *cl, 10511 __attribute__((unused)) void *data) 10512 { 10513 struct cmd_flow_director_result *res = parsed_result; 10514 struct rte_eth_fdir_filter entry; 10515 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN]; 10516 char *end; 10517 unsigned long vf_id; 10518 int ret = 0; 10519 10520 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 10521 if (ret < 0) { 10522 printf("flow director is not supported on port %u.\n", 10523 res->port_id); 10524 return; 10525 } 10526 memset(flexbytes, 0, sizeof(flexbytes)); 10527 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter)); 10528 10529 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 10530 if (strcmp(res->mode_value, "MAC-VLAN")) { 10531 printf("Please set mode to MAC-VLAN.\n"); 10532 return; 10533 } 10534 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10535 if (strcmp(res->mode_value, "Tunnel")) { 10536 printf("Please set mode to Tunnel.\n"); 10537 return; 10538 } 10539 } else { 10540 if (!strcmp(res->mode_value, "raw")) { 10541 #ifdef RTE_LIBRTE_I40E_PMD 10542 struct rte_pmd_i40e_flow_type_mapping 10543 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 10544 struct rte_pmd_i40e_pkt_template_conf conf; 10545 uint16_t flow_type = str2flowtype(res->flow_type); 10546 uint16_t i, port = res->port_id; 10547 uint8_t add; 10548 10549 memset(&conf, 0, sizeof(conf)); 10550 10551 if (flow_type == RTE_ETH_FLOW_UNKNOWN) { 10552 printf("Invalid flow type specified.\n"); 10553 return; 10554 } 10555 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, 10556 mapping); 10557 if (ret) 10558 return; 10559 if (mapping[flow_type].pctype == 0ULL) { 10560 printf("Invalid flow type specified.\n"); 10561 return; 10562 } 10563 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) { 10564 if (mapping[flow_type].pctype & (1ULL << i)) { 10565 conf.input.pctype = i; 10566 break; 10567 } 10568 } 10569 10570 conf.input.packet = open_file(res->filepath, 10571 &conf.input.length); 10572 if (!conf.input.packet) 10573 return; 10574 if (!strcmp(res->drop, "drop")) 10575 conf.action.behavior = 10576 RTE_PMD_I40E_PKT_TEMPLATE_REJECT; 10577 else 10578 conf.action.behavior = 10579 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT; 10580 conf.action.report_status = 10581 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID; 10582 conf.action.rx_queue = res->queue_id; 10583 conf.soft_id = res->fd_id_value; 10584 add = strcmp(res->ops, "del") ? 1 : 0; 10585 ret = rte_pmd_i40e_flow_add_del_packet_template(port, 10586 &conf, 10587 add); 10588 if (ret < 0) 10589 printf("flow director config error: (%s)\n", 10590 strerror(-ret)); 10591 close_file(conf.input.packet); 10592 #endif 10593 return; 10594 } else if (strcmp(res->mode_value, "IP")) { 10595 printf("Please set mode to IP or raw.\n"); 10596 return; 10597 } 10598 entry.input.flow_type = str2flowtype(res->flow_type); 10599 } 10600 10601 ret = parse_flexbytes(res->flexbytes_value, 10602 flexbytes, 10603 RTE_ETH_FDIR_MAX_FLEXLEN); 10604 if (ret < 0) { 10605 printf("error: Cannot parse flexbytes input.\n"); 10606 return; 10607 } 10608 10609 switch (entry.input.flow_type) { 10610 case RTE_ETH_FLOW_FRAG_IPV4: 10611 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: 10612 entry.input.flow.ip4_flow.proto = res->proto_value; 10613 /* fall-through */ 10614 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP: 10615 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP: 10616 IPV4_ADDR_TO_UINT(res->ip_dst, 10617 entry.input.flow.ip4_flow.dst_ip); 10618 IPV4_ADDR_TO_UINT(res->ip_src, 10619 entry.input.flow.ip4_flow.src_ip); 10620 entry.input.flow.ip4_flow.tos = res->tos_value; 10621 entry.input.flow.ip4_flow.ttl = res->ttl_value; 10622 /* need convert to big endian. */ 10623 entry.input.flow.udp4_flow.dst_port = 10624 rte_cpu_to_be_16(res->port_dst); 10625 entry.input.flow.udp4_flow.src_port = 10626 rte_cpu_to_be_16(res->port_src); 10627 break; 10628 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: 10629 IPV4_ADDR_TO_UINT(res->ip_dst, 10630 entry.input.flow.sctp4_flow.ip.dst_ip); 10631 IPV4_ADDR_TO_UINT(res->ip_src, 10632 entry.input.flow.sctp4_flow.ip.src_ip); 10633 entry.input.flow.ip4_flow.tos = res->tos_value; 10634 entry.input.flow.ip4_flow.ttl = res->ttl_value; 10635 /* need convert to big endian. */ 10636 entry.input.flow.sctp4_flow.dst_port = 10637 rte_cpu_to_be_16(res->port_dst); 10638 entry.input.flow.sctp4_flow.src_port = 10639 rte_cpu_to_be_16(res->port_src); 10640 entry.input.flow.sctp4_flow.verify_tag = 10641 rte_cpu_to_be_32(res->verify_tag_value); 10642 break; 10643 case RTE_ETH_FLOW_FRAG_IPV6: 10644 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: 10645 entry.input.flow.ipv6_flow.proto = res->proto_value; 10646 /* fall-through */ 10647 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP: 10648 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP: 10649 IPV6_ADDR_TO_ARRAY(res->ip_dst, 10650 entry.input.flow.ipv6_flow.dst_ip); 10651 IPV6_ADDR_TO_ARRAY(res->ip_src, 10652 entry.input.flow.ipv6_flow.src_ip); 10653 entry.input.flow.ipv6_flow.tc = res->tos_value; 10654 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 10655 /* need convert to big endian. */ 10656 entry.input.flow.udp6_flow.dst_port = 10657 rte_cpu_to_be_16(res->port_dst); 10658 entry.input.flow.udp6_flow.src_port = 10659 rte_cpu_to_be_16(res->port_src); 10660 break; 10661 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: 10662 IPV6_ADDR_TO_ARRAY(res->ip_dst, 10663 entry.input.flow.sctp6_flow.ip.dst_ip); 10664 IPV6_ADDR_TO_ARRAY(res->ip_src, 10665 entry.input.flow.sctp6_flow.ip.src_ip); 10666 entry.input.flow.ipv6_flow.tc = res->tos_value; 10667 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 10668 /* need convert to big endian. */ 10669 entry.input.flow.sctp6_flow.dst_port = 10670 rte_cpu_to_be_16(res->port_dst); 10671 entry.input.flow.sctp6_flow.src_port = 10672 rte_cpu_to_be_16(res->port_src); 10673 entry.input.flow.sctp6_flow.verify_tag = 10674 rte_cpu_to_be_32(res->verify_tag_value); 10675 break; 10676 case RTE_ETH_FLOW_L2_PAYLOAD: 10677 entry.input.flow.l2_flow.ether_type = 10678 rte_cpu_to_be_16(res->ether_type); 10679 break; 10680 default: 10681 break; 10682 } 10683 10684 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) 10685 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr, 10686 &res->mac_addr, 10687 sizeof(struct ether_addr)); 10688 10689 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10690 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr, 10691 &res->mac_addr, 10692 sizeof(struct ether_addr)); 10693 entry.input.flow.tunnel_flow.tunnel_type = 10694 str2fdir_tunneltype(res->tunnel_type); 10695 entry.input.flow.tunnel_flow.tunnel_id = 10696 rte_cpu_to_be_32(res->tunnel_id_value); 10697 } 10698 10699 rte_memcpy(entry.input.flow_ext.flexbytes, 10700 flexbytes, 10701 RTE_ETH_FDIR_MAX_FLEXLEN); 10702 10703 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value); 10704 10705 entry.action.flex_off = 0; /*use 0 by default */ 10706 if (!strcmp(res->drop, "drop")) 10707 entry.action.behavior = RTE_ETH_FDIR_REJECT; 10708 else 10709 entry.action.behavior = RTE_ETH_FDIR_ACCEPT; 10710 10711 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN && 10712 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) { 10713 if (!strcmp(res->pf_vf, "pf")) 10714 entry.input.flow_ext.is_vf = 0; 10715 else if (!strncmp(res->pf_vf, "vf", 2)) { 10716 struct rte_eth_dev_info dev_info; 10717 10718 memset(&dev_info, 0, sizeof(dev_info)); 10719 rte_eth_dev_info_get(res->port_id, &dev_info); 10720 errno = 0; 10721 vf_id = strtoul(res->pf_vf + 2, &end, 10); 10722 if (errno != 0 || *end != '\0' || 10723 vf_id >= dev_info.max_vfs) { 10724 printf("invalid parameter %s.\n", res->pf_vf); 10725 return; 10726 } 10727 entry.input.flow_ext.is_vf = 1; 10728 entry.input.flow_ext.dst_id = (uint16_t)vf_id; 10729 } else { 10730 printf("invalid parameter %s.\n", res->pf_vf); 10731 return; 10732 } 10733 } 10734 10735 /* set to report FD ID by default */ 10736 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID; 10737 entry.action.rx_queue = res->queue_id; 10738 entry.soft_id = res->fd_id_value; 10739 if (!strcmp(res->ops, "add")) 10740 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10741 RTE_ETH_FILTER_ADD, &entry); 10742 else if (!strcmp(res->ops, "del")) 10743 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10744 RTE_ETH_FILTER_DELETE, &entry); 10745 else 10746 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10747 RTE_ETH_FILTER_UPDATE, &entry); 10748 if (ret < 0) 10749 printf("flow director programming error: (%s)\n", 10750 strerror(-ret)); 10751 } 10752 10753 cmdline_parse_token_string_t cmd_flow_director_filter = 10754 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10755 flow_director_filter, "flow_director_filter"); 10756 cmdline_parse_token_num_t cmd_flow_director_port_id = 10757 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10758 port_id, UINT16); 10759 cmdline_parse_token_string_t cmd_flow_director_ops = 10760 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10761 ops, "add#del#update"); 10762 cmdline_parse_token_string_t cmd_flow_director_flow = 10763 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10764 flow, "flow"); 10765 cmdline_parse_token_string_t cmd_flow_director_flow_type = 10766 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10767 flow_type, NULL); 10768 cmdline_parse_token_string_t cmd_flow_director_ether = 10769 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10770 ether, "ether"); 10771 cmdline_parse_token_num_t cmd_flow_director_ether_type = 10772 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10773 ether_type, UINT16); 10774 cmdline_parse_token_string_t cmd_flow_director_src = 10775 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10776 src, "src"); 10777 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src = 10778 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 10779 ip_src); 10780 cmdline_parse_token_num_t cmd_flow_director_port_src = 10781 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10782 port_src, UINT16); 10783 cmdline_parse_token_string_t cmd_flow_director_dst = 10784 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10785 dst, "dst"); 10786 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst = 10787 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 10788 ip_dst); 10789 cmdline_parse_token_num_t cmd_flow_director_port_dst = 10790 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10791 port_dst, UINT16); 10792 cmdline_parse_token_string_t cmd_flow_director_verify_tag = 10793 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10794 verify_tag, "verify_tag"); 10795 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value = 10796 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10797 verify_tag_value, UINT32); 10798 cmdline_parse_token_string_t cmd_flow_director_tos = 10799 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10800 tos, "tos"); 10801 cmdline_parse_token_num_t cmd_flow_director_tos_value = 10802 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10803 tos_value, UINT8); 10804 cmdline_parse_token_string_t cmd_flow_director_proto = 10805 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10806 proto, "proto"); 10807 cmdline_parse_token_num_t cmd_flow_director_proto_value = 10808 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10809 proto_value, UINT8); 10810 cmdline_parse_token_string_t cmd_flow_director_ttl = 10811 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10812 ttl, "ttl"); 10813 cmdline_parse_token_num_t cmd_flow_director_ttl_value = 10814 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10815 ttl_value, UINT8); 10816 cmdline_parse_token_string_t cmd_flow_director_vlan = 10817 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10818 vlan, "vlan"); 10819 cmdline_parse_token_num_t cmd_flow_director_vlan_value = 10820 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10821 vlan_value, UINT16); 10822 cmdline_parse_token_string_t cmd_flow_director_flexbytes = 10823 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10824 flexbytes, "flexbytes"); 10825 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value = 10826 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10827 flexbytes_value, NULL); 10828 cmdline_parse_token_string_t cmd_flow_director_drop = 10829 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10830 drop, "drop#fwd"); 10831 cmdline_parse_token_string_t cmd_flow_director_pf_vf = 10832 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10833 pf_vf, NULL); 10834 cmdline_parse_token_string_t cmd_flow_director_queue = 10835 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10836 queue, "queue"); 10837 cmdline_parse_token_num_t cmd_flow_director_queue_id = 10838 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10839 queue_id, UINT16); 10840 cmdline_parse_token_string_t cmd_flow_director_fd_id = 10841 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10842 fd_id, "fd_id"); 10843 cmdline_parse_token_num_t cmd_flow_director_fd_id_value = 10844 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10845 fd_id_value, UINT32); 10846 10847 cmdline_parse_token_string_t cmd_flow_director_mode = 10848 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10849 mode, "mode"); 10850 cmdline_parse_token_string_t cmd_flow_director_mode_ip = 10851 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10852 mode_value, "IP"); 10853 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan = 10854 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10855 mode_value, "MAC-VLAN"); 10856 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel = 10857 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10858 mode_value, "Tunnel"); 10859 cmdline_parse_token_string_t cmd_flow_director_mode_raw = 10860 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10861 mode_value, "raw"); 10862 cmdline_parse_token_string_t cmd_flow_director_mac = 10863 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10864 mac, "mac"); 10865 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr = 10866 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result, 10867 mac_addr); 10868 cmdline_parse_token_string_t cmd_flow_director_tunnel = 10869 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10870 tunnel, "tunnel"); 10871 cmdline_parse_token_string_t cmd_flow_director_tunnel_type = 10872 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10873 tunnel_type, "NVGRE#VxLAN"); 10874 cmdline_parse_token_string_t cmd_flow_director_tunnel_id = 10875 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10876 tunnel_id, "tunnel-id"); 10877 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value = 10878 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10879 tunnel_id_value, UINT32); 10880 cmdline_parse_token_string_t cmd_flow_director_packet = 10881 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10882 packet, "packet"); 10883 cmdline_parse_token_string_t cmd_flow_director_filepath = 10884 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10885 filepath, NULL); 10886 10887 cmdline_parse_inst_t cmd_add_del_ip_flow_director = { 10888 .f = cmd_flow_director_filter_parsed, 10889 .data = NULL, 10890 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow" 10891 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 10892 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|" 10893 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> " 10894 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> " 10895 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> " 10896 "fd_id <fd_id_value>: " 10897 "Add or delete an ip flow director entry on NIC", 10898 .tokens = { 10899 (void *)&cmd_flow_director_filter, 10900 (void *)&cmd_flow_director_port_id, 10901 (void *)&cmd_flow_director_mode, 10902 (void *)&cmd_flow_director_mode_ip, 10903 (void *)&cmd_flow_director_ops, 10904 (void *)&cmd_flow_director_flow, 10905 (void *)&cmd_flow_director_flow_type, 10906 (void *)&cmd_flow_director_src, 10907 (void *)&cmd_flow_director_ip_src, 10908 (void *)&cmd_flow_director_dst, 10909 (void *)&cmd_flow_director_ip_dst, 10910 (void *)&cmd_flow_director_tos, 10911 (void *)&cmd_flow_director_tos_value, 10912 (void *)&cmd_flow_director_proto, 10913 (void *)&cmd_flow_director_proto_value, 10914 (void *)&cmd_flow_director_ttl, 10915 (void *)&cmd_flow_director_ttl_value, 10916 (void *)&cmd_flow_director_vlan, 10917 (void *)&cmd_flow_director_vlan_value, 10918 (void *)&cmd_flow_director_flexbytes, 10919 (void *)&cmd_flow_director_flexbytes_value, 10920 (void *)&cmd_flow_director_drop, 10921 (void *)&cmd_flow_director_pf_vf, 10922 (void *)&cmd_flow_director_queue, 10923 (void *)&cmd_flow_director_queue_id, 10924 (void *)&cmd_flow_director_fd_id, 10925 (void *)&cmd_flow_director_fd_id_value, 10926 NULL, 10927 }, 10928 }; 10929 10930 cmdline_parse_inst_t cmd_add_del_udp_flow_director = { 10931 .f = cmd_flow_director_filter_parsed, 10932 .data = NULL, 10933 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow " 10934 "director entry on NIC", 10935 .tokens = { 10936 (void *)&cmd_flow_director_filter, 10937 (void *)&cmd_flow_director_port_id, 10938 (void *)&cmd_flow_director_mode, 10939 (void *)&cmd_flow_director_mode_ip, 10940 (void *)&cmd_flow_director_ops, 10941 (void *)&cmd_flow_director_flow, 10942 (void *)&cmd_flow_director_flow_type, 10943 (void *)&cmd_flow_director_src, 10944 (void *)&cmd_flow_director_ip_src, 10945 (void *)&cmd_flow_director_port_src, 10946 (void *)&cmd_flow_director_dst, 10947 (void *)&cmd_flow_director_ip_dst, 10948 (void *)&cmd_flow_director_port_dst, 10949 (void *)&cmd_flow_director_tos, 10950 (void *)&cmd_flow_director_tos_value, 10951 (void *)&cmd_flow_director_ttl, 10952 (void *)&cmd_flow_director_ttl_value, 10953 (void *)&cmd_flow_director_vlan, 10954 (void *)&cmd_flow_director_vlan_value, 10955 (void *)&cmd_flow_director_flexbytes, 10956 (void *)&cmd_flow_director_flexbytes_value, 10957 (void *)&cmd_flow_director_drop, 10958 (void *)&cmd_flow_director_pf_vf, 10959 (void *)&cmd_flow_director_queue, 10960 (void *)&cmd_flow_director_queue_id, 10961 (void *)&cmd_flow_director_fd_id, 10962 (void *)&cmd_flow_director_fd_id_value, 10963 NULL, 10964 }, 10965 }; 10966 10967 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = { 10968 .f = cmd_flow_director_filter_parsed, 10969 .data = NULL, 10970 .help_str = "flow_director_filter ... : Add or delete a sctp flow " 10971 "director entry on NIC", 10972 .tokens = { 10973 (void *)&cmd_flow_director_filter, 10974 (void *)&cmd_flow_director_port_id, 10975 (void *)&cmd_flow_director_mode, 10976 (void *)&cmd_flow_director_mode_ip, 10977 (void *)&cmd_flow_director_ops, 10978 (void *)&cmd_flow_director_flow, 10979 (void *)&cmd_flow_director_flow_type, 10980 (void *)&cmd_flow_director_src, 10981 (void *)&cmd_flow_director_ip_src, 10982 (void *)&cmd_flow_director_port_src, 10983 (void *)&cmd_flow_director_dst, 10984 (void *)&cmd_flow_director_ip_dst, 10985 (void *)&cmd_flow_director_port_dst, 10986 (void *)&cmd_flow_director_verify_tag, 10987 (void *)&cmd_flow_director_verify_tag_value, 10988 (void *)&cmd_flow_director_tos, 10989 (void *)&cmd_flow_director_tos_value, 10990 (void *)&cmd_flow_director_ttl, 10991 (void *)&cmd_flow_director_ttl_value, 10992 (void *)&cmd_flow_director_vlan, 10993 (void *)&cmd_flow_director_vlan_value, 10994 (void *)&cmd_flow_director_flexbytes, 10995 (void *)&cmd_flow_director_flexbytes_value, 10996 (void *)&cmd_flow_director_drop, 10997 (void *)&cmd_flow_director_pf_vf, 10998 (void *)&cmd_flow_director_queue, 10999 (void *)&cmd_flow_director_queue_id, 11000 (void *)&cmd_flow_director_fd_id, 11001 (void *)&cmd_flow_director_fd_id_value, 11002 NULL, 11003 }, 11004 }; 11005 11006 cmdline_parse_inst_t cmd_add_del_l2_flow_director = { 11007 .f = cmd_flow_director_filter_parsed, 11008 .data = NULL, 11009 .help_str = "flow_director_filter ... : Add or delete a L2 flow " 11010 "director entry on NIC", 11011 .tokens = { 11012 (void *)&cmd_flow_director_filter, 11013 (void *)&cmd_flow_director_port_id, 11014 (void *)&cmd_flow_director_mode, 11015 (void *)&cmd_flow_director_mode_ip, 11016 (void *)&cmd_flow_director_ops, 11017 (void *)&cmd_flow_director_flow, 11018 (void *)&cmd_flow_director_flow_type, 11019 (void *)&cmd_flow_director_ether, 11020 (void *)&cmd_flow_director_ether_type, 11021 (void *)&cmd_flow_director_flexbytes, 11022 (void *)&cmd_flow_director_flexbytes_value, 11023 (void *)&cmd_flow_director_drop, 11024 (void *)&cmd_flow_director_pf_vf, 11025 (void *)&cmd_flow_director_queue, 11026 (void *)&cmd_flow_director_queue_id, 11027 (void *)&cmd_flow_director_fd_id, 11028 (void *)&cmd_flow_director_fd_id_value, 11029 NULL, 11030 }, 11031 }; 11032 11033 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = { 11034 .f = cmd_flow_director_filter_parsed, 11035 .data = NULL, 11036 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow " 11037 "director entry on NIC", 11038 .tokens = { 11039 (void *)&cmd_flow_director_filter, 11040 (void *)&cmd_flow_director_port_id, 11041 (void *)&cmd_flow_director_mode, 11042 (void *)&cmd_flow_director_mode_mac_vlan, 11043 (void *)&cmd_flow_director_ops, 11044 (void *)&cmd_flow_director_mac, 11045 (void *)&cmd_flow_director_mac_addr, 11046 (void *)&cmd_flow_director_vlan, 11047 (void *)&cmd_flow_director_vlan_value, 11048 (void *)&cmd_flow_director_flexbytes, 11049 (void *)&cmd_flow_director_flexbytes_value, 11050 (void *)&cmd_flow_director_drop, 11051 (void *)&cmd_flow_director_queue, 11052 (void *)&cmd_flow_director_queue_id, 11053 (void *)&cmd_flow_director_fd_id, 11054 (void *)&cmd_flow_director_fd_id_value, 11055 NULL, 11056 }, 11057 }; 11058 11059 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = { 11060 .f = cmd_flow_director_filter_parsed, 11061 .data = NULL, 11062 .help_str = "flow_director_filter ... : Add or delete a tunnel flow " 11063 "director entry on NIC", 11064 .tokens = { 11065 (void *)&cmd_flow_director_filter, 11066 (void *)&cmd_flow_director_port_id, 11067 (void *)&cmd_flow_director_mode, 11068 (void *)&cmd_flow_director_mode_tunnel, 11069 (void *)&cmd_flow_director_ops, 11070 (void *)&cmd_flow_director_mac, 11071 (void *)&cmd_flow_director_mac_addr, 11072 (void *)&cmd_flow_director_vlan, 11073 (void *)&cmd_flow_director_vlan_value, 11074 (void *)&cmd_flow_director_tunnel, 11075 (void *)&cmd_flow_director_tunnel_type, 11076 (void *)&cmd_flow_director_tunnel_id, 11077 (void *)&cmd_flow_director_tunnel_id_value, 11078 (void *)&cmd_flow_director_flexbytes, 11079 (void *)&cmd_flow_director_flexbytes_value, 11080 (void *)&cmd_flow_director_drop, 11081 (void *)&cmd_flow_director_queue, 11082 (void *)&cmd_flow_director_queue_id, 11083 (void *)&cmd_flow_director_fd_id, 11084 (void *)&cmd_flow_director_fd_id_value, 11085 NULL, 11086 }, 11087 }; 11088 11089 cmdline_parse_inst_t cmd_add_del_raw_flow_director = { 11090 .f = cmd_flow_director_filter_parsed, 11091 .data = NULL, 11092 .help_str = "flow_director_filter ... : Add or delete a raw flow " 11093 "director entry on NIC", 11094 .tokens = { 11095 (void *)&cmd_flow_director_filter, 11096 (void *)&cmd_flow_director_port_id, 11097 (void *)&cmd_flow_director_mode, 11098 (void *)&cmd_flow_director_mode_raw, 11099 (void *)&cmd_flow_director_ops, 11100 (void *)&cmd_flow_director_flow, 11101 (void *)&cmd_flow_director_flow_type, 11102 (void *)&cmd_flow_director_drop, 11103 (void *)&cmd_flow_director_queue, 11104 (void *)&cmd_flow_director_queue_id, 11105 (void *)&cmd_flow_director_fd_id, 11106 (void *)&cmd_flow_director_fd_id_value, 11107 (void *)&cmd_flow_director_packet, 11108 (void *)&cmd_flow_director_filepath, 11109 NULL, 11110 }, 11111 }; 11112 11113 struct cmd_flush_flow_director_result { 11114 cmdline_fixed_string_t flush_flow_director; 11115 portid_t port_id; 11116 }; 11117 11118 cmdline_parse_token_string_t cmd_flush_flow_director_flush = 11119 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result, 11120 flush_flow_director, "flush_flow_director"); 11121 cmdline_parse_token_num_t cmd_flush_flow_director_port_id = 11122 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result, 11123 port_id, UINT16); 11124 11125 static void 11126 cmd_flush_flow_director_parsed(void *parsed_result, 11127 __attribute__((unused)) struct cmdline *cl, 11128 __attribute__((unused)) void *data) 11129 { 11130 struct cmd_flow_director_result *res = parsed_result; 11131 int ret = 0; 11132 11133 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 11134 if (ret < 0) { 11135 printf("flow director is not supported on port %u.\n", 11136 res->port_id); 11137 return; 11138 } 11139 11140 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11141 RTE_ETH_FILTER_FLUSH, NULL); 11142 if (ret < 0) 11143 printf("flow director table flushing error: (%s)\n", 11144 strerror(-ret)); 11145 } 11146 11147 cmdline_parse_inst_t cmd_flush_flow_director = { 11148 .f = cmd_flush_flow_director_parsed, 11149 .data = NULL, 11150 .help_str = "flush_flow_director <port_id>: " 11151 "Flush all flow director entries of a device on NIC", 11152 .tokens = { 11153 (void *)&cmd_flush_flow_director_flush, 11154 (void *)&cmd_flush_flow_director_port_id, 11155 NULL, 11156 }, 11157 }; 11158 11159 /* *** deal with flow director mask *** */ 11160 struct cmd_flow_director_mask_result { 11161 cmdline_fixed_string_t flow_director_mask; 11162 portid_t port_id; 11163 cmdline_fixed_string_t mode; 11164 cmdline_fixed_string_t mode_value; 11165 cmdline_fixed_string_t vlan; 11166 uint16_t vlan_mask; 11167 cmdline_fixed_string_t src_mask; 11168 cmdline_ipaddr_t ipv4_src; 11169 cmdline_ipaddr_t ipv6_src; 11170 uint16_t port_src; 11171 cmdline_fixed_string_t dst_mask; 11172 cmdline_ipaddr_t ipv4_dst; 11173 cmdline_ipaddr_t ipv6_dst; 11174 uint16_t port_dst; 11175 cmdline_fixed_string_t mac; 11176 uint8_t mac_addr_byte_mask; 11177 cmdline_fixed_string_t tunnel_id; 11178 uint32_t tunnel_id_mask; 11179 cmdline_fixed_string_t tunnel_type; 11180 uint8_t tunnel_type_mask; 11181 }; 11182 11183 static void 11184 cmd_flow_director_mask_parsed(void *parsed_result, 11185 __attribute__((unused)) struct cmdline *cl, 11186 __attribute__((unused)) void *data) 11187 { 11188 struct cmd_flow_director_mask_result *res = parsed_result; 11189 struct rte_eth_fdir_masks *mask; 11190 struct rte_port *port; 11191 11192 port = &ports[res->port_id]; 11193 /** Check if the port is not started **/ 11194 if (port->port_status != RTE_PORT_STOPPED) { 11195 printf("Please stop port %d first\n", res->port_id); 11196 return; 11197 } 11198 11199 mask = &port->dev_conf.fdir_conf.mask; 11200 11201 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 11202 if (strcmp(res->mode_value, "MAC-VLAN")) { 11203 printf("Please set mode to MAC-VLAN.\n"); 11204 return; 11205 } 11206 11207 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11208 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 11209 if (strcmp(res->mode_value, "Tunnel")) { 11210 printf("Please set mode to Tunnel.\n"); 11211 return; 11212 } 11213 11214 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11215 mask->mac_addr_byte_mask = res->mac_addr_byte_mask; 11216 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask); 11217 mask->tunnel_type_mask = res->tunnel_type_mask; 11218 } else { 11219 if (strcmp(res->mode_value, "IP")) { 11220 printf("Please set mode to IP.\n"); 11221 return; 11222 } 11223 11224 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11225 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip); 11226 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip); 11227 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip); 11228 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip); 11229 mask->src_port_mask = rte_cpu_to_be_16(res->port_src); 11230 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst); 11231 } 11232 11233 cmd_reconfig_device_queue(res->port_id, 1, 1); 11234 } 11235 11236 cmdline_parse_token_string_t cmd_flow_director_mask = 11237 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11238 flow_director_mask, "flow_director_mask"); 11239 cmdline_parse_token_num_t cmd_flow_director_mask_port_id = 11240 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11241 port_id, UINT16); 11242 cmdline_parse_token_string_t cmd_flow_director_mask_vlan = 11243 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11244 vlan, "vlan"); 11245 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value = 11246 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11247 vlan_mask, UINT16); 11248 cmdline_parse_token_string_t cmd_flow_director_mask_src = 11249 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11250 src_mask, "src_mask"); 11251 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src = 11252 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11253 ipv4_src); 11254 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src = 11255 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11256 ipv6_src); 11257 cmdline_parse_token_num_t cmd_flow_director_mask_port_src = 11258 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11259 port_src, UINT16); 11260 cmdline_parse_token_string_t cmd_flow_director_mask_dst = 11261 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11262 dst_mask, "dst_mask"); 11263 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst = 11264 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11265 ipv4_dst); 11266 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst = 11267 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11268 ipv6_dst); 11269 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst = 11270 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11271 port_dst, UINT16); 11272 11273 cmdline_parse_token_string_t cmd_flow_director_mask_mode = 11274 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11275 mode, "mode"); 11276 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip = 11277 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11278 mode_value, "IP"); 11279 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan = 11280 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11281 mode_value, "MAC-VLAN"); 11282 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel = 11283 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11284 mode_value, "Tunnel"); 11285 cmdline_parse_token_string_t cmd_flow_director_mask_mac = 11286 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11287 mac, "mac"); 11288 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value = 11289 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11290 mac_addr_byte_mask, UINT8); 11291 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type = 11292 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11293 tunnel_type, "tunnel-type"); 11294 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value = 11295 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11296 tunnel_type_mask, UINT8); 11297 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id = 11298 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11299 tunnel_id, "tunnel-id"); 11300 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value = 11301 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11302 tunnel_id_mask, UINT32); 11303 11304 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = { 11305 .f = cmd_flow_director_mask_parsed, 11306 .data = NULL, 11307 .help_str = "flow_director_mask ... : " 11308 "Set IP mode flow director's mask on NIC", 11309 .tokens = { 11310 (void *)&cmd_flow_director_mask, 11311 (void *)&cmd_flow_director_mask_port_id, 11312 (void *)&cmd_flow_director_mask_mode, 11313 (void *)&cmd_flow_director_mask_mode_ip, 11314 (void *)&cmd_flow_director_mask_vlan, 11315 (void *)&cmd_flow_director_mask_vlan_value, 11316 (void *)&cmd_flow_director_mask_src, 11317 (void *)&cmd_flow_director_mask_ipv4_src, 11318 (void *)&cmd_flow_director_mask_ipv6_src, 11319 (void *)&cmd_flow_director_mask_port_src, 11320 (void *)&cmd_flow_director_mask_dst, 11321 (void *)&cmd_flow_director_mask_ipv4_dst, 11322 (void *)&cmd_flow_director_mask_ipv6_dst, 11323 (void *)&cmd_flow_director_mask_port_dst, 11324 NULL, 11325 }, 11326 }; 11327 11328 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = { 11329 .f = cmd_flow_director_mask_parsed, 11330 .data = NULL, 11331 .help_str = "flow_director_mask ... : Set MAC VLAN mode " 11332 "flow director's mask on NIC", 11333 .tokens = { 11334 (void *)&cmd_flow_director_mask, 11335 (void *)&cmd_flow_director_mask_port_id, 11336 (void *)&cmd_flow_director_mask_mode, 11337 (void *)&cmd_flow_director_mask_mode_mac_vlan, 11338 (void *)&cmd_flow_director_mask_vlan, 11339 (void *)&cmd_flow_director_mask_vlan_value, 11340 NULL, 11341 }, 11342 }; 11343 11344 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = { 11345 .f = cmd_flow_director_mask_parsed, 11346 .data = NULL, 11347 .help_str = "flow_director_mask ... : Set tunnel mode " 11348 "flow director's mask on NIC", 11349 .tokens = { 11350 (void *)&cmd_flow_director_mask, 11351 (void *)&cmd_flow_director_mask_port_id, 11352 (void *)&cmd_flow_director_mask_mode, 11353 (void *)&cmd_flow_director_mask_mode_tunnel, 11354 (void *)&cmd_flow_director_mask_vlan, 11355 (void *)&cmd_flow_director_mask_vlan_value, 11356 (void *)&cmd_flow_director_mask_mac, 11357 (void *)&cmd_flow_director_mask_mac_value, 11358 (void *)&cmd_flow_director_mask_tunnel_type, 11359 (void *)&cmd_flow_director_mask_tunnel_type_value, 11360 (void *)&cmd_flow_director_mask_tunnel_id, 11361 (void *)&cmd_flow_director_mask_tunnel_id_value, 11362 NULL, 11363 }, 11364 }; 11365 11366 /* *** deal with flow director mask on flexible payload *** */ 11367 struct cmd_flow_director_flex_mask_result { 11368 cmdline_fixed_string_t flow_director_flexmask; 11369 portid_t port_id; 11370 cmdline_fixed_string_t flow; 11371 cmdline_fixed_string_t flow_type; 11372 cmdline_fixed_string_t mask; 11373 }; 11374 11375 static void 11376 cmd_flow_director_flex_mask_parsed(void *parsed_result, 11377 __attribute__((unused)) struct cmdline *cl, 11378 __attribute__((unused)) void *data) 11379 { 11380 struct cmd_flow_director_flex_mask_result *res = parsed_result; 11381 struct rte_eth_fdir_info fdir_info; 11382 struct rte_eth_fdir_flex_mask flex_mask; 11383 struct rte_port *port; 11384 uint64_t flow_type_mask; 11385 uint16_t i; 11386 int ret; 11387 11388 port = &ports[res->port_id]; 11389 /** Check if the port is not started **/ 11390 if (port->port_status != RTE_PORT_STOPPED) { 11391 printf("Please stop port %d first\n", res->port_id); 11392 return; 11393 } 11394 11395 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask)); 11396 ret = parse_flexbytes(res->mask, 11397 flex_mask.mask, 11398 RTE_ETH_FDIR_MAX_FLEXLEN); 11399 if (ret < 0) { 11400 printf("error: Cannot parse mask input.\n"); 11401 return; 11402 } 11403 11404 memset(&fdir_info, 0, sizeof(fdir_info)); 11405 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11406 RTE_ETH_FILTER_INFO, &fdir_info); 11407 if (ret < 0) { 11408 printf("Cannot get FDir filter info\n"); 11409 return; 11410 } 11411 11412 if (!strcmp(res->flow_type, "none")) { 11413 /* means don't specify the flow type */ 11414 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN; 11415 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) 11416 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i], 11417 0, sizeof(struct rte_eth_fdir_flex_mask)); 11418 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1; 11419 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0], 11420 &flex_mask, 11421 sizeof(struct rte_eth_fdir_flex_mask)); 11422 cmd_reconfig_device_queue(res->port_id, 1, 1); 11423 return; 11424 } 11425 flow_type_mask = fdir_info.flow_types_mask[0]; 11426 if (!strcmp(res->flow_type, "all")) { 11427 if (!flow_type_mask) { 11428 printf("No flow type supported\n"); 11429 return; 11430 } 11431 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) { 11432 if (flow_type_mask & (1ULL << i)) { 11433 flex_mask.flow_type = i; 11434 fdir_set_flex_mask(res->port_id, &flex_mask); 11435 } 11436 } 11437 cmd_reconfig_device_queue(res->port_id, 1, 1); 11438 return; 11439 } 11440 flex_mask.flow_type = str2flowtype(res->flow_type); 11441 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) { 11442 printf("Flow type %s not supported on port %d\n", 11443 res->flow_type, res->port_id); 11444 return; 11445 } 11446 fdir_set_flex_mask(res->port_id, &flex_mask); 11447 cmd_reconfig_device_queue(res->port_id, 1, 1); 11448 } 11449 11450 cmdline_parse_token_string_t cmd_flow_director_flexmask = 11451 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11452 flow_director_flexmask, 11453 "flow_director_flex_mask"); 11454 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id = 11455 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11456 port_id, UINT16); 11457 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow = 11458 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11459 flow, "flow"); 11460 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type = 11461 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11462 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 11463 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all"); 11464 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask = 11465 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11466 mask, NULL); 11467 11468 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = { 11469 .f = cmd_flow_director_flex_mask_parsed, 11470 .data = NULL, 11471 .help_str = "flow_director_flex_mask ... : " 11472 "Set flow director's flex mask on NIC", 11473 .tokens = { 11474 (void *)&cmd_flow_director_flexmask, 11475 (void *)&cmd_flow_director_flexmask_port_id, 11476 (void *)&cmd_flow_director_flexmask_flow, 11477 (void *)&cmd_flow_director_flexmask_flow_type, 11478 (void *)&cmd_flow_director_flexmask_mask, 11479 NULL, 11480 }, 11481 }; 11482 11483 /* *** deal with flow director flexible payload configuration *** */ 11484 struct cmd_flow_director_flexpayload_result { 11485 cmdline_fixed_string_t flow_director_flexpayload; 11486 portid_t port_id; 11487 cmdline_fixed_string_t payload_layer; 11488 cmdline_fixed_string_t payload_cfg; 11489 }; 11490 11491 static inline int 11492 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num) 11493 { 11494 char s[256]; 11495 const char *p, *p0 = q_arg; 11496 char *end; 11497 unsigned long int_fld; 11498 char *str_fld[max_num]; 11499 int i; 11500 unsigned size; 11501 int ret = -1; 11502 11503 p = strchr(p0, '('); 11504 if (p == NULL) 11505 return -1; 11506 ++p; 11507 p0 = strchr(p, ')'); 11508 if (p0 == NULL) 11509 return -1; 11510 11511 size = p0 - p; 11512 if (size >= sizeof(s)) 11513 return -1; 11514 11515 snprintf(s, sizeof(s), "%.*s", size, p); 11516 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 11517 if (ret < 0 || ret > max_num) 11518 return -1; 11519 for (i = 0; i < ret; i++) { 11520 errno = 0; 11521 int_fld = strtoul(str_fld[i], &end, 0); 11522 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX) 11523 return -1; 11524 offsets[i] = (uint16_t)int_fld; 11525 } 11526 return ret; 11527 } 11528 11529 static void 11530 cmd_flow_director_flxpld_parsed(void *parsed_result, 11531 __attribute__((unused)) struct cmdline *cl, 11532 __attribute__((unused)) void *data) 11533 { 11534 struct cmd_flow_director_flexpayload_result *res = parsed_result; 11535 struct rte_eth_flex_payload_cfg flex_cfg; 11536 struct rte_port *port; 11537 int ret = 0; 11538 11539 port = &ports[res->port_id]; 11540 /** Check if the port is not started **/ 11541 if (port->port_status != RTE_PORT_STOPPED) { 11542 printf("Please stop port %d first\n", res->port_id); 11543 return; 11544 } 11545 11546 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg)); 11547 11548 if (!strcmp(res->payload_layer, "raw")) 11549 flex_cfg.type = RTE_ETH_RAW_PAYLOAD; 11550 else if (!strcmp(res->payload_layer, "l2")) 11551 flex_cfg.type = RTE_ETH_L2_PAYLOAD; 11552 else if (!strcmp(res->payload_layer, "l3")) 11553 flex_cfg.type = RTE_ETH_L3_PAYLOAD; 11554 else if (!strcmp(res->payload_layer, "l4")) 11555 flex_cfg.type = RTE_ETH_L4_PAYLOAD; 11556 11557 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset, 11558 RTE_ETH_FDIR_MAX_FLEXLEN); 11559 if (ret < 0) { 11560 printf("error: Cannot parse flex payload input.\n"); 11561 return; 11562 } 11563 11564 fdir_set_flex_payload(res->port_id, &flex_cfg); 11565 cmd_reconfig_device_queue(res->port_id, 1, 1); 11566 } 11567 11568 cmdline_parse_token_string_t cmd_flow_director_flexpayload = 11569 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11570 flow_director_flexpayload, 11571 "flow_director_flex_payload"); 11572 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id = 11573 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11574 port_id, UINT16); 11575 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer = 11576 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11577 payload_layer, "raw#l2#l3#l4"); 11578 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg = 11579 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11580 payload_cfg, NULL); 11581 11582 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = { 11583 .f = cmd_flow_director_flxpld_parsed, 11584 .data = NULL, 11585 .help_str = "flow_director_flexpayload ... : " 11586 "Set flow director's flex payload on NIC", 11587 .tokens = { 11588 (void *)&cmd_flow_director_flexpayload, 11589 (void *)&cmd_flow_director_flexpayload_port_id, 11590 (void *)&cmd_flow_director_flexpayload_payload_layer, 11591 (void *)&cmd_flow_director_flexpayload_payload_cfg, 11592 NULL, 11593 }, 11594 }; 11595 11596 /* Generic flow interface command. */ 11597 extern cmdline_parse_inst_t cmd_flow; 11598 11599 /* *** Classification Filters Control *** */ 11600 /* *** Get symmetric hash enable per port *** */ 11601 struct cmd_get_sym_hash_ena_per_port_result { 11602 cmdline_fixed_string_t get_sym_hash_ena_per_port; 11603 portid_t port_id; 11604 }; 11605 11606 static void 11607 cmd_get_sym_hash_per_port_parsed(void *parsed_result, 11608 __rte_unused struct cmdline *cl, 11609 __rte_unused void *data) 11610 { 11611 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result; 11612 struct rte_eth_hash_filter_info info; 11613 int ret; 11614 11615 if (rte_eth_dev_filter_supported(res->port_id, 11616 RTE_ETH_FILTER_HASH) < 0) { 11617 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 11618 res->port_id); 11619 return; 11620 } 11621 11622 memset(&info, 0, sizeof(info)); 11623 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 11624 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11625 RTE_ETH_FILTER_GET, &info); 11626 11627 if (ret < 0) { 11628 printf("Cannot get symmetric hash enable per port " 11629 "on port %u\n", res->port_id); 11630 return; 11631 } 11632 11633 printf("Symmetric hash is %s on port %u\n", info.info.enable ? 11634 "enabled" : "disabled", res->port_id); 11635 } 11636 11637 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all = 11638 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 11639 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port"); 11640 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id = 11641 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 11642 port_id, UINT16); 11643 11644 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = { 11645 .f = cmd_get_sym_hash_per_port_parsed, 11646 .data = NULL, 11647 .help_str = "get_sym_hash_ena_per_port <port_id>", 11648 .tokens = { 11649 (void *)&cmd_get_sym_hash_ena_per_port_all, 11650 (void *)&cmd_get_sym_hash_ena_per_port_port_id, 11651 NULL, 11652 }, 11653 }; 11654 11655 /* *** Set symmetric hash enable per port *** */ 11656 struct cmd_set_sym_hash_ena_per_port_result { 11657 cmdline_fixed_string_t set_sym_hash_ena_per_port; 11658 cmdline_fixed_string_t enable; 11659 portid_t port_id; 11660 }; 11661 11662 static void 11663 cmd_set_sym_hash_per_port_parsed(void *parsed_result, 11664 __rte_unused struct cmdline *cl, 11665 __rte_unused void *data) 11666 { 11667 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result; 11668 struct rte_eth_hash_filter_info info; 11669 int ret; 11670 11671 if (rte_eth_dev_filter_supported(res->port_id, 11672 RTE_ETH_FILTER_HASH) < 0) { 11673 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 11674 res->port_id); 11675 return; 11676 } 11677 11678 memset(&info, 0, sizeof(info)); 11679 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 11680 if (!strcmp(res->enable, "enable")) 11681 info.info.enable = 1; 11682 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11683 RTE_ETH_FILTER_SET, &info); 11684 if (ret < 0) { 11685 printf("Cannot set symmetric hash enable per port on " 11686 "port %u\n", res->port_id); 11687 return; 11688 } 11689 printf("Symmetric hash has been set to %s on port %u\n", 11690 res->enable, res->port_id); 11691 } 11692 11693 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all = 11694 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11695 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port"); 11696 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id = 11697 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11698 port_id, UINT16); 11699 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable = 11700 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11701 enable, "enable#disable"); 11702 11703 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = { 11704 .f = cmd_set_sym_hash_per_port_parsed, 11705 .data = NULL, 11706 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable", 11707 .tokens = { 11708 (void *)&cmd_set_sym_hash_ena_per_port_all, 11709 (void *)&cmd_set_sym_hash_ena_per_port_port_id, 11710 (void *)&cmd_set_sym_hash_ena_per_port_enable, 11711 NULL, 11712 }, 11713 }; 11714 11715 /* Get global config of hash function */ 11716 struct cmd_get_hash_global_config_result { 11717 cmdline_fixed_string_t get_hash_global_config; 11718 portid_t port_id; 11719 }; 11720 11721 static char * 11722 flowtype_to_str(uint16_t ftype) 11723 { 11724 uint16_t i; 11725 static struct { 11726 char str[16]; 11727 uint16_t ftype; 11728 } ftype_table[] = { 11729 {"ipv4", RTE_ETH_FLOW_IPV4}, 11730 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 11731 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 11732 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 11733 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 11734 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 11735 {"ipv6", RTE_ETH_FLOW_IPV6}, 11736 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 11737 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 11738 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 11739 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 11740 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 11741 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 11742 {"port", RTE_ETH_FLOW_PORT}, 11743 {"vxlan", RTE_ETH_FLOW_VXLAN}, 11744 {"geneve", RTE_ETH_FLOW_GENEVE}, 11745 {"nvgre", RTE_ETH_FLOW_NVGRE}, 11746 }; 11747 11748 for (i = 0; i < RTE_DIM(ftype_table); i++) { 11749 if (ftype_table[i].ftype == ftype) 11750 return ftype_table[i].str; 11751 } 11752 11753 return NULL; 11754 } 11755 11756 static void 11757 cmd_get_hash_global_config_parsed(void *parsed_result, 11758 __rte_unused struct cmdline *cl, 11759 __rte_unused void *data) 11760 { 11761 struct cmd_get_hash_global_config_result *res = parsed_result; 11762 struct rte_eth_hash_filter_info info; 11763 uint32_t idx, offset; 11764 uint16_t i; 11765 char *str; 11766 int ret; 11767 11768 if (rte_eth_dev_filter_supported(res->port_id, 11769 RTE_ETH_FILTER_HASH) < 0) { 11770 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 11771 res->port_id); 11772 return; 11773 } 11774 11775 memset(&info, 0, sizeof(info)); 11776 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 11777 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11778 RTE_ETH_FILTER_GET, &info); 11779 if (ret < 0) { 11780 printf("Cannot get hash global configurations by port %d\n", 11781 res->port_id); 11782 return; 11783 } 11784 11785 switch (info.info.global_conf.hash_func) { 11786 case RTE_ETH_HASH_FUNCTION_TOEPLITZ: 11787 printf("Hash function is Toeplitz\n"); 11788 break; 11789 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: 11790 printf("Hash function is Simple XOR\n"); 11791 break; 11792 default: 11793 printf("Unknown hash function\n"); 11794 break; 11795 } 11796 11797 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) { 11798 idx = i / UINT64_BIT; 11799 offset = i % UINT64_BIT; 11800 if (!(info.info.global_conf.valid_bit_mask[idx] & 11801 (1ULL << offset))) 11802 continue; 11803 str = flowtype_to_str(i); 11804 if (!str) 11805 continue; 11806 printf("Symmetric hash is %s globally for flow type %s " 11807 "by port %d\n", 11808 ((info.info.global_conf.sym_hash_enable_mask[idx] & 11809 (1ULL << offset)) ? "enabled" : "disabled"), str, 11810 res->port_id); 11811 } 11812 } 11813 11814 cmdline_parse_token_string_t cmd_get_hash_global_config_all = 11815 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result, 11816 get_hash_global_config, "get_hash_global_config"); 11817 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id = 11818 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result, 11819 port_id, UINT16); 11820 11821 cmdline_parse_inst_t cmd_get_hash_global_config = { 11822 .f = cmd_get_hash_global_config_parsed, 11823 .data = NULL, 11824 .help_str = "get_hash_global_config <port_id>", 11825 .tokens = { 11826 (void *)&cmd_get_hash_global_config_all, 11827 (void *)&cmd_get_hash_global_config_port_id, 11828 NULL, 11829 }, 11830 }; 11831 11832 /* Set global config of hash function */ 11833 struct cmd_set_hash_global_config_result { 11834 cmdline_fixed_string_t set_hash_global_config; 11835 portid_t port_id; 11836 cmdline_fixed_string_t hash_func; 11837 cmdline_fixed_string_t flow_type; 11838 cmdline_fixed_string_t enable; 11839 }; 11840 11841 static void 11842 cmd_set_hash_global_config_parsed(void *parsed_result, 11843 __rte_unused struct cmdline *cl, 11844 __rte_unused void *data) 11845 { 11846 struct cmd_set_hash_global_config_result *res = parsed_result; 11847 struct rte_eth_hash_filter_info info; 11848 uint32_t ftype, idx, offset; 11849 int ret; 11850 11851 if (rte_eth_dev_filter_supported(res->port_id, 11852 RTE_ETH_FILTER_HASH) < 0) { 11853 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 11854 res->port_id); 11855 return; 11856 } 11857 memset(&info, 0, sizeof(info)); 11858 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 11859 if (!strcmp(res->hash_func, "toeplitz")) 11860 info.info.global_conf.hash_func = 11861 RTE_ETH_HASH_FUNCTION_TOEPLITZ; 11862 else if (!strcmp(res->hash_func, "simple_xor")) 11863 info.info.global_conf.hash_func = 11864 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; 11865 else if (!strcmp(res->hash_func, "default")) 11866 info.info.global_conf.hash_func = 11867 RTE_ETH_HASH_FUNCTION_DEFAULT; 11868 11869 ftype = str2flowtype(res->flow_type); 11870 idx = ftype / UINT64_BIT; 11871 offset = ftype % UINT64_BIT; 11872 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset); 11873 if (!strcmp(res->enable, "enable")) 11874 info.info.global_conf.sym_hash_enable_mask[idx] |= 11875 (1ULL << offset); 11876 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11877 RTE_ETH_FILTER_SET, &info); 11878 if (ret < 0) 11879 printf("Cannot set global hash configurations by port %d\n", 11880 res->port_id); 11881 else 11882 printf("Global hash configurations have been set " 11883 "succcessfully by port %d\n", res->port_id); 11884 } 11885 11886 cmdline_parse_token_string_t cmd_set_hash_global_config_all = 11887 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 11888 set_hash_global_config, "set_hash_global_config"); 11889 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id = 11890 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result, 11891 port_id, UINT16); 11892 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func = 11893 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 11894 hash_func, "toeplitz#simple_xor#default"); 11895 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type = 11896 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 11897 flow_type, 11898 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#" 11899 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 11900 cmdline_parse_token_string_t cmd_set_hash_global_config_enable = 11901 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 11902 enable, "enable#disable"); 11903 11904 cmdline_parse_inst_t cmd_set_hash_global_config = { 11905 .f = cmd_set_hash_global_config_parsed, 11906 .data = NULL, 11907 .help_str = "set_hash_global_config <port_id> " 11908 "toeplitz|simple_xor|default " 11909 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 11910 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 11911 "l2_payload enable|disable", 11912 .tokens = { 11913 (void *)&cmd_set_hash_global_config_all, 11914 (void *)&cmd_set_hash_global_config_port_id, 11915 (void *)&cmd_set_hash_global_config_hash_func, 11916 (void *)&cmd_set_hash_global_config_flow_type, 11917 (void *)&cmd_set_hash_global_config_enable, 11918 NULL, 11919 }, 11920 }; 11921 11922 /* Set hash input set */ 11923 struct cmd_set_hash_input_set_result { 11924 cmdline_fixed_string_t set_hash_input_set; 11925 portid_t port_id; 11926 cmdline_fixed_string_t flow_type; 11927 cmdline_fixed_string_t inset_field; 11928 cmdline_fixed_string_t select; 11929 }; 11930 11931 static enum rte_eth_input_set_field 11932 str2inset(char *string) 11933 { 11934 uint16_t i; 11935 11936 static const struct { 11937 char str[32]; 11938 enum rte_eth_input_set_field inset; 11939 } inset_table[] = { 11940 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE}, 11941 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN}, 11942 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN}, 11943 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4}, 11944 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4}, 11945 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS}, 11946 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO}, 11947 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL}, 11948 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6}, 11949 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6}, 11950 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC}, 11951 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER}, 11952 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS}, 11953 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT}, 11954 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT}, 11955 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT}, 11956 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT}, 11957 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT}, 11958 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT}, 11959 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG}, 11960 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY}, 11961 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY}, 11962 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD}, 11963 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD}, 11964 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD}, 11965 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD}, 11966 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD}, 11967 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD}, 11968 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD}, 11969 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD}, 11970 {"none", RTE_ETH_INPUT_SET_NONE}, 11971 }; 11972 11973 for (i = 0; i < RTE_DIM(inset_table); i++) { 11974 if (!strcmp(string, inset_table[i].str)) 11975 return inset_table[i].inset; 11976 } 11977 11978 return RTE_ETH_INPUT_SET_UNKNOWN; 11979 } 11980 11981 static void 11982 cmd_set_hash_input_set_parsed(void *parsed_result, 11983 __rte_unused struct cmdline *cl, 11984 __rte_unused void *data) 11985 { 11986 struct cmd_set_hash_input_set_result *res = parsed_result; 11987 struct rte_eth_hash_filter_info info; 11988 11989 memset(&info, 0, sizeof(info)); 11990 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT; 11991 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 11992 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 11993 info.info.input_set_conf.inset_size = 1; 11994 if (!strcmp(res->select, "select")) 11995 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 11996 else if (!strcmp(res->select, "add")) 11997 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 11998 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11999 RTE_ETH_FILTER_SET, &info); 12000 } 12001 12002 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd = 12003 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12004 set_hash_input_set, "set_hash_input_set"); 12005 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id = 12006 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result, 12007 port_id, UINT16); 12008 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type = 12009 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12010 flow_type, NULL); 12011 cmdline_parse_token_string_t cmd_set_hash_input_set_field = 12012 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12013 inset_field, 12014 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12015 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#" 12016 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#" 12017 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#" 12018 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#" 12019 "fld-8th#none"); 12020 cmdline_parse_token_string_t cmd_set_hash_input_set_select = 12021 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12022 select, "select#add"); 12023 12024 cmdline_parse_inst_t cmd_set_hash_input_set = { 12025 .f = cmd_set_hash_input_set_parsed, 12026 .data = NULL, 12027 .help_str = "set_hash_input_set <port_id> " 12028 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12029 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> " 12030 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|" 12031 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|" 12032 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|" 12033 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|" 12034 "fld-7th|fld-8th|none select|add", 12035 .tokens = { 12036 (void *)&cmd_set_hash_input_set_cmd, 12037 (void *)&cmd_set_hash_input_set_port_id, 12038 (void *)&cmd_set_hash_input_set_flow_type, 12039 (void *)&cmd_set_hash_input_set_field, 12040 (void *)&cmd_set_hash_input_set_select, 12041 NULL, 12042 }, 12043 }; 12044 12045 /* Set flow director input set */ 12046 struct cmd_set_fdir_input_set_result { 12047 cmdline_fixed_string_t set_fdir_input_set; 12048 portid_t port_id; 12049 cmdline_fixed_string_t flow_type; 12050 cmdline_fixed_string_t inset_field; 12051 cmdline_fixed_string_t select; 12052 }; 12053 12054 static void 12055 cmd_set_fdir_input_set_parsed(void *parsed_result, 12056 __rte_unused struct cmdline *cl, 12057 __rte_unused void *data) 12058 { 12059 struct cmd_set_fdir_input_set_result *res = parsed_result; 12060 struct rte_eth_fdir_filter_info info; 12061 12062 memset(&info, 0, sizeof(info)); 12063 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT; 12064 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 12065 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 12066 info.info.input_set_conf.inset_size = 1; 12067 if (!strcmp(res->select, "select")) 12068 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 12069 else if (!strcmp(res->select, "add")) 12070 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 12071 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 12072 RTE_ETH_FILTER_SET, &info); 12073 } 12074 12075 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd = 12076 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12077 set_fdir_input_set, "set_fdir_input_set"); 12078 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id = 12079 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result, 12080 port_id, UINT16); 12081 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type = 12082 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12083 flow_type, 12084 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#" 12085 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 12086 cmdline_parse_token_string_t cmd_set_fdir_input_set_field = 12087 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12088 inset_field, 12089 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12090 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#" 12091 "ipv6-hop-limits#udp-src-port#udp-dst-port#" 12092 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#" 12093 "sctp-veri-tag#none"); 12094 cmdline_parse_token_string_t cmd_set_fdir_input_set_select = 12095 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12096 select, "select#add"); 12097 12098 cmdline_parse_inst_t cmd_set_fdir_input_set = { 12099 .f = cmd_set_fdir_input_set_parsed, 12100 .data = NULL, 12101 .help_str = "set_fdir_input_set <port_id> " 12102 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12103 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload " 12104 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|" 12105 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|" 12106 "ipv6-hop-limits|udp-src-port|udp-dst-port|" 12107 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|" 12108 "sctp-veri-tag|none select|add", 12109 .tokens = { 12110 (void *)&cmd_set_fdir_input_set_cmd, 12111 (void *)&cmd_set_fdir_input_set_port_id, 12112 (void *)&cmd_set_fdir_input_set_flow_type, 12113 (void *)&cmd_set_fdir_input_set_field, 12114 (void *)&cmd_set_fdir_input_set_select, 12115 NULL, 12116 }, 12117 }; 12118 12119 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ 12120 struct cmd_mcast_addr_result { 12121 cmdline_fixed_string_t mcast_addr_cmd; 12122 cmdline_fixed_string_t what; 12123 uint16_t port_num; 12124 struct ether_addr mc_addr; 12125 }; 12126 12127 static void cmd_mcast_addr_parsed(void *parsed_result, 12128 __attribute__((unused)) struct cmdline *cl, 12129 __attribute__((unused)) void *data) 12130 { 12131 struct cmd_mcast_addr_result *res = parsed_result; 12132 12133 if (!is_multicast_ether_addr(&res->mc_addr)) { 12134 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n", 12135 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1], 12136 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3], 12137 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]); 12138 return; 12139 } 12140 if (strcmp(res->what, "add") == 0) 12141 mcast_addr_add(res->port_num, &res->mc_addr); 12142 else 12143 mcast_addr_remove(res->port_num, &res->mc_addr); 12144 } 12145 12146 cmdline_parse_token_string_t cmd_mcast_addr_cmd = 12147 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, 12148 mcast_addr_cmd, "mcast_addr"); 12149 cmdline_parse_token_string_t cmd_mcast_addr_what = 12150 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, 12151 "add#remove"); 12152 cmdline_parse_token_num_t cmd_mcast_addr_portnum = 12153 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16); 12154 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = 12155 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 12156 12157 cmdline_parse_inst_t cmd_mcast_addr = { 12158 .f = cmd_mcast_addr_parsed, 12159 .data = (void *)0, 12160 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: " 12161 "Add/Remove multicast MAC address on port_id", 12162 .tokens = { 12163 (void *)&cmd_mcast_addr_cmd, 12164 (void *)&cmd_mcast_addr_what, 12165 (void *)&cmd_mcast_addr_portnum, 12166 (void *)&cmd_mcast_addr_addr, 12167 NULL, 12168 }, 12169 }; 12170 12171 /* l2 tunnel config 12172 * only support E-tag now. 12173 */ 12174 12175 /* Ether type config */ 12176 struct cmd_config_l2_tunnel_eth_type_result { 12177 cmdline_fixed_string_t port; 12178 cmdline_fixed_string_t config; 12179 cmdline_fixed_string_t all; 12180 portid_t id; 12181 cmdline_fixed_string_t l2_tunnel; 12182 cmdline_fixed_string_t l2_tunnel_type; 12183 cmdline_fixed_string_t eth_type; 12184 uint16_t eth_type_val; 12185 }; 12186 12187 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port = 12188 TOKEN_STRING_INITIALIZER 12189 (struct cmd_config_l2_tunnel_eth_type_result, 12190 port, "port"); 12191 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config = 12192 TOKEN_STRING_INITIALIZER 12193 (struct cmd_config_l2_tunnel_eth_type_result, 12194 config, "config"); 12195 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str = 12196 TOKEN_STRING_INITIALIZER 12197 (struct cmd_config_l2_tunnel_eth_type_result, 12198 all, "all"); 12199 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id = 12200 TOKEN_NUM_INITIALIZER 12201 (struct cmd_config_l2_tunnel_eth_type_result, 12202 id, UINT16); 12203 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel = 12204 TOKEN_STRING_INITIALIZER 12205 (struct cmd_config_l2_tunnel_eth_type_result, 12206 l2_tunnel, "l2-tunnel"); 12207 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type = 12208 TOKEN_STRING_INITIALIZER 12209 (struct cmd_config_l2_tunnel_eth_type_result, 12210 l2_tunnel_type, "E-tag"); 12211 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type = 12212 TOKEN_STRING_INITIALIZER 12213 (struct cmd_config_l2_tunnel_eth_type_result, 12214 eth_type, "ether-type"); 12215 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val = 12216 TOKEN_NUM_INITIALIZER 12217 (struct cmd_config_l2_tunnel_eth_type_result, 12218 eth_type_val, UINT16); 12219 12220 static enum rte_eth_tunnel_type 12221 str2fdir_l2_tunnel_type(char *string) 12222 { 12223 uint32_t i = 0; 12224 12225 static const struct { 12226 char str[32]; 12227 enum rte_eth_tunnel_type type; 12228 } l2_tunnel_type_str[] = { 12229 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG}, 12230 }; 12231 12232 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) { 12233 if (!strcmp(l2_tunnel_type_str[i].str, string)) 12234 return l2_tunnel_type_str[i].type; 12235 } 12236 return RTE_TUNNEL_TYPE_NONE; 12237 } 12238 12239 /* ether type config for all ports */ 12240 static void 12241 cmd_config_l2_tunnel_eth_type_all_parsed 12242 (void *parsed_result, 12243 __attribute__((unused)) struct cmdline *cl, 12244 __attribute__((unused)) void *data) 12245 { 12246 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result; 12247 struct rte_eth_l2_tunnel_conf entry; 12248 portid_t pid; 12249 12250 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12251 entry.ether_type = res->eth_type_val; 12252 12253 RTE_ETH_FOREACH_DEV(pid) { 12254 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry); 12255 } 12256 } 12257 12258 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = { 12259 .f = cmd_config_l2_tunnel_eth_type_all_parsed, 12260 .data = NULL, 12261 .help_str = "port config all l2-tunnel E-tag ether-type <value>", 12262 .tokens = { 12263 (void *)&cmd_config_l2_tunnel_eth_type_port, 12264 (void *)&cmd_config_l2_tunnel_eth_type_config, 12265 (void *)&cmd_config_l2_tunnel_eth_type_all_str, 12266 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 12267 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 12268 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 12269 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 12270 NULL, 12271 }, 12272 }; 12273 12274 /* ether type config for a specific port */ 12275 static void 12276 cmd_config_l2_tunnel_eth_type_specific_parsed( 12277 void *parsed_result, 12278 __attribute__((unused)) struct cmdline *cl, 12279 __attribute__((unused)) void *data) 12280 { 12281 struct cmd_config_l2_tunnel_eth_type_result *res = 12282 parsed_result; 12283 struct rte_eth_l2_tunnel_conf entry; 12284 12285 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12286 return; 12287 12288 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12289 entry.ether_type = res->eth_type_val; 12290 12291 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry); 12292 } 12293 12294 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = { 12295 .f = cmd_config_l2_tunnel_eth_type_specific_parsed, 12296 .data = NULL, 12297 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>", 12298 .tokens = { 12299 (void *)&cmd_config_l2_tunnel_eth_type_port, 12300 (void *)&cmd_config_l2_tunnel_eth_type_config, 12301 (void *)&cmd_config_l2_tunnel_eth_type_id, 12302 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 12303 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 12304 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 12305 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 12306 NULL, 12307 }, 12308 }; 12309 12310 /* Enable/disable l2 tunnel */ 12311 struct cmd_config_l2_tunnel_en_dis_result { 12312 cmdline_fixed_string_t port; 12313 cmdline_fixed_string_t config; 12314 cmdline_fixed_string_t all; 12315 portid_t id; 12316 cmdline_fixed_string_t l2_tunnel; 12317 cmdline_fixed_string_t l2_tunnel_type; 12318 cmdline_fixed_string_t en_dis; 12319 }; 12320 12321 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port = 12322 TOKEN_STRING_INITIALIZER 12323 (struct cmd_config_l2_tunnel_en_dis_result, 12324 port, "port"); 12325 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config = 12326 TOKEN_STRING_INITIALIZER 12327 (struct cmd_config_l2_tunnel_en_dis_result, 12328 config, "config"); 12329 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str = 12330 TOKEN_STRING_INITIALIZER 12331 (struct cmd_config_l2_tunnel_en_dis_result, 12332 all, "all"); 12333 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id = 12334 TOKEN_NUM_INITIALIZER 12335 (struct cmd_config_l2_tunnel_en_dis_result, 12336 id, UINT16); 12337 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel = 12338 TOKEN_STRING_INITIALIZER 12339 (struct cmd_config_l2_tunnel_en_dis_result, 12340 l2_tunnel, "l2-tunnel"); 12341 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type = 12342 TOKEN_STRING_INITIALIZER 12343 (struct cmd_config_l2_tunnel_en_dis_result, 12344 l2_tunnel_type, "E-tag"); 12345 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis = 12346 TOKEN_STRING_INITIALIZER 12347 (struct cmd_config_l2_tunnel_en_dis_result, 12348 en_dis, "enable#disable"); 12349 12350 /* enable/disable l2 tunnel for all ports */ 12351 static void 12352 cmd_config_l2_tunnel_en_dis_all_parsed( 12353 void *parsed_result, 12354 __attribute__((unused)) struct cmdline *cl, 12355 __attribute__((unused)) void *data) 12356 { 12357 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result; 12358 struct rte_eth_l2_tunnel_conf entry; 12359 portid_t pid; 12360 uint8_t en; 12361 12362 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12363 12364 if (!strcmp("enable", res->en_dis)) 12365 en = 1; 12366 else 12367 en = 0; 12368 12369 RTE_ETH_FOREACH_DEV(pid) { 12370 rte_eth_dev_l2_tunnel_offload_set(pid, 12371 &entry, 12372 ETH_L2_TUNNEL_ENABLE_MASK, 12373 en); 12374 } 12375 } 12376 12377 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = { 12378 .f = cmd_config_l2_tunnel_en_dis_all_parsed, 12379 .data = NULL, 12380 .help_str = "port config all l2-tunnel E-tag enable|disable", 12381 .tokens = { 12382 (void *)&cmd_config_l2_tunnel_en_dis_port, 12383 (void *)&cmd_config_l2_tunnel_en_dis_config, 12384 (void *)&cmd_config_l2_tunnel_en_dis_all_str, 12385 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12386 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12387 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12388 NULL, 12389 }, 12390 }; 12391 12392 /* enable/disable l2 tunnel for a port */ 12393 static void 12394 cmd_config_l2_tunnel_en_dis_specific_parsed( 12395 void *parsed_result, 12396 __attribute__((unused)) struct cmdline *cl, 12397 __attribute__((unused)) void *data) 12398 { 12399 struct cmd_config_l2_tunnel_en_dis_result *res = 12400 parsed_result; 12401 struct rte_eth_l2_tunnel_conf entry; 12402 12403 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12404 return; 12405 12406 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12407 12408 if (!strcmp("enable", res->en_dis)) 12409 rte_eth_dev_l2_tunnel_offload_set(res->id, 12410 &entry, 12411 ETH_L2_TUNNEL_ENABLE_MASK, 12412 1); 12413 else 12414 rte_eth_dev_l2_tunnel_offload_set(res->id, 12415 &entry, 12416 ETH_L2_TUNNEL_ENABLE_MASK, 12417 0); 12418 } 12419 12420 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = { 12421 .f = cmd_config_l2_tunnel_en_dis_specific_parsed, 12422 .data = NULL, 12423 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable", 12424 .tokens = { 12425 (void *)&cmd_config_l2_tunnel_en_dis_port, 12426 (void *)&cmd_config_l2_tunnel_en_dis_config, 12427 (void *)&cmd_config_l2_tunnel_en_dis_id, 12428 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12429 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12430 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12431 NULL, 12432 }, 12433 }; 12434 12435 /* E-tag configuration */ 12436 12437 /* Common result structure for all E-tag configuration */ 12438 struct cmd_config_e_tag_result { 12439 cmdline_fixed_string_t e_tag; 12440 cmdline_fixed_string_t set; 12441 cmdline_fixed_string_t insertion; 12442 cmdline_fixed_string_t stripping; 12443 cmdline_fixed_string_t forwarding; 12444 cmdline_fixed_string_t filter; 12445 cmdline_fixed_string_t add; 12446 cmdline_fixed_string_t del; 12447 cmdline_fixed_string_t on; 12448 cmdline_fixed_string_t off; 12449 cmdline_fixed_string_t on_off; 12450 cmdline_fixed_string_t port_tag_id; 12451 uint32_t port_tag_id_val; 12452 cmdline_fixed_string_t e_tag_id; 12453 uint16_t e_tag_id_val; 12454 cmdline_fixed_string_t dst_pool; 12455 uint8_t dst_pool_val; 12456 cmdline_fixed_string_t port; 12457 portid_t port_id; 12458 cmdline_fixed_string_t vf; 12459 uint8_t vf_id; 12460 }; 12461 12462 /* Common CLI fields for all E-tag configuration */ 12463 cmdline_parse_token_string_t cmd_config_e_tag_e_tag = 12464 TOKEN_STRING_INITIALIZER 12465 (struct cmd_config_e_tag_result, 12466 e_tag, "E-tag"); 12467 cmdline_parse_token_string_t cmd_config_e_tag_set = 12468 TOKEN_STRING_INITIALIZER 12469 (struct cmd_config_e_tag_result, 12470 set, "set"); 12471 cmdline_parse_token_string_t cmd_config_e_tag_insertion = 12472 TOKEN_STRING_INITIALIZER 12473 (struct cmd_config_e_tag_result, 12474 insertion, "insertion"); 12475 cmdline_parse_token_string_t cmd_config_e_tag_stripping = 12476 TOKEN_STRING_INITIALIZER 12477 (struct cmd_config_e_tag_result, 12478 stripping, "stripping"); 12479 cmdline_parse_token_string_t cmd_config_e_tag_forwarding = 12480 TOKEN_STRING_INITIALIZER 12481 (struct cmd_config_e_tag_result, 12482 forwarding, "forwarding"); 12483 cmdline_parse_token_string_t cmd_config_e_tag_filter = 12484 TOKEN_STRING_INITIALIZER 12485 (struct cmd_config_e_tag_result, 12486 filter, "filter"); 12487 cmdline_parse_token_string_t cmd_config_e_tag_add = 12488 TOKEN_STRING_INITIALIZER 12489 (struct cmd_config_e_tag_result, 12490 add, "add"); 12491 cmdline_parse_token_string_t cmd_config_e_tag_del = 12492 TOKEN_STRING_INITIALIZER 12493 (struct cmd_config_e_tag_result, 12494 del, "del"); 12495 cmdline_parse_token_string_t cmd_config_e_tag_on = 12496 TOKEN_STRING_INITIALIZER 12497 (struct cmd_config_e_tag_result, 12498 on, "on"); 12499 cmdline_parse_token_string_t cmd_config_e_tag_off = 12500 TOKEN_STRING_INITIALIZER 12501 (struct cmd_config_e_tag_result, 12502 off, "off"); 12503 cmdline_parse_token_string_t cmd_config_e_tag_on_off = 12504 TOKEN_STRING_INITIALIZER 12505 (struct cmd_config_e_tag_result, 12506 on_off, "on#off"); 12507 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id = 12508 TOKEN_STRING_INITIALIZER 12509 (struct cmd_config_e_tag_result, 12510 port_tag_id, "port-tag-id"); 12511 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val = 12512 TOKEN_NUM_INITIALIZER 12513 (struct cmd_config_e_tag_result, 12514 port_tag_id_val, UINT32); 12515 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id = 12516 TOKEN_STRING_INITIALIZER 12517 (struct cmd_config_e_tag_result, 12518 e_tag_id, "e-tag-id"); 12519 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val = 12520 TOKEN_NUM_INITIALIZER 12521 (struct cmd_config_e_tag_result, 12522 e_tag_id_val, UINT16); 12523 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool = 12524 TOKEN_STRING_INITIALIZER 12525 (struct cmd_config_e_tag_result, 12526 dst_pool, "dst-pool"); 12527 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val = 12528 TOKEN_NUM_INITIALIZER 12529 (struct cmd_config_e_tag_result, 12530 dst_pool_val, UINT8); 12531 cmdline_parse_token_string_t cmd_config_e_tag_port = 12532 TOKEN_STRING_INITIALIZER 12533 (struct cmd_config_e_tag_result, 12534 port, "port"); 12535 cmdline_parse_token_num_t cmd_config_e_tag_port_id = 12536 TOKEN_NUM_INITIALIZER 12537 (struct cmd_config_e_tag_result, 12538 port_id, UINT16); 12539 cmdline_parse_token_string_t cmd_config_e_tag_vf = 12540 TOKEN_STRING_INITIALIZER 12541 (struct cmd_config_e_tag_result, 12542 vf, "vf"); 12543 cmdline_parse_token_num_t cmd_config_e_tag_vf_id = 12544 TOKEN_NUM_INITIALIZER 12545 (struct cmd_config_e_tag_result, 12546 vf_id, UINT8); 12547 12548 /* E-tag insertion configuration */ 12549 static void 12550 cmd_config_e_tag_insertion_en_parsed( 12551 void *parsed_result, 12552 __attribute__((unused)) struct cmdline *cl, 12553 __attribute__((unused)) void *data) 12554 { 12555 struct cmd_config_e_tag_result *res = 12556 parsed_result; 12557 struct rte_eth_l2_tunnel_conf entry; 12558 12559 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12560 return; 12561 12562 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12563 entry.tunnel_id = res->port_tag_id_val; 12564 entry.vf_id = res->vf_id; 12565 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 12566 &entry, 12567 ETH_L2_TUNNEL_INSERTION_MASK, 12568 1); 12569 } 12570 12571 static void 12572 cmd_config_e_tag_insertion_dis_parsed( 12573 void *parsed_result, 12574 __attribute__((unused)) struct cmdline *cl, 12575 __attribute__((unused)) void *data) 12576 { 12577 struct cmd_config_e_tag_result *res = 12578 parsed_result; 12579 struct rte_eth_l2_tunnel_conf entry; 12580 12581 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12582 return; 12583 12584 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12585 entry.vf_id = res->vf_id; 12586 12587 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 12588 &entry, 12589 ETH_L2_TUNNEL_INSERTION_MASK, 12590 0); 12591 } 12592 12593 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = { 12594 .f = cmd_config_e_tag_insertion_en_parsed, 12595 .data = NULL, 12596 .help_str = "E-tag ... : E-tag insertion enable", 12597 .tokens = { 12598 (void *)&cmd_config_e_tag_e_tag, 12599 (void *)&cmd_config_e_tag_set, 12600 (void *)&cmd_config_e_tag_insertion, 12601 (void *)&cmd_config_e_tag_on, 12602 (void *)&cmd_config_e_tag_port_tag_id, 12603 (void *)&cmd_config_e_tag_port_tag_id_val, 12604 (void *)&cmd_config_e_tag_port, 12605 (void *)&cmd_config_e_tag_port_id, 12606 (void *)&cmd_config_e_tag_vf, 12607 (void *)&cmd_config_e_tag_vf_id, 12608 NULL, 12609 }, 12610 }; 12611 12612 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = { 12613 .f = cmd_config_e_tag_insertion_dis_parsed, 12614 .data = NULL, 12615 .help_str = "E-tag ... : E-tag insertion disable", 12616 .tokens = { 12617 (void *)&cmd_config_e_tag_e_tag, 12618 (void *)&cmd_config_e_tag_set, 12619 (void *)&cmd_config_e_tag_insertion, 12620 (void *)&cmd_config_e_tag_off, 12621 (void *)&cmd_config_e_tag_port, 12622 (void *)&cmd_config_e_tag_port_id, 12623 (void *)&cmd_config_e_tag_vf, 12624 (void *)&cmd_config_e_tag_vf_id, 12625 NULL, 12626 }, 12627 }; 12628 12629 /* E-tag stripping configuration */ 12630 static void 12631 cmd_config_e_tag_stripping_parsed( 12632 void *parsed_result, 12633 __attribute__((unused)) struct cmdline *cl, 12634 __attribute__((unused)) void *data) 12635 { 12636 struct cmd_config_e_tag_result *res = 12637 parsed_result; 12638 struct rte_eth_l2_tunnel_conf entry; 12639 12640 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12641 return; 12642 12643 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12644 12645 if (!strcmp(res->on_off, "on")) 12646 rte_eth_dev_l2_tunnel_offload_set 12647 (res->port_id, 12648 &entry, 12649 ETH_L2_TUNNEL_STRIPPING_MASK, 12650 1); 12651 else 12652 rte_eth_dev_l2_tunnel_offload_set 12653 (res->port_id, 12654 &entry, 12655 ETH_L2_TUNNEL_STRIPPING_MASK, 12656 0); 12657 } 12658 12659 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = { 12660 .f = cmd_config_e_tag_stripping_parsed, 12661 .data = NULL, 12662 .help_str = "E-tag ... : E-tag stripping enable/disable", 12663 .tokens = { 12664 (void *)&cmd_config_e_tag_e_tag, 12665 (void *)&cmd_config_e_tag_set, 12666 (void *)&cmd_config_e_tag_stripping, 12667 (void *)&cmd_config_e_tag_on_off, 12668 (void *)&cmd_config_e_tag_port, 12669 (void *)&cmd_config_e_tag_port_id, 12670 NULL, 12671 }, 12672 }; 12673 12674 /* E-tag forwarding configuration */ 12675 static void 12676 cmd_config_e_tag_forwarding_parsed( 12677 void *parsed_result, 12678 __attribute__((unused)) struct cmdline *cl, 12679 __attribute__((unused)) void *data) 12680 { 12681 struct cmd_config_e_tag_result *res = parsed_result; 12682 struct rte_eth_l2_tunnel_conf entry; 12683 12684 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12685 return; 12686 12687 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12688 12689 if (!strcmp(res->on_off, "on")) 12690 rte_eth_dev_l2_tunnel_offload_set 12691 (res->port_id, 12692 &entry, 12693 ETH_L2_TUNNEL_FORWARDING_MASK, 12694 1); 12695 else 12696 rte_eth_dev_l2_tunnel_offload_set 12697 (res->port_id, 12698 &entry, 12699 ETH_L2_TUNNEL_FORWARDING_MASK, 12700 0); 12701 } 12702 12703 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = { 12704 .f = cmd_config_e_tag_forwarding_parsed, 12705 .data = NULL, 12706 .help_str = "E-tag ... : E-tag forwarding enable/disable", 12707 .tokens = { 12708 (void *)&cmd_config_e_tag_e_tag, 12709 (void *)&cmd_config_e_tag_set, 12710 (void *)&cmd_config_e_tag_forwarding, 12711 (void *)&cmd_config_e_tag_on_off, 12712 (void *)&cmd_config_e_tag_port, 12713 (void *)&cmd_config_e_tag_port_id, 12714 NULL, 12715 }, 12716 }; 12717 12718 /* E-tag filter configuration */ 12719 static void 12720 cmd_config_e_tag_filter_add_parsed( 12721 void *parsed_result, 12722 __attribute__((unused)) struct cmdline *cl, 12723 __attribute__((unused)) void *data) 12724 { 12725 struct cmd_config_e_tag_result *res = parsed_result; 12726 struct rte_eth_l2_tunnel_conf entry; 12727 int ret = 0; 12728 12729 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12730 return; 12731 12732 if (res->e_tag_id_val > 0x3fff) { 12733 printf("e-tag-id must be equal or less than 0x3fff.\n"); 12734 return; 12735 } 12736 12737 ret = rte_eth_dev_filter_supported(res->port_id, 12738 RTE_ETH_FILTER_L2_TUNNEL); 12739 if (ret < 0) { 12740 printf("E-tag filter is not supported on port %u.\n", 12741 res->port_id); 12742 return; 12743 } 12744 12745 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12746 entry.tunnel_id = res->e_tag_id_val; 12747 entry.pool = res->dst_pool_val; 12748 12749 ret = rte_eth_dev_filter_ctrl(res->port_id, 12750 RTE_ETH_FILTER_L2_TUNNEL, 12751 RTE_ETH_FILTER_ADD, 12752 &entry); 12753 if (ret < 0) 12754 printf("E-tag filter programming error: (%s)\n", 12755 strerror(-ret)); 12756 } 12757 12758 cmdline_parse_inst_t cmd_config_e_tag_filter_add = { 12759 .f = cmd_config_e_tag_filter_add_parsed, 12760 .data = NULL, 12761 .help_str = "E-tag ... : E-tag filter add", 12762 .tokens = { 12763 (void *)&cmd_config_e_tag_e_tag, 12764 (void *)&cmd_config_e_tag_set, 12765 (void *)&cmd_config_e_tag_filter, 12766 (void *)&cmd_config_e_tag_add, 12767 (void *)&cmd_config_e_tag_e_tag_id, 12768 (void *)&cmd_config_e_tag_e_tag_id_val, 12769 (void *)&cmd_config_e_tag_dst_pool, 12770 (void *)&cmd_config_e_tag_dst_pool_val, 12771 (void *)&cmd_config_e_tag_port, 12772 (void *)&cmd_config_e_tag_port_id, 12773 NULL, 12774 }, 12775 }; 12776 12777 static void 12778 cmd_config_e_tag_filter_del_parsed( 12779 void *parsed_result, 12780 __attribute__((unused)) struct cmdline *cl, 12781 __attribute__((unused)) void *data) 12782 { 12783 struct cmd_config_e_tag_result *res = parsed_result; 12784 struct rte_eth_l2_tunnel_conf entry; 12785 int ret = 0; 12786 12787 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12788 return; 12789 12790 if (res->e_tag_id_val > 0x3fff) { 12791 printf("e-tag-id must be less than 0x3fff.\n"); 12792 return; 12793 } 12794 12795 ret = rte_eth_dev_filter_supported(res->port_id, 12796 RTE_ETH_FILTER_L2_TUNNEL); 12797 if (ret < 0) { 12798 printf("E-tag filter is not supported on port %u.\n", 12799 res->port_id); 12800 return; 12801 } 12802 12803 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12804 entry.tunnel_id = res->e_tag_id_val; 12805 12806 ret = rte_eth_dev_filter_ctrl(res->port_id, 12807 RTE_ETH_FILTER_L2_TUNNEL, 12808 RTE_ETH_FILTER_DELETE, 12809 &entry); 12810 if (ret < 0) 12811 printf("E-tag filter programming error: (%s)\n", 12812 strerror(-ret)); 12813 } 12814 12815 cmdline_parse_inst_t cmd_config_e_tag_filter_del = { 12816 .f = cmd_config_e_tag_filter_del_parsed, 12817 .data = NULL, 12818 .help_str = "E-tag ... : E-tag filter delete", 12819 .tokens = { 12820 (void *)&cmd_config_e_tag_e_tag, 12821 (void *)&cmd_config_e_tag_set, 12822 (void *)&cmd_config_e_tag_filter, 12823 (void *)&cmd_config_e_tag_del, 12824 (void *)&cmd_config_e_tag_e_tag_id, 12825 (void *)&cmd_config_e_tag_e_tag_id_val, 12826 (void *)&cmd_config_e_tag_port, 12827 (void *)&cmd_config_e_tag_port_id, 12828 NULL, 12829 }, 12830 }; 12831 12832 /* vf vlan anti spoof configuration */ 12833 12834 /* Common result structure for vf vlan anti spoof */ 12835 struct cmd_vf_vlan_anti_spoof_result { 12836 cmdline_fixed_string_t set; 12837 cmdline_fixed_string_t vf; 12838 cmdline_fixed_string_t vlan; 12839 cmdline_fixed_string_t antispoof; 12840 portid_t port_id; 12841 uint32_t vf_id; 12842 cmdline_fixed_string_t on_off; 12843 }; 12844 12845 /* Common CLI fields for vf vlan anti spoof enable disable */ 12846 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set = 12847 TOKEN_STRING_INITIALIZER 12848 (struct cmd_vf_vlan_anti_spoof_result, 12849 set, "set"); 12850 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf = 12851 TOKEN_STRING_INITIALIZER 12852 (struct cmd_vf_vlan_anti_spoof_result, 12853 vf, "vf"); 12854 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan = 12855 TOKEN_STRING_INITIALIZER 12856 (struct cmd_vf_vlan_anti_spoof_result, 12857 vlan, "vlan"); 12858 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof = 12859 TOKEN_STRING_INITIALIZER 12860 (struct cmd_vf_vlan_anti_spoof_result, 12861 antispoof, "antispoof"); 12862 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id = 12863 TOKEN_NUM_INITIALIZER 12864 (struct cmd_vf_vlan_anti_spoof_result, 12865 port_id, UINT16); 12866 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id = 12867 TOKEN_NUM_INITIALIZER 12868 (struct cmd_vf_vlan_anti_spoof_result, 12869 vf_id, UINT32); 12870 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off = 12871 TOKEN_STRING_INITIALIZER 12872 (struct cmd_vf_vlan_anti_spoof_result, 12873 on_off, "on#off"); 12874 12875 static void 12876 cmd_set_vf_vlan_anti_spoof_parsed( 12877 void *parsed_result, 12878 __attribute__((unused)) struct cmdline *cl, 12879 __attribute__((unused)) void *data) 12880 { 12881 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result; 12882 int ret = -ENOTSUP; 12883 12884 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12885 12886 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12887 return; 12888 12889 #ifdef RTE_LIBRTE_IXGBE_PMD 12890 if (ret == -ENOTSUP) 12891 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, 12892 res->vf_id, is_on); 12893 #endif 12894 #ifdef RTE_LIBRTE_I40E_PMD 12895 if (ret == -ENOTSUP) 12896 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id, 12897 res->vf_id, is_on); 12898 #endif 12899 #ifdef RTE_LIBRTE_BNXT_PMD 12900 if (ret == -ENOTSUP) 12901 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id, 12902 res->vf_id, is_on); 12903 #endif 12904 12905 switch (ret) { 12906 case 0: 12907 break; 12908 case -EINVAL: 12909 printf("invalid vf_id %d\n", res->vf_id); 12910 break; 12911 case -ENODEV: 12912 printf("invalid port_id %d\n", res->port_id); 12913 break; 12914 case -ENOTSUP: 12915 printf("function not implemented\n"); 12916 break; 12917 default: 12918 printf("programming error: (%s)\n", strerror(-ret)); 12919 } 12920 } 12921 12922 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = { 12923 .f = cmd_set_vf_vlan_anti_spoof_parsed, 12924 .data = NULL, 12925 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off", 12926 .tokens = { 12927 (void *)&cmd_vf_vlan_anti_spoof_set, 12928 (void *)&cmd_vf_vlan_anti_spoof_vf, 12929 (void *)&cmd_vf_vlan_anti_spoof_vlan, 12930 (void *)&cmd_vf_vlan_anti_spoof_antispoof, 12931 (void *)&cmd_vf_vlan_anti_spoof_port_id, 12932 (void *)&cmd_vf_vlan_anti_spoof_vf_id, 12933 (void *)&cmd_vf_vlan_anti_spoof_on_off, 12934 NULL, 12935 }, 12936 }; 12937 12938 /* vf mac anti spoof configuration */ 12939 12940 /* Common result structure for vf mac anti spoof */ 12941 struct cmd_vf_mac_anti_spoof_result { 12942 cmdline_fixed_string_t set; 12943 cmdline_fixed_string_t vf; 12944 cmdline_fixed_string_t mac; 12945 cmdline_fixed_string_t antispoof; 12946 portid_t port_id; 12947 uint32_t vf_id; 12948 cmdline_fixed_string_t on_off; 12949 }; 12950 12951 /* Common CLI fields for vf mac anti spoof enable disable */ 12952 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set = 12953 TOKEN_STRING_INITIALIZER 12954 (struct cmd_vf_mac_anti_spoof_result, 12955 set, "set"); 12956 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf = 12957 TOKEN_STRING_INITIALIZER 12958 (struct cmd_vf_mac_anti_spoof_result, 12959 vf, "vf"); 12960 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac = 12961 TOKEN_STRING_INITIALIZER 12962 (struct cmd_vf_mac_anti_spoof_result, 12963 mac, "mac"); 12964 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof = 12965 TOKEN_STRING_INITIALIZER 12966 (struct cmd_vf_mac_anti_spoof_result, 12967 antispoof, "antispoof"); 12968 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id = 12969 TOKEN_NUM_INITIALIZER 12970 (struct cmd_vf_mac_anti_spoof_result, 12971 port_id, UINT16); 12972 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id = 12973 TOKEN_NUM_INITIALIZER 12974 (struct cmd_vf_mac_anti_spoof_result, 12975 vf_id, UINT32); 12976 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off = 12977 TOKEN_STRING_INITIALIZER 12978 (struct cmd_vf_mac_anti_spoof_result, 12979 on_off, "on#off"); 12980 12981 static void 12982 cmd_set_vf_mac_anti_spoof_parsed( 12983 void *parsed_result, 12984 __attribute__((unused)) struct cmdline *cl, 12985 __attribute__((unused)) void *data) 12986 { 12987 struct cmd_vf_mac_anti_spoof_result *res = parsed_result; 12988 int ret = -ENOTSUP; 12989 12990 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 12991 12992 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12993 return; 12994 12995 #ifdef RTE_LIBRTE_IXGBE_PMD 12996 if (ret == -ENOTSUP) 12997 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, 12998 res->vf_id, is_on); 12999 #endif 13000 #ifdef RTE_LIBRTE_I40E_PMD 13001 if (ret == -ENOTSUP) 13002 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id, 13003 res->vf_id, is_on); 13004 #endif 13005 #ifdef RTE_LIBRTE_BNXT_PMD 13006 if (ret == -ENOTSUP) 13007 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id, 13008 res->vf_id, is_on); 13009 #endif 13010 13011 switch (ret) { 13012 case 0: 13013 break; 13014 case -EINVAL: 13015 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13016 break; 13017 case -ENODEV: 13018 printf("invalid port_id %d\n", res->port_id); 13019 break; 13020 case -ENOTSUP: 13021 printf("function not implemented\n"); 13022 break; 13023 default: 13024 printf("programming error: (%s)\n", strerror(-ret)); 13025 } 13026 } 13027 13028 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = { 13029 .f = cmd_set_vf_mac_anti_spoof_parsed, 13030 .data = NULL, 13031 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off", 13032 .tokens = { 13033 (void *)&cmd_vf_mac_anti_spoof_set, 13034 (void *)&cmd_vf_mac_anti_spoof_vf, 13035 (void *)&cmd_vf_mac_anti_spoof_mac, 13036 (void *)&cmd_vf_mac_anti_spoof_antispoof, 13037 (void *)&cmd_vf_mac_anti_spoof_port_id, 13038 (void *)&cmd_vf_mac_anti_spoof_vf_id, 13039 (void *)&cmd_vf_mac_anti_spoof_on_off, 13040 NULL, 13041 }, 13042 }; 13043 13044 /* vf vlan strip queue configuration */ 13045 13046 /* Common result structure for vf mac anti spoof */ 13047 struct cmd_vf_vlan_stripq_result { 13048 cmdline_fixed_string_t set; 13049 cmdline_fixed_string_t vf; 13050 cmdline_fixed_string_t vlan; 13051 cmdline_fixed_string_t stripq; 13052 portid_t port_id; 13053 uint16_t vf_id; 13054 cmdline_fixed_string_t on_off; 13055 }; 13056 13057 /* Common CLI fields for vf vlan strip enable disable */ 13058 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set = 13059 TOKEN_STRING_INITIALIZER 13060 (struct cmd_vf_vlan_stripq_result, 13061 set, "set"); 13062 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf = 13063 TOKEN_STRING_INITIALIZER 13064 (struct cmd_vf_vlan_stripq_result, 13065 vf, "vf"); 13066 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan = 13067 TOKEN_STRING_INITIALIZER 13068 (struct cmd_vf_vlan_stripq_result, 13069 vlan, "vlan"); 13070 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq = 13071 TOKEN_STRING_INITIALIZER 13072 (struct cmd_vf_vlan_stripq_result, 13073 stripq, "stripq"); 13074 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id = 13075 TOKEN_NUM_INITIALIZER 13076 (struct cmd_vf_vlan_stripq_result, 13077 port_id, UINT16); 13078 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id = 13079 TOKEN_NUM_INITIALIZER 13080 (struct cmd_vf_vlan_stripq_result, 13081 vf_id, UINT16); 13082 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off = 13083 TOKEN_STRING_INITIALIZER 13084 (struct cmd_vf_vlan_stripq_result, 13085 on_off, "on#off"); 13086 13087 static void 13088 cmd_set_vf_vlan_stripq_parsed( 13089 void *parsed_result, 13090 __attribute__((unused)) struct cmdline *cl, 13091 __attribute__((unused)) void *data) 13092 { 13093 struct cmd_vf_vlan_stripq_result *res = parsed_result; 13094 int ret = -ENOTSUP; 13095 13096 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13097 13098 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13099 return; 13100 13101 #ifdef RTE_LIBRTE_IXGBE_PMD 13102 if (ret == -ENOTSUP) 13103 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, 13104 res->vf_id, is_on); 13105 #endif 13106 #ifdef RTE_LIBRTE_I40E_PMD 13107 if (ret == -ENOTSUP) 13108 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id, 13109 res->vf_id, is_on); 13110 #endif 13111 #ifdef RTE_LIBRTE_BNXT_PMD 13112 if (ret == -ENOTSUP) 13113 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id, 13114 res->vf_id, is_on); 13115 #endif 13116 13117 switch (ret) { 13118 case 0: 13119 break; 13120 case -EINVAL: 13121 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13122 break; 13123 case -ENODEV: 13124 printf("invalid port_id %d\n", res->port_id); 13125 break; 13126 case -ENOTSUP: 13127 printf("function not implemented\n"); 13128 break; 13129 default: 13130 printf("programming error: (%s)\n", strerror(-ret)); 13131 } 13132 } 13133 13134 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = { 13135 .f = cmd_set_vf_vlan_stripq_parsed, 13136 .data = NULL, 13137 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off", 13138 .tokens = { 13139 (void *)&cmd_vf_vlan_stripq_set, 13140 (void *)&cmd_vf_vlan_stripq_vf, 13141 (void *)&cmd_vf_vlan_stripq_vlan, 13142 (void *)&cmd_vf_vlan_stripq_stripq, 13143 (void *)&cmd_vf_vlan_stripq_port_id, 13144 (void *)&cmd_vf_vlan_stripq_vf_id, 13145 (void *)&cmd_vf_vlan_stripq_on_off, 13146 NULL, 13147 }, 13148 }; 13149 13150 /* vf vlan insert configuration */ 13151 13152 /* Common result structure for vf vlan insert */ 13153 struct cmd_vf_vlan_insert_result { 13154 cmdline_fixed_string_t set; 13155 cmdline_fixed_string_t vf; 13156 cmdline_fixed_string_t vlan; 13157 cmdline_fixed_string_t insert; 13158 portid_t port_id; 13159 uint16_t vf_id; 13160 uint16_t vlan_id; 13161 }; 13162 13163 /* Common CLI fields for vf vlan insert enable disable */ 13164 cmdline_parse_token_string_t cmd_vf_vlan_insert_set = 13165 TOKEN_STRING_INITIALIZER 13166 (struct cmd_vf_vlan_insert_result, 13167 set, "set"); 13168 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf = 13169 TOKEN_STRING_INITIALIZER 13170 (struct cmd_vf_vlan_insert_result, 13171 vf, "vf"); 13172 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan = 13173 TOKEN_STRING_INITIALIZER 13174 (struct cmd_vf_vlan_insert_result, 13175 vlan, "vlan"); 13176 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert = 13177 TOKEN_STRING_INITIALIZER 13178 (struct cmd_vf_vlan_insert_result, 13179 insert, "insert"); 13180 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id = 13181 TOKEN_NUM_INITIALIZER 13182 (struct cmd_vf_vlan_insert_result, 13183 port_id, UINT16); 13184 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id = 13185 TOKEN_NUM_INITIALIZER 13186 (struct cmd_vf_vlan_insert_result, 13187 vf_id, UINT16); 13188 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id = 13189 TOKEN_NUM_INITIALIZER 13190 (struct cmd_vf_vlan_insert_result, 13191 vlan_id, UINT16); 13192 13193 static void 13194 cmd_set_vf_vlan_insert_parsed( 13195 void *parsed_result, 13196 __attribute__((unused)) struct cmdline *cl, 13197 __attribute__((unused)) void *data) 13198 { 13199 struct cmd_vf_vlan_insert_result *res = parsed_result; 13200 int ret = -ENOTSUP; 13201 13202 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13203 return; 13204 13205 #ifdef RTE_LIBRTE_IXGBE_PMD 13206 if (ret == -ENOTSUP) 13207 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, 13208 res->vlan_id); 13209 #endif 13210 #ifdef RTE_LIBRTE_I40E_PMD 13211 if (ret == -ENOTSUP) 13212 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id, 13213 res->vlan_id); 13214 #endif 13215 #ifdef RTE_LIBRTE_BNXT_PMD 13216 if (ret == -ENOTSUP) 13217 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id, 13218 res->vlan_id); 13219 #endif 13220 13221 switch (ret) { 13222 case 0: 13223 break; 13224 case -EINVAL: 13225 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id); 13226 break; 13227 case -ENODEV: 13228 printf("invalid port_id %d\n", res->port_id); 13229 break; 13230 case -ENOTSUP: 13231 printf("function not implemented\n"); 13232 break; 13233 default: 13234 printf("programming error: (%s)\n", strerror(-ret)); 13235 } 13236 } 13237 13238 cmdline_parse_inst_t cmd_set_vf_vlan_insert = { 13239 .f = cmd_set_vf_vlan_insert_parsed, 13240 .data = NULL, 13241 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>", 13242 .tokens = { 13243 (void *)&cmd_vf_vlan_insert_set, 13244 (void *)&cmd_vf_vlan_insert_vf, 13245 (void *)&cmd_vf_vlan_insert_vlan, 13246 (void *)&cmd_vf_vlan_insert_insert, 13247 (void *)&cmd_vf_vlan_insert_port_id, 13248 (void *)&cmd_vf_vlan_insert_vf_id, 13249 (void *)&cmd_vf_vlan_insert_vlan_id, 13250 NULL, 13251 }, 13252 }; 13253 13254 /* tx loopback configuration */ 13255 13256 /* Common result structure for tx loopback */ 13257 struct cmd_tx_loopback_result { 13258 cmdline_fixed_string_t set; 13259 cmdline_fixed_string_t tx; 13260 cmdline_fixed_string_t loopback; 13261 portid_t port_id; 13262 cmdline_fixed_string_t on_off; 13263 }; 13264 13265 /* Common CLI fields for tx loopback enable disable */ 13266 cmdline_parse_token_string_t cmd_tx_loopback_set = 13267 TOKEN_STRING_INITIALIZER 13268 (struct cmd_tx_loopback_result, 13269 set, "set"); 13270 cmdline_parse_token_string_t cmd_tx_loopback_tx = 13271 TOKEN_STRING_INITIALIZER 13272 (struct cmd_tx_loopback_result, 13273 tx, "tx"); 13274 cmdline_parse_token_string_t cmd_tx_loopback_loopback = 13275 TOKEN_STRING_INITIALIZER 13276 (struct cmd_tx_loopback_result, 13277 loopback, "loopback"); 13278 cmdline_parse_token_num_t cmd_tx_loopback_port_id = 13279 TOKEN_NUM_INITIALIZER 13280 (struct cmd_tx_loopback_result, 13281 port_id, UINT16); 13282 cmdline_parse_token_string_t cmd_tx_loopback_on_off = 13283 TOKEN_STRING_INITIALIZER 13284 (struct cmd_tx_loopback_result, 13285 on_off, "on#off"); 13286 13287 static void 13288 cmd_set_tx_loopback_parsed( 13289 void *parsed_result, 13290 __attribute__((unused)) struct cmdline *cl, 13291 __attribute__((unused)) void *data) 13292 { 13293 struct cmd_tx_loopback_result *res = parsed_result; 13294 int ret = -ENOTSUP; 13295 13296 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13297 13298 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13299 return; 13300 13301 #ifdef RTE_LIBRTE_IXGBE_PMD 13302 if (ret == -ENOTSUP) 13303 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on); 13304 #endif 13305 #ifdef RTE_LIBRTE_I40E_PMD 13306 if (ret == -ENOTSUP) 13307 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on); 13308 #endif 13309 #ifdef RTE_LIBRTE_BNXT_PMD 13310 if (ret == -ENOTSUP) 13311 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on); 13312 #endif 13313 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD 13314 if (ret == -ENOTSUP) 13315 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on); 13316 #endif 13317 13318 switch (ret) { 13319 case 0: 13320 break; 13321 case -EINVAL: 13322 printf("invalid is_on %d\n", is_on); 13323 break; 13324 case -ENODEV: 13325 printf("invalid port_id %d\n", res->port_id); 13326 break; 13327 case -ENOTSUP: 13328 printf("function not implemented\n"); 13329 break; 13330 default: 13331 printf("programming error: (%s)\n", strerror(-ret)); 13332 } 13333 } 13334 13335 cmdline_parse_inst_t cmd_set_tx_loopback = { 13336 .f = cmd_set_tx_loopback_parsed, 13337 .data = NULL, 13338 .help_str = "set tx loopback <port_id> on|off", 13339 .tokens = { 13340 (void *)&cmd_tx_loopback_set, 13341 (void *)&cmd_tx_loopback_tx, 13342 (void *)&cmd_tx_loopback_loopback, 13343 (void *)&cmd_tx_loopback_port_id, 13344 (void *)&cmd_tx_loopback_on_off, 13345 NULL, 13346 }, 13347 }; 13348 13349 /* all queues drop enable configuration */ 13350 13351 /* Common result structure for all queues drop enable */ 13352 struct cmd_all_queues_drop_en_result { 13353 cmdline_fixed_string_t set; 13354 cmdline_fixed_string_t all; 13355 cmdline_fixed_string_t queues; 13356 cmdline_fixed_string_t drop; 13357 portid_t port_id; 13358 cmdline_fixed_string_t on_off; 13359 }; 13360 13361 /* Common CLI fields for tx loopback enable disable */ 13362 cmdline_parse_token_string_t cmd_all_queues_drop_en_set = 13363 TOKEN_STRING_INITIALIZER 13364 (struct cmd_all_queues_drop_en_result, 13365 set, "set"); 13366 cmdline_parse_token_string_t cmd_all_queues_drop_en_all = 13367 TOKEN_STRING_INITIALIZER 13368 (struct cmd_all_queues_drop_en_result, 13369 all, "all"); 13370 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues = 13371 TOKEN_STRING_INITIALIZER 13372 (struct cmd_all_queues_drop_en_result, 13373 queues, "queues"); 13374 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop = 13375 TOKEN_STRING_INITIALIZER 13376 (struct cmd_all_queues_drop_en_result, 13377 drop, "drop"); 13378 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id = 13379 TOKEN_NUM_INITIALIZER 13380 (struct cmd_all_queues_drop_en_result, 13381 port_id, UINT16); 13382 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off = 13383 TOKEN_STRING_INITIALIZER 13384 (struct cmd_all_queues_drop_en_result, 13385 on_off, "on#off"); 13386 13387 static void 13388 cmd_set_all_queues_drop_en_parsed( 13389 void *parsed_result, 13390 __attribute__((unused)) struct cmdline *cl, 13391 __attribute__((unused)) void *data) 13392 { 13393 struct cmd_all_queues_drop_en_result *res = parsed_result; 13394 int ret = -ENOTSUP; 13395 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13396 13397 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13398 return; 13399 13400 #ifdef RTE_LIBRTE_IXGBE_PMD 13401 if (ret == -ENOTSUP) 13402 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on); 13403 #endif 13404 #ifdef RTE_LIBRTE_BNXT_PMD 13405 if (ret == -ENOTSUP) 13406 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on); 13407 #endif 13408 switch (ret) { 13409 case 0: 13410 break; 13411 case -EINVAL: 13412 printf("invalid is_on %d\n", is_on); 13413 break; 13414 case -ENODEV: 13415 printf("invalid port_id %d\n", res->port_id); 13416 break; 13417 case -ENOTSUP: 13418 printf("function not implemented\n"); 13419 break; 13420 default: 13421 printf("programming error: (%s)\n", strerror(-ret)); 13422 } 13423 } 13424 13425 cmdline_parse_inst_t cmd_set_all_queues_drop_en = { 13426 .f = cmd_set_all_queues_drop_en_parsed, 13427 .data = NULL, 13428 .help_str = "set all queues drop <port_id> on|off", 13429 .tokens = { 13430 (void *)&cmd_all_queues_drop_en_set, 13431 (void *)&cmd_all_queues_drop_en_all, 13432 (void *)&cmd_all_queues_drop_en_queues, 13433 (void *)&cmd_all_queues_drop_en_drop, 13434 (void *)&cmd_all_queues_drop_en_port_id, 13435 (void *)&cmd_all_queues_drop_en_on_off, 13436 NULL, 13437 }, 13438 }; 13439 13440 /* vf split drop enable configuration */ 13441 13442 /* Common result structure for vf split drop enable */ 13443 struct cmd_vf_split_drop_en_result { 13444 cmdline_fixed_string_t set; 13445 cmdline_fixed_string_t vf; 13446 cmdline_fixed_string_t split; 13447 cmdline_fixed_string_t drop; 13448 portid_t port_id; 13449 uint16_t vf_id; 13450 cmdline_fixed_string_t on_off; 13451 }; 13452 13453 /* Common CLI fields for vf split drop enable disable */ 13454 cmdline_parse_token_string_t cmd_vf_split_drop_en_set = 13455 TOKEN_STRING_INITIALIZER 13456 (struct cmd_vf_split_drop_en_result, 13457 set, "set"); 13458 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf = 13459 TOKEN_STRING_INITIALIZER 13460 (struct cmd_vf_split_drop_en_result, 13461 vf, "vf"); 13462 cmdline_parse_token_string_t cmd_vf_split_drop_en_split = 13463 TOKEN_STRING_INITIALIZER 13464 (struct cmd_vf_split_drop_en_result, 13465 split, "split"); 13466 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop = 13467 TOKEN_STRING_INITIALIZER 13468 (struct cmd_vf_split_drop_en_result, 13469 drop, "drop"); 13470 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id = 13471 TOKEN_NUM_INITIALIZER 13472 (struct cmd_vf_split_drop_en_result, 13473 port_id, UINT16); 13474 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id = 13475 TOKEN_NUM_INITIALIZER 13476 (struct cmd_vf_split_drop_en_result, 13477 vf_id, UINT16); 13478 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off = 13479 TOKEN_STRING_INITIALIZER 13480 (struct cmd_vf_split_drop_en_result, 13481 on_off, "on#off"); 13482 13483 static void 13484 cmd_set_vf_split_drop_en_parsed( 13485 void *parsed_result, 13486 __attribute__((unused)) struct cmdline *cl, 13487 __attribute__((unused)) void *data) 13488 { 13489 struct cmd_vf_split_drop_en_result *res = parsed_result; 13490 int ret = -ENOTSUP; 13491 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13492 13493 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13494 return; 13495 13496 #ifdef RTE_LIBRTE_IXGBE_PMD 13497 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, 13498 is_on); 13499 #endif 13500 switch (ret) { 13501 case 0: 13502 break; 13503 case -EINVAL: 13504 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13505 break; 13506 case -ENODEV: 13507 printf("invalid port_id %d\n", res->port_id); 13508 break; 13509 case -ENOTSUP: 13510 printf("not supported on port %d\n", res->port_id); 13511 break; 13512 default: 13513 printf("programming error: (%s)\n", strerror(-ret)); 13514 } 13515 } 13516 13517 cmdline_parse_inst_t cmd_set_vf_split_drop_en = { 13518 .f = cmd_set_vf_split_drop_en_parsed, 13519 .data = NULL, 13520 .help_str = "set vf split drop <port_id> <vf_id> on|off", 13521 .tokens = { 13522 (void *)&cmd_vf_split_drop_en_set, 13523 (void *)&cmd_vf_split_drop_en_vf, 13524 (void *)&cmd_vf_split_drop_en_split, 13525 (void *)&cmd_vf_split_drop_en_drop, 13526 (void *)&cmd_vf_split_drop_en_port_id, 13527 (void *)&cmd_vf_split_drop_en_vf_id, 13528 (void *)&cmd_vf_split_drop_en_on_off, 13529 NULL, 13530 }, 13531 }; 13532 13533 /* vf mac address configuration */ 13534 13535 /* Common result structure for vf mac address */ 13536 struct cmd_set_vf_mac_addr_result { 13537 cmdline_fixed_string_t set; 13538 cmdline_fixed_string_t vf; 13539 cmdline_fixed_string_t mac; 13540 cmdline_fixed_string_t addr; 13541 portid_t port_id; 13542 uint16_t vf_id; 13543 struct ether_addr mac_addr; 13544 13545 }; 13546 13547 /* Common CLI fields for vf split drop enable disable */ 13548 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set = 13549 TOKEN_STRING_INITIALIZER 13550 (struct cmd_set_vf_mac_addr_result, 13551 set, "set"); 13552 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf = 13553 TOKEN_STRING_INITIALIZER 13554 (struct cmd_set_vf_mac_addr_result, 13555 vf, "vf"); 13556 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac = 13557 TOKEN_STRING_INITIALIZER 13558 (struct cmd_set_vf_mac_addr_result, 13559 mac, "mac"); 13560 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr = 13561 TOKEN_STRING_INITIALIZER 13562 (struct cmd_set_vf_mac_addr_result, 13563 addr, "addr"); 13564 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id = 13565 TOKEN_NUM_INITIALIZER 13566 (struct cmd_set_vf_mac_addr_result, 13567 port_id, UINT16); 13568 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id = 13569 TOKEN_NUM_INITIALIZER 13570 (struct cmd_set_vf_mac_addr_result, 13571 vf_id, UINT16); 13572 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr = 13573 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result, 13574 mac_addr); 13575 13576 static void 13577 cmd_set_vf_mac_addr_parsed( 13578 void *parsed_result, 13579 __attribute__((unused)) struct cmdline *cl, 13580 __attribute__((unused)) void *data) 13581 { 13582 struct cmd_set_vf_mac_addr_result *res = parsed_result; 13583 int ret = -ENOTSUP; 13584 13585 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13586 return; 13587 13588 #ifdef RTE_LIBRTE_IXGBE_PMD 13589 if (ret == -ENOTSUP) 13590 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, 13591 &res->mac_addr); 13592 #endif 13593 #ifdef RTE_LIBRTE_I40E_PMD 13594 if (ret == -ENOTSUP) 13595 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id, 13596 &res->mac_addr); 13597 #endif 13598 #ifdef RTE_LIBRTE_BNXT_PMD 13599 if (ret == -ENOTSUP) 13600 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id, 13601 &res->mac_addr); 13602 #endif 13603 13604 switch (ret) { 13605 case 0: 13606 break; 13607 case -EINVAL: 13608 printf("invalid vf_id %d or mac_addr\n", res->vf_id); 13609 break; 13610 case -ENODEV: 13611 printf("invalid port_id %d\n", res->port_id); 13612 break; 13613 case -ENOTSUP: 13614 printf("function not implemented\n"); 13615 break; 13616 default: 13617 printf("programming error: (%s)\n", strerror(-ret)); 13618 } 13619 } 13620 13621 cmdline_parse_inst_t cmd_set_vf_mac_addr = { 13622 .f = cmd_set_vf_mac_addr_parsed, 13623 .data = NULL, 13624 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>", 13625 .tokens = { 13626 (void *)&cmd_set_vf_mac_addr_set, 13627 (void *)&cmd_set_vf_mac_addr_vf, 13628 (void *)&cmd_set_vf_mac_addr_mac, 13629 (void *)&cmd_set_vf_mac_addr_addr, 13630 (void *)&cmd_set_vf_mac_addr_port_id, 13631 (void *)&cmd_set_vf_mac_addr_vf_id, 13632 (void *)&cmd_set_vf_mac_addr_mac_addr, 13633 NULL, 13634 }, 13635 }; 13636 13637 /* MACsec configuration */ 13638 13639 /* Common result structure for MACsec offload enable */ 13640 struct cmd_macsec_offload_on_result { 13641 cmdline_fixed_string_t set; 13642 cmdline_fixed_string_t macsec; 13643 cmdline_fixed_string_t offload; 13644 portid_t port_id; 13645 cmdline_fixed_string_t on; 13646 cmdline_fixed_string_t encrypt; 13647 cmdline_fixed_string_t en_on_off; 13648 cmdline_fixed_string_t replay_protect; 13649 cmdline_fixed_string_t rp_on_off; 13650 }; 13651 13652 /* Common CLI fields for MACsec offload disable */ 13653 cmdline_parse_token_string_t cmd_macsec_offload_on_set = 13654 TOKEN_STRING_INITIALIZER 13655 (struct cmd_macsec_offload_on_result, 13656 set, "set"); 13657 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec = 13658 TOKEN_STRING_INITIALIZER 13659 (struct cmd_macsec_offload_on_result, 13660 macsec, "macsec"); 13661 cmdline_parse_token_string_t cmd_macsec_offload_on_offload = 13662 TOKEN_STRING_INITIALIZER 13663 (struct cmd_macsec_offload_on_result, 13664 offload, "offload"); 13665 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id = 13666 TOKEN_NUM_INITIALIZER 13667 (struct cmd_macsec_offload_on_result, 13668 port_id, UINT16); 13669 cmdline_parse_token_string_t cmd_macsec_offload_on_on = 13670 TOKEN_STRING_INITIALIZER 13671 (struct cmd_macsec_offload_on_result, 13672 on, "on"); 13673 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt = 13674 TOKEN_STRING_INITIALIZER 13675 (struct cmd_macsec_offload_on_result, 13676 encrypt, "encrypt"); 13677 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off = 13678 TOKEN_STRING_INITIALIZER 13679 (struct cmd_macsec_offload_on_result, 13680 en_on_off, "on#off"); 13681 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect = 13682 TOKEN_STRING_INITIALIZER 13683 (struct cmd_macsec_offload_on_result, 13684 replay_protect, "replay-protect"); 13685 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off = 13686 TOKEN_STRING_INITIALIZER 13687 (struct cmd_macsec_offload_on_result, 13688 rp_on_off, "on#off"); 13689 13690 static void 13691 cmd_set_macsec_offload_on_parsed( 13692 void *parsed_result, 13693 __attribute__((unused)) struct cmdline *cl, 13694 __attribute__((unused)) void *data) 13695 { 13696 struct cmd_macsec_offload_on_result *res = parsed_result; 13697 int ret = -ENOTSUP; 13698 portid_t port_id = res->port_id; 13699 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; 13700 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; 13701 struct rte_eth_dev_info dev_info; 13702 13703 if (port_id_is_invalid(port_id, ENABLED_WARN)) 13704 return; 13705 if (!port_is_stopped(port_id)) { 13706 printf("Please stop port %d first\n", port_id); 13707 return; 13708 } 13709 13710 rte_eth_dev_info_get(port_id, &dev_info); 13711 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 13712 #ifdef RTE_LIBRTE_IXGBE_PMD 13713 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); 13714 #endif 13715 } 13716 RTE_SET_USED(en); 13717 RTE_SET_USED(rp); 13718 13719 switch (ret) { 13720 case 0: 13721 ports[port_id].dev_conf.txmode.offloads |= 13722 DEV_TX_OFFLOAD_MACSEC_INSERT; 13723 cmd_reconfig_device_queue(port_id, 1, 1); 13724 break; 13725 case -ENODEV: 13726 printf("invalid port_id %d\n", port_id); 13727 break; 13728 case -ENOTSUP: 13729 printf("not supported on port %d\n", port_id); 13730 break; 13731 default: 13732 printf("programming error: (%s)\n", strerror(-ret)); 13733 } 13734 } 13735 13736 cmdline_parse_inst_t cmd_set_macsec_offload_on = { 13737 .f = cmd_set_macsec_offload_on_parsed, 13738 .data = NULL, 13739 .help_str = "set macsec offload <port_id> on " 13740 "encrypt on|off replay-protect on|off", 13741 .tokens = { 13742 (void *)&cmd_macsec_offload_on_set, 13743 (void *)&cmd_macsec_offload_on_macsec, 13744 (void *)&cmd_macsec_offload_on_offload, 13745 (void *)&cmd_macsec_offload_on_port_id, 13746 (void *)&cmd_macsec_offload_on_on, 13747 (void *)&cmd_macsec_offload_on_encrypt, 13748 (void *)&cmd_macsec_offload_on_en_on_off, 13749 (void *)&cmd_macsec_offload_on_replay_protect, 13750 (void *)&cmd_macsec_offload_on_rp_on_off, 13751 NULL, 13752 }, 13753 }; 13754 13755 /* Common result structure for MACsec offload disable */ 13756 struct cmd_macsec_offload_off_result { 13757 cmdline_fixed_string_t set; 13758 cmdline_fixed_string_t macsec; 13759 cmdline_fixed_string_t offload; 13760 portid_t port_id; 13761 cmdline_fixed_string_t off; 13762 }; 13763 13764 /* Common CLI fields for MACsec offload disable */ 13765 cmdline_parse_token_string_t cmd_macsec_offload_off_set = 13766 TOKEN_STRING_INITIALIZER 13767 (struct cmd_macsec_offload_off_result, 13768 set, "set"); 13769 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec = 13770 TOKEN_STRING_INITIALIZER 13771 (struct cmd_macsec_offload_off_result, 13772 macsec, "macsec"); 13773 cmdline_parse_token_string_t cmd_macsec_offload_off_offload = 13774 TOKEN_STRING_INITIALIZER 13775 (struct cmd_macsec_offload_off_result, 13776 offload, "offload"); 13777 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id = 13778 TOKEN_NUM_INITIALIZER 13779 (struct cmd_macsec_offload_off_result, 13780 port_id, UINT16); 13781 cmdline_parse_token_string_t cmd_macsec_offload_off_off = 13782 TOKEN_STRING_INITIALIZER 13783 (struct cmd_macsec_offload_off_result, 13784 off, "off"); 13785 13786 static void 13787 cmd_set_macsec_offload_off_parsed( 13788 void *parsed_result, 13789 __attribute__((unused)) struct cmdline *cl, 13790 __attribute__((unused)) void *data) 13791 { 13792 struct cmd_macsec_offload_off_result *res = parsed_result; 13793 int ret = -ENOTSUP; 13794 struct rte_eth_dev_info dev_info; 13795 portid_t port_id = res->port_id; 13796 13797 if (port_id_is_invalid(port_id, ENABLED_WARN)) 13798 return; 13799 if (!port_is_stopped(port_id)) { 13800 printf("Please stop port %d first\n", port_id); 13801 return; 13802 } 13803 13804 rte_eth_dev_info_get(port_id, &dev_info); 13805 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 13806 #ifdef RTE_LIBRTE_IXGBE_PMD 13807 ret = rte_pmd_ixgbe_macsec_disable(port_id); 13808 #endif 13809 } 13810 switch (ret) { 13811 case 0: 13812 ports[port_id].dev_conf.txmode.offloads &= 13813 ~DEV_TX_OFFLOAD_MACSEC_INSERT; 13814 cmd_reconfig_device_queue(port_id, 1, 1); 13815 break; 13816 case -ENODEV: 13817 printf("invalid port_id %d\n", port_id); 13818 break; 13819 case -ENOTSUP: 13820 printf("not supported on port %d\n", port_id); 13821 break; 13822 default: 13823 printf("programming error: (%s)\n", strerror(-ret)); 13824 } 13825 } 13826 13827 cmdline_parse_inst_t cmd_set_macsec_offload_off = { 13828 .f = cmd_set_macsec_offload_off_parsed, 13829 .data = NULL, 13830 .help_str = "set macsec offload <port_id> off", 13831 .tokens = { 13832 (void *)&cmd_macsec_offload_off_set, 13833 (void *)&cmd_macsec_offload_off_macsec, 13834 (void *)&cmd_macsec_offload_off_offload, 13835 (void *)&cmd_macsec_offload_off_port_id, 13836 (void *)&cmd_macsec_offload_off_off, 13837 NULL, 13838 }, 13839 }; 13840 13841 /* Common result structure for MACsec secure connection configure */ 13842 struct cmd_macsec_sc_result { 13843 cmdline_fixed_string_t set; 13844 cmdline_fixed_string_t macsec; 13845 cmdline_fixed_string_t sc; 13846 cmdline_fixed_string_t tx_rx; 13847 portid_t port_id; 13848 struct ether_addr mac; 13849 uint16_t pi; 13850 }; 13851 13852 /* Common CLI fields for MACsec secure connection configure */ 13853 cmdline_parse_token_string_t cmd_macsec_sc_set = 13854 TOKEN_STRING_INITIALIZER 13855 (struct cmd_macsec_sc_result, 13856 set, "set"); 13857 cmdline_parse_token_string_t cmd_macsec_sc_macsec = 13858 TOKEN_STRING_INITIALIZER 13859 (struct cmd_macsec_sc_result, 13860 macsec, "macsec"); 13861 cmdline_parse_token_string_t cmd_macsec_sc_sc = 13862 TOKEN_STRING_INITIALIZER 13863 (struct cmd_macsec_sc_result, 13864 sc, "sc"); 13865 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx = 13866 TOKEN_STRING_INITIALIZER 13867 (struct cmd_macsec_sc_result, 13868 tx_rx, "tx#rx"); 13869 cmdline_parse_token_num_t cmd_macsec_sc_port_id = 13870 TOKEN_NUM_INITIALIZER 13871 (struct cmd_macsec_sc_result, 13872 port_id, UINT16); 13873 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac = 13874 TOKEN_ETHERADDR_INITIALIZER 13875 (struct cmd_macsec_sc_result, 13876 mac); 13877 cmdline_parse_token_num_t cmd_macsec_sc_pi = 13878 TOKEN_NUM_INITIALIZER 13879 (struct cmd_macsec_sc_result, 13880 pi, UINT16); 13881 13882 static void 13883 cmd_set_macsec_sc_parsed( 13884 void *parsed_result, 13885 __attribute__((unused)) struct cmdline *cl, 13886 __attribute__((unused)) void *data) 13887 { 13888 struct cmd_macsec_sc_result *res = parsed_result; 13889 int ret = -ENOTSUP; 13890 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 13891 13892 #ifdef RTE_LIBRTE_IXGBE_PMD 13893 ret = is_tx ? 13894 rte_pmd_ixgbe_macsec_config_txsc(res->port_id, 13895 res->mac.addr_bytes) : 13896 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, 13897 res->mac.addr_bytes, res->pi); 13898 #endif 13899 RTE_SET_USED(is_tx); 13900 13901 switch (ret) { 13902 case 0: 13903 break; 13904 case -ENODEV: 13905 printf("invalid port_id %d\n", res->port_id); 13906 break; 13907 case -ENOTSUP: 13908 printf("not supported on port %d\n", res->port_id); 13909 break; 13910 default: 13911 printf("programming error: (%s)\n", strerror(-ret)); 13912 } 13913 } 13914 13915 cmdline_parse_inst_t cmd_set_macsec_sc = { 13916 .f = cmd_set_macsec_sc_parsed, 13917 .data = NULL, 13918 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>", 13919 .tokens = { 13920 (void *)&cmd_macsec_sc_set, 13921 (void *)&cmd_macsec_sc_macsec, 13922 (void *)&cmd_macsec_sc_sc, 13923 (void *)&cmd_macsec_sc_tx_rx, 13924 (void *)&cmd_macsec_sc_port_id, 13925 (void *)&cmd_macsec_sc_mac, 13926 (void *)&cmd_macsec_sc_pi, 13927 NULL, 13928 }, 13929 }; 13930 13931 /* Common result structure for MACsec secure connection configure */ 13932 struct cmd_macsec_sa_result { 13933 cmdline_fixed_string_t set; 13934 cmdline_fixed_string_t macsec; 13935 cmdline_fixed_string_t sa; 13936 cmdline_fixed_string_t tx_rx; 13937 portid_t port_id; 13938 uint8_t idx; 13939 uint8_t an; 13940 uint32_t pn; 13941 cmdline_fixed_string_t key; 13942 }; 13943 13944 /* Common CLI fields for MACsec secure connection configure */ 13945 cmdline_parse_token_string_t cmd_macsec_sa_set = 13946 TOKEN_STRING_INITIALIZER 13947 (struct cmd_macsec_sa_result, 13948 set, "set"); 13949 cmdline_parse_token_string_t cmd_macsec_sa_macsec = 13950 TOKEN_STRING_INITIALIZER 13951 (struct cmd_macsec_sa_result, 13952 macsec, "macsec"); 13953 cmdline_parse_token_string_t cmd_macsec_sa_sa = 13954 TOKEN_STRING_INITIALIZER 13955 (struct cmd_macsec_sa_result, 13956 sa, "sa"); 13957 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx = 13958 TOKEN_STRING_INITIALIZER 13959 (struct cmd_macsec_sa_result, 13960 tx_rx, "tx#rx"); 13961 cmdline_parse_token_num_t cmd_macsec_sa_port_id = 13962 TOKEN_NUM_INITIALIZER 13963 (struct cmd_macsec_sa_result, 13964 port_id, UINT16); 13965 cmdline_parse_token_num_t cmd_macsec_sa_idx = 13966 TOKEN_NUM_INITIALIZER 13967 (struct cmd_macsec_sa_result, 13968 idx, UINT8); 13969 cmdline_parse_token_num_t cmd_macsec_sa_an = 13970 TOKEN_NUM_INITIALIZER 13971 (struct cmd_macsec_sa_result, 13972 an, UINT8); 13973 cmdline_parse_token_num_t cmd_macsec_sa_pn = 13974 TOKEN_NUM_INITIALIZER 13975 (struct cmd_macsec_sa_result, 13976 pn, UINT32); 13977 cmdline_parse_token_string_t cmd_macsec_sa_key = 13978 TOKEN_STRING_INITIALIZER 13979 (struct cmd_macsec_sa_result, 13980 key, NULL); 13981 13982 static void 13983 cmd_set_macsec_sa_parsed( 13984 void *parsed_result, 13985 __attribute__((unused)) struct cmdline *cl, 13986 __attribute__((unused)) void *data) 13987 { 13988 struct cmd_macsec_sa_result *res = parsed_result; 13989 int ret = -ENOTSUP; 13990 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 13991 uint8_t key[16] = { 0 }; 13992 uint8_t xdgt0; 13993 uint8_t xdgt1; 13994 int key_len; 13995 int i; 13996 13997 key_len = strlen(res->key) / 2; 13998 if (key_len > 16) 13999 key_len = 16; 14000 14001 for (i = 0; i < key_len; i++) { 14002 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 14003 if (xdgt0 == 0xFF) 14004 return; 14005 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 14006 if (xdgt1 == 0xFF) 14007 return; 14008 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 14009 } 14010 14011 #ifdef RTE_LIBRTE_IXGBE_PMD 14012 ret = is_tx ? 14013 rte_pmd_ixgbe_macsec_select_txsa(res->port_id, 14014 res->idx, res->an, res->pn, key) : 14015 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id, 14016 res->idx, res->an, res->pn, key); 14017 #endif 14018 RTE_SET_USED(is_tx); 14019 RTE_SET_USED(key); 14020 14021 switch (ret) { 14022 case 0: 14023 break; 14024 case -EINVAL: 14025 printf("invalid idx %d or an %d\n", res->idx, res->an); 14026 break; 14027 case -ENODEV: 14028 printf("invalid port_id %d\n", res->port_id); 14029 break; 14030 case -ENOTSUP: 14031 printf("not supported on port %d\n", res->port_id); 14032 break; 14033 default: 14034 printf("programming error: (%s)\n", strerror(-ret)); 14035 } 14036 } 14037 14038 cmdline_parse_inst_t cmd_set_macsec_sa = { 14039 .f = cmd_set_macsec_sa_parsed, 14040 .data = NULL, 14041 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>", 14042 .tokens = { 14043 (void *)&cmd_macsec_sa_set, 14044 (void *)&cmd_macsec_sa_macsec, 14045 (void *)&cmd_macsec_sa_sa, 14046 (void *)&cmd_macsec_sa_tx_rx, 14047 (void *)&cmd_macsec_sa_port_id, 14048 (void *)&cmd_macsec_sa_idx, 14049 (void *)&cmd_macsec_sa_an, 14050 (void *)&cmd_macsec_sa_pn, 14051 (void *)&cmd_macsec_sa_key, 14052 NULL, 14053 }, 14054 }; 14055 14056 /* VF unicast promiscuous mode configuration */ 14057 14058 /* Common result structure for VF unicast promiscuous mode */ 14059 struct cmd_vf_promisc_result { 14060 cmdline_fixed_string_t set; 14061 cmdline_fixed_string_t vf; 14062 cmdline_fixed_string_t promisc; 14063 portid_t port_id; 14064 uint32_t vf_id; 14065 cmdline_fixed_string_t on_off; 14066 }; 14067 14068 /* Common CLI fields for VF unicast promiscuous mode enable disable */ 14069 cmdline_parse_token_string_t cmd_vf_promisc_set = 14070 TOKEN_STRING_INITIALIZER 14071 (struct cmd_vf_promisc_result, 14072 set, "set"); 14073 cmdline_parse_token_string_t cmd_vf_promisc_vf = 14074 TOKEN_STRING_INITIALIZER 14075 (struct cmd_vf_promisc_result, 14076 vf, "vf"); 14077 cmdline_parse_token_string_t cmd_vf_promisc_promisc = 14078 TOKEN_STRING_INITIALIZER 14079 (struct cmd_vf_promisc_result, 14080 promisc, "promisc"); 14081 cmdline_parse_token_num_t cmd_vf_promisc_port_id = 14082 TOKEN_NUM_INITIALIZER 14083 (struct cmd_vf_promisc_result, 14084 port_id, UINT16); 14085 cmdline_parse_token_num_t cmd_vf_promisc_vf_id = 14086 TOKEN_NUM_INITIALIZER 14087 (struct cmd_vf_promisc_result, 14088 vf_id, UINT32); 14089 cmdline_parse_token_string_t cmd_vf_promisc_on_off = 14090 TOKEN_STRING_INITIALIZER 14091 (struct cmd_vf_promisc_result, 14092 on_off, "on#off"); 14093 14094 static void 14095 cmd_set_vf_promisc_parsed( 14096 void *parsed_result, 14097 __attribute__((unused)) struct cmdline *cl, 14098 __attribute__((unused)) void *data) 14099 { 14100 struct cmd_vf_promisc_result *res = parsed_result; 14101 int ret = -ENOTSUP; 14102 14103 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14104 14105 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14106 return; 14107 14108 #ifdef RTE_LIBRTE_I40E_PMD 14109 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id, 14110 res->vf_id, is_on); 14111 #endif 14112 14113 switch (ret) { 14114 case 0: 14115 break; 14116 case -EINVAL: 14117 printf("invalid vf_id %d\n", res->vf_id); 14118 break; 14119 case -ENODEV: 14120 printf("invalid port_id %d\n", res->port_id); 14121 break; 14122 case -ENOTSUP: 14123 printf("function not implemented\n"); 14124 break; 14125 default: 14126 printf("programming error: (%s)\n", strerror(-ret)); 14127 } 14128 } 14129 14130 cmdline_parse_inst_t cmd_set_vf_promisc = { 14131 .f = cmd_set_vf_promisc_parsed, 14132 .data = NULL, 14133 .help_str = "set vf promisc <port_id> <vf_id> on|off: " 14134 "Set unicast promiscuous mode for a VF from the PF", 14135 .tokens = { 14136 (void *)&cmd_vf_promisc_set, 14137 (void *)&cmd_vf_promisc_vf, 14138 (void *)&cmd_vf_promisc_promisc, 14139 (void *)&cmd_vf_promisc_port_id, 14140 (void *)&cmd_vf_promisc_vf_id, 14141 (void *)&cmd_vf_promisc_on_off, 14142 NULL, 14143 }, 14144 }; 14145 14146 /* VF multicast promiscuous mode configuration */ 14147 14148 /* Common result structure for VF multicast promiscuous mode */ 14149 struct cmd_vf_allmulti_result { 14150 cmdline_fixed_string_t set; 14151 cmdline_fixed_string_t vf; 14152 cmdline_fixed_string_t allmulti; 14153 portid_t port_id; 14154 uint32_t vf_id; 14155 cmdline_fixed_string_t on_off; 14156 }; 14157 14158 /* Common CLI fields for VF multicast promiscuous mode enable disable */ 14159 cmdline_parse_token_string_t cmd_vf_allmulti_set = 14160 TOKEN_STRING_INITIALIZER 14161 (struct cmd_vf_allmulti_result, 14162 set, "set"); 14163 cmdline_parse_token_string_t cmd_vf_allmulti_vf = 14164 TOKEN_STRING_INITIALIZER 14165 (struct cmd_vf_allmulti_result, 14166 vf, "vf"); 14167 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti = 14168 TOKEN_STRING_INITIALIZER 14169 (struct cmd_vf_allmulti_result, 14170 allmulti, "allmulti"); 14171 cmdline_parse_token_num_t cmd_vf_allmulti_port_id = 14172 TOKEN_NUM_INITIALIZER 14173 (struct cmd_vf_allmulti_result, 14174 port_id, UINT16); 14175 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id = 14176 TOKEN_NUM_INITIALIZER 14177 (struct cmd_vf_allmulti_result, 14178 vf_id, UINT32); 14179 cmdline_parse_token_string_t cmd_vf_allmulti_on_off = 14180 TOKEN_STRING_INITIALIZER 14181 (struct cmd_vf_allmulti_result, 14182 on_off, "on#off"); 14183 14184 static void 14185 cmd_set_vf_allmulti_parsed( 14186 void *parsed_result, 14187 __attribute__((unused)) struct cmdline *cl, 14188 __attribute__((unused)) void *data) 14189 { 14190 struct cmd_vf_allmulti_result *res = parsed_result; 14191 int ret = -ENOTSUP; 14192 14193 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14194 14195 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14196 return; 14197 14198 #ifdef RTE_LIBRTE_I40E_PMD 14199 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id, 14200 res->vf_id, is_on); 14201 #endif 14202 14203 switch (ret) { 14204 case 0: 14205 break; 14206 case -EINVAL: 14207 printf("invalid vf_id %d\n", res->vf_id); 14208 break; 14209 case -ENODEV: 14210 printf("invalid port_id %d\n", res->port_id); 14211 break; 14212 case -ENOTSUP: 14213 printf("function not implemented\n"); 14214 break; 14215 default: 14216 printf("programming error: (%s)\n", strerror(-ret)); 14217 } 14218 } 14219 14220 cmdline_parse_inst_t cmd_set_vf_allmulti = { 14221 .f = cmd_set_vf_allmulti_parsed, 14222 .data = NULL, 14223 .help_str = "set vf allmulti <port_id> <vf_id> on|off: " 14224 "Set multicast promiscuous mode for a VF from the PF", 14225 .tokens = { 14226 (void *)&cmd_vf_allmulti_set, 14227 (void *)&cmd_vf_allmulti_vf, 14228 (void *)&cmd_vf_allmulti_allmulti, 14229 (void *)&cmd_vf_allmulti_port_id, 14230 (void *)&cmd_vf_allmulti_vf_id, 14231 (void *)&cmd_vf_allmulti_on_off, 14232 NULL, 14233 }, 14234 }; 14235 14236 /* vf broadcast mode configuration */ 14237 14238 /* Common result structure for vf broadcast */ 14239 struct cmd_set_vf_broadcast_result { 14240 cmdline_fixed_string_t set; 14241 cmdline_fixed_string_t vf; 14242 cmdline_fixed_string_t broadcast; 14243 portid_t port_id; 14244 uint16_t vf_id; 14245 cmdline_fixed_string_t on_off; 14246 }; 14247 14248 /* Common CLI fields for vf broadcast enable disable */ 14249 cmdline_parse_token_string_t cmd_set_vf_broadcast_set = 14250 TOKEN_STRING_INITIALIZER 14251 (struct cmd_set_vf_broadcast_result, 14252 set, "set"); 14253 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf = 14254 TOKEN_STRING_INITIALIZER 14255 (struct cmd_set_vf_broadcast_result, 14256 vf, "vf"); 14257 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast = 14258 TOKEN_STRING_INITIALIZER 14259 (struct cmd_set_vf_broadcast_result, 14260 broadcast, "broadcast"); 14261 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id = 14262 TOKEN_NUM_INITIALIZER 14263 (struct cmd_set_vf_broadcast_result, 14264 port_id, UINT16); 14265 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id = 14266 TOKEN_NUM_INITIALIZER 14267 (struct cmd_set_vf_broadcast_result, 14268 vf_id, UINT16); 14269 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off = 14270 TOKEN_STRING_INITIALIZER 14271 (struct cmd_set_vf_broadcast_result, 14272 on_off, "on#off"); 14273 14274 static void 14275 cmd_set_vf_broadcast_parsed( 14276 void *parsed_result, 14277 __attribute__((unused)) struct cmdline *cl, 14278 __attribute__((unused)) void *data) 14279 { 14280 struct cmd_set_vf_broadcast_result *res = parsed_result; 14281 int ret = -ENOTSUP; 14282 14283 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14284 14285 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14286 return; 14287 14288 #ifdef RTE_LIBRTE_I40E_PMD 14289 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id, 14290 res->vf_id, is_on); 14291 #endif 14292 14293 switch (ret) { 14294 case 0: 14295 break; 14296 case -EINVAL: 14297 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14298 break; 14299 case -ENODEV: 14300 printf("invalid port_id %d\n", res->port_id); 14301 break; 14302 case -ENOTSUP: 14303 printf("function not implemented\n"); 14304 break; 14305 default: 14306 printf("programming error: (%s)\n", strerror(-ret)); 14307 } 14308 } 14309 14310 cmdline_parse_inst_t cmd_set_vf_broadcast = { 14311 .f = cmd_set_vf_broadcast_parsed, 14312 .data = NULL, 14313 .help_str = "set vf broadcast <port_id> <vf_id> on|off", 14314 .tokens = { 14315 (void *)&cmd_set_vf_broadcast_set, 14316 (void *)&cmd_set_vf_broadcast_vf, 14317 (void *)&cmd_set_vf_broadcast_broadcast, 14318 (void *)&cmd_set_vf_broadcast_port_id, 14319 (void *)&cmd_set_vf_broadcast_vf_id, 14320 (void *)&cmd_set_vf_broadcast_on_off, 14321 NULL, 14322 }, 14323 }; 14324 14325 /* vf vlan tag configuration */ 14326 14327 /* Common result structure for vf vlan tag */ 14328 struct cmd_set_vf_vlan_tag_result { 14329 cmdline_fixed_string_t set; 14330 cmdline_fixed_string_t vf; 14331 cmdline_fixed_string_t vlan; 14332 cmdline_fixed_string_t tag; 14333 portid_t port_id; 14334 uint16_t vf_id; 14335 cmdline_fixed_string_t on_off; 14336 }; 14337 14338 /* Common CLI fields for vf vlan tag enable disable */ 14339 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set = 14340 TOKEN_STRING_INITIALIZER 14341 (struct cmd_set_vf_vlan_tag_result, 14342 set, "set"); 14343 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf = 14344 TOKEN_STRING_INITIALIZER 14345 (struct cmd_set_vf_vlan_tag_result, 14346 vf, "vf"); 14347 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan = 14348 TOKEN_STRING_INITIALIZER 14349 (struct cmd_set_vf_vlan_tag_result, 14350 vlan, "vlan"); 14351 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag = 14352 TOKEN_STRING_INITIALIZER 14353 (struct cmd_set_vf_vlan_tag_result, 14354 tag, "tag"); 14355 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id = 14356 TOKEN_NUM_INITIALIZER 14357 (struct cmd_set_vf_vlan_tag_result, 14358 port_id, UINT16); 14359 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id = 14360 TOKEN_NUM_INITIALIZER 14361 (struct cmd_set_vf_vlan_tag_result, 14362 vf_id, UINT16); 14363 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off = 14364 TOKEN_STRING_INITIALIZER 14365 (struct cmd_set_vf_vlan_tag_result, 14366 on_off, "on#off"); 14367 14368 static void 14369 cmd_set_vf_vlan_tag_parsed( 14370 void *parsed_result, 14371 __attribute__((unused)) struct cmdline *cl, 14372 __attribute__((unused)) void *data) 14373 { 14374 struct cmd_set_vf_vlan_tag_result *res = parsed_result; 14375 int ret = -ENOTSUP; 14376 14377 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14378 14379 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14380 return; 14381 14382 #ifdef RTE_LIBRTE_I40E_PMD 14383 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id, 14384 res->vf_id, is_on); 14385 #endif 14386 14387 switch (ret) { 14388 case 0: 14389 break; 14390 case -EINVAL: 14391 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14392 break; 14393 case -ENODEV: 14394 printf("invalid port_id %d\n", res->port_id); 14395 break; 14396 case -ENOTSUP: 14397 printf("function not implemented\n"); 14398 break; 14399 default: 14400 printf("programming error: (%s)\n", strerror(-ret)); 14401 } 14402 } 14403 14404 cmdline_parse_inst_t cmd_set_vf_vlan_tag = { 14405 .f = cmd_set_vf_vlan_tag_parsed, 14406 .data = NULL, 14407 .help_str = "set vf vlan tag <port_id> <vf_id> on|off", 14408 .tokens = { 14409 (void *)&cmd_set_vf_vlan_tag_set, 14410 (void *)&cmd_set_vf_vlan_tag_vf, 14411 (void *)&cmd_set_vf_vlan_tag_vlan, 14412 (void *)&cmd_set_vf_vlan_tag_tag, 14413 (void *)&cmd_set_vf_vlan_tag_port_id, 14414 (void *)&cmd_set_vf_vlan_tag_vf_id, 14415 (void *)&cmd_set_vf_vlan_tag_on_off, 14416 NULL, 14417 }, 14418 }; 14419 14420 /* Common definition of VF and TC TX bandwidth configuration */ 14421 struct cmd_vf_tc_bw_result { 14422 cmdline_fixed_string_t set; 14423 cmdline_fixed_string_t vf; 14424 cmdline_fixed_string_t tc; 14425 cmdline_fixed_string_t tx; 14426 cmdline_fixed_string_t min_bw; 14427 cmdline_fixed_string_t max_bw; 14428 cmdline_fixed_string_t strict_link_prio; 14429 portid_t port_id; 14430 uint16_t vf_id; 14431 uint8_t tc_no; 14432 uint32_t bw; 14433 cmdline_fixed_string_t bw_list; 14434 uint8_t tc_map; 14435 }; 14436 14437 cmdline_parse_token_string_t cmd_vf_tc_bw_set = 14438 TOKEN_STRING_INITIALIZER 14439 (struct cmd_vf_tc_bw_result, 14440 set, "set"); 14441 cmdline_parse_token_string_t cmd_vf_tc_bw_vf = 14442 TOKEN_STRING_INITIALIZER 14443 (struct cmd_vf_tc_bw_result, 14444 vf, "vf"); 14445 cmdline_parse_token_string_t cmd_vf_tc_bw_tc = 14446 TOKEN_STRING_INITIALIZER 14447 (struct cmd_vf_tc_bw_result, 14448 tc, "tc"); 14449 cmdline_parse_token_string_t cmd_vf_tc_bw_tx = 14450 TOKEN_STRING_INITIALIZER 14451 (struct cmd_vf_tc_bw_result, 14452 tx, "tx"); 14453 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio = 14454 TOKEN_STRING_INITIALIZER 14455 (struct cmd_vf_tc_bw_result, 14456 strict_link_prio, "strict-link-priority"); 14457 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw = 14458 TOKEN_STRING_INITIALIZER 14459 (struct cmd_vf_tc_bw_result, 14460 min_bw, "min-bandwidth"); 14461 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw = 14462 TOKEN_STRING_INITIALIZER 14463 (struct cmd_vf_tc_bw_result, 14464 max_bw, "max-bandwidth"); 14465 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id = 14466 TOKEN_NUM_INITIALIZER 14467 (struct cmd_vf_tc_bw_result, 14468 port_id, UINT16); 14469 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id = 14470 TOKEN_NUM_INITIALIZER 14471 (struct cmd_vf_tc_bw_result, 14472 vf_id, UINT16); 14473 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no = 14474 TOKEN_NUM_INITIALIZER 14475 (struct cmd_vf_tc_bw_result, 14476 tc_no, UINT8); 14477 cmdline_parse_token_num_t cmd_vf_tc_bw_bw = 14478 TOKEN_NUM_INITIALIZER 14479 (struct cmd_vf_tc_bw_result, 14480 bw, UINT32); 14481 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list = 14482 TOKEN_STRING_INITIALIZER 14483 (struct cmd_vf_tc_bw_result, 14484 bw_list, NULL); 14485 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map = 14486 TOKEN_NUM_INITIALIZER 14487 (struct cmd_vf_tc_bw_result, 14488 tc_map, UINT8); 14489 14490 /* VF max bandwidth setting */ 14491 static void 14492 cmd_vf_max_bw_parsed( 14493 void *parsed_result, 14494 __attribute__((unused)) struct cmdline *cl, 14495 __attribute__((unused)) void *data) 14496 { 14497 struct cmd_vf_tc_bw_result *res = parsed_result; 14498 int ret = -ENOTSUP; 14499 14500 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14501 return; 14502 14503 #ifdef RTE_LIBRTE_I40E_PMD 14504 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id, 14505 res->vf_id, res->bw); 14506 #endif 14507 14508 switch (ret) { 14509 case 0: 14510 break; 14511 case -EINVAL: 14512 printf("invalid vf_id %d or bandwidth %d\n", 14513 res->vf_id, res->bw); 14514 break; 14515 case -ENODEV: 14516 printf("invalid port_id %d\n", res->port_id); 14517 break; 14518 case -ENOTSUP: 14519 printf("function not implemented\n"); 14520 break; 14521 default: 14522 printf("programming error: (%s)\n", strerror(-ret)); 14523 } 14524 } 14525 14526 cmdline_parse_inst_t cmd_vf_max_bw = { 14527 .f = cmd_vf_max_bw_parsed, 14528 .data = NULL, 14529 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>", 14530 .tokens = { 14531 (void *)&cmd_vf_tc_bw_set, 14532 (void *)&cmd_vf_tc_bw_vf, 14533 (void *)&cmd_vf_tc_bw_tx, 14534 (void *)&cmd_vf_tc_bw_max_bw, 14535 (void *)&cmd_vf_tc_bw_port_id, 14536 (void *)&cmd_vf_tc_bw_vf_id, 14537 (void *)&cmd_vf_tc_bw_bw, 14538 NULL, 14539 }, 14540 }; 14541 14542 static int 14543 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list, 14544 uint8_t *tc_num, 14545 char *str) 14546 { 14547 uint32_t size; 14548 const char *p, *p0 = str; 14549 char s[256]; 14550 char *end; 14551 char *str_fld[16]; 14552 uint16_t i; 14553 int ret; 14554 14555 p = strchr(p0, '('); 14556 if (p == NULL) { 14557 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 14558 return -1; 14559 } 14560 p++; 14561 p0 = strchr(p, ')'); 14562 if (p0 == NULL) { 14563 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 14564 return -1; 14565 } 14566 size = p0 - p; 14567 if (size >= sizeof(s)) { 14568 printf("The string size exceeds the internal buffer size\n"); 14569 return -1; 14570 } 14571 snprintf(s, sizeof(s), "%.*s", size, p); 14572 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ','); 14573 if (ret <= 0) { 14574 printf("Failed to get the bandwidth list. "); 14575 return -1; 14576 } 14577 *tc_num = ret; 14578 for (i = 0; i < ret; i++) 14579 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0); 14580 14581 return 0; 14582 } 14583 14584 /* TC min bandwidth setting */ 14585 static void 14586 cmd_vf_tc_min_bw_parsed( 14587 void *parsed_result, 14588 __attribute__((unused)) struct cmdline *cl, 14589 __attribute__((unused)) void *data) 14590 { 14591 struct cmd_vf_tc_bw_result *res = parsed_result; 14592 uint8_t tc_num; 14593 uint8_t bw[16]; 14594 int ret = -ENOTSUP; 14595 14596 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14597 return; 14598 14599 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 14600 if (ret) 14601 return; 14602 14603 #ifdef RTE_LIBRTE_I40E_PMD 14604 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id, 14605 tc_num, bw); 14606 #endif 14607 14608 switch (ret) { 14609 case 0: 14610 break; 14611 case -EINVAL: 14612 printf("invalid vf_id %d or bandwidth\n", res->vf_id); 14613 break; 14614 case -ENODEV: 14615 printf("invalid port_id %d\n", res->port_id); 14616 break; 14617 case -ENOTSUP: 14618 printf("function not implemented\n"); 14619 break; 14620 default: 14621 printf("programming error: (%s)\n", strerror(-ret)); 14622 } 14623 } 14624 14625 cmdline_parse_inst_t cmd_vf_tc_min_bw = { 14626 .f = cmd_vf_tc_min_bw_parsed, 14627 .data = NULL, 14628 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>" 14629 " <bw1, bw2, ...>", 14630 .tokens = { 14631 (void *)&cmd_vf_tc_bw_set, 14632 (void *)&cmd_vf_tc_bw_vf, 14633 (void *)&cmd_vf_tc_bw_tc, 14634 (void *)&cmd_vf_tc_bw_tx, 14635 (void *)&cmd_vf_tc_bw_min_bw, 14636 (void *)&cmd_vf_tc_bw_port_id, 14637 (void *)&cmd_vf_tc_bw_vf_id, 14638 (void *)&cmd_vf_tc_bw_bw_list, 14639 NULL, 14640 }, 14641 }; 14642 14643 static void 14644 cmd_tc_min_bw_parsed( 14645 void *parsed_result, 14646 __attribute__((unused)) struct cmdline *cl, 14647 __attribute__((unused)) void *data) 14648 { 14649 struct cmd_vf_tc_bw_result *res = parsed_result; 14650 struct rte_port *port; 14651 uint8_t tc_num; 14652 uint8_t bw[16]; 14653 int ret = -ENOTSUP; 14654 14655 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14656 return; 14657 14658 port = &ports[res->port_id]; 14659 /** Check if the port is not started **/ 14660 if (port->port_status != RTE_PORT_STOPPED) { 14661 printf("Please stop port %d first\n", res->port_id); 14662 return; 14663 } 14664 14665 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 14666 if (ret) 14667 return; 14668 14669 #ifdef RTE_LIBRTE_IXGBE_PMD 14670 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw); 14671 #endif 14672 14673 switch (ret) { 14674 case 0: 14675 break; 14676 case -EINVAL: 14677 printf("invalid bandwidth\n"); 14678 break; 14679 case -ENODEV: 14680 printf("invalid port_id %d\n", res->port_id); 14681 break; 14682 case -ENOTSUP: 14683 printf("function not implemented\n"); 14684 break; 14685 default: 14686 printf("programming error: (%s)\n", strerror(-ret)); 14687 } 14688 } 14689 14690 cmdline_parse_inst_t cmd_tc_min_bw = { 14691 .f = cmd_tc_min_bw_parsed, 14692 .data = NULL, 14693 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>", 14694 .tokens = { 14695 (void *)&cmd_vf_tc_bw_set, 14696 (void *)&cmd_vf_tc_bw_tc, 14697 (void *)&cmd_vf_tc_bw_tx, 14698 (void *)&cmd_vf_tc_bw_min_bw, 14699 (void *)&cmd_vf_tc_bw_port_id, 14700 (void *)&cmd_vf_tc_bw_bw_list, 14701 NULL, 14702 }, 14703 }; 14704 14705 /* TC max bandwidth setting */ 14706 static void 14707 cmd_vf_tc_max_bw_parsed( 14708 void *parsed_result, 14709 __attribute__((unused)) struct cmdline *cl, 14710 __attribute__((unused)) void *data) 14711 { 14712 struct cmd_vf_tc_bw_result *res = parsed_result; 14713 int ret = -ENOTSUP; 14714 14715 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14716 return; 14717 14718 #ifdef RTE_LIBRTE_I40E_PMD 14719 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id, 14720 res->tc_no, res->bw); 14721 #endif 14722 14723 switch (ret) { 14724 case 0: 14725 break; 14726 case -EINVAL: 14727 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n", 14728 res->vf_id, res->tc_no, res->bw); 14729 break; 14730 case -ENODEV: 14731 printf("invalid port_id %d\n", res->port_id); 14732 break; 14733 case -ENOTSUP: 14734 printf("function not implemented\n"); 14735 break; 14736 default: 14737 printf("programming error: (%s)\n", strerror(-ret)); 14738 } 14739 } 14740 14741 cmdline_parse_inst_t cmd_vf_tc_max_bw = { 14742 .f = cmd_vf_tc_max_bw_parsed, 14743 .data = NULL, 14744 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>" 14745 " <bandwidth>", 14746 .tokens = { 14747 (void *)&cmd_vf_tc_bw_set, 14748 (void *)&cmd_vf_tc_bw_vf, 14749 (void *)&cmd_vf_tc_bw_tc, 14750 (void *)&cmd_vf_tc_bw_tx, 14751 (void *)&cmd_vf_tc_bw_max_bw, 14752 (void *)&cmd_vf_tc_bw_port_id, 14753 (void *)&cmd_vf_tc_bw_vf_id, 14754 (void *)&cmd_vf_tc_bw_tc_no, 14755 (void *)&cmd_vf_tc_bw_bw, 14756 NULL, 14757 }, 14758 }; 14759 14760 14761 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 14762 14763 /* *** Set Port default Traffic Management Hierarchy *** */ 14764 struct cmd_set_port_tm_hierarchy_default_result { 14765 cmdline_fixed_string_t set; 14766 cmdline_fixed_string_t port; 14767 cmdline_fixed_string_t tm; 14768 cmdline_fixed_string_t hierarchy; 14769 cmdline_fixed_string_t def; 14770 portid_t port_id; 14771 }; 14772 14773 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set = 14774 TOKEN_STRING_INITIALIZER( 14775 struct cmd_set_port_tm_hierarchy_default_result, set, "set"); 14776 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port = 14777 TOKEN_STRING_INITIALIZER( 14778 struct cmd_set_port_tm_hierarchy_default_result, port, "port"); 14779 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm = 14780 TOKEN_STRING_INITIALIZER( 14781 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm"); 14782 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy = 14783 TOKEN_STRING_INITIALIZER( 14784 struct cmd_set_port_tm_hierarchy_default_result, 14785 hierarchy, "hierarchy"); 14786 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default = 14787 TOKEN_STRING_INITIALIZER( 14788 struct cmd_set_port_tm_hierarchy_default_result, 14789 def, "default"); 14790 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id = 14791 TOKEN_NUM_INITIALIZER( 14792 struct cmd_set_port_tm_hierarchy_default_result, 14793 port_id, UINT16); 14794 14795 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result, 14796 __attribute__((unused)) struct cmdline *cl, 14797 __attribute__((unused)) void *data) 14798 { 14799 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result; 14800 struct rte_port *p; 14801 portid_t port_id = res->port_id; 14802 14803 if (port_id_is_invalid(port_id, ENABLED_WARN)) 14804 return; 14805 14806 p = &ports[port_id]; 14807 14808 /* Port tm flag */ 14809 if (p->softport.tm_flag == 0) { 14810 printf(" tm not enabled on port %u (error)\n", port_id); 14811 return; 14812 } 14813 14814 /* Forward mode: tm */ 14815 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "tm")) { 14816 printf(" tm mode not enabled(error)\n"); 14817 return; 14818 } 14819 14820 /* Set the default tm hierarchy */ 14821 p->softport.tm.default_hierarchy_enable = 1; 14822 } 14823 14824 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = { 14825 .f = cmd_set_port_tm_hierarchy_default_parsed, 14826 .data = NULL, 14827 .help_str = "set port tm hierarchy default <port_id>", 14828 .tokens = { 14829 (void *)&cmd_set_port_tm_hierarchy_default_set, 14830 (void *)&cmd_set_port_tm_hierarchy_default_port, 14831 (void *)&cmd_set_port_tm_hierarchy_default_tm, 14832 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy, 14833 (void *)&cmd_set_port_tm_hierarchy_default_default, 14834 (void *)&cmd_set_port_tm_hierarchy_default_port_id, 14835 NULL, 14836 }, 14837 }; 14838 #endif 14839 14840 /* Strict link priority scheduling mode setting */ 14841 static void 14842 cmd_strict_link_prio_parsed( 14843 void *parsed_result, 14844 __attribute__((unused)) struct cmdline *cl, 14845 __attribute__((unused)) void *data) 14846 { 14847 struct cmd_vf_tc_bw_result *res = parsed_result; 14848 int ret = -ENOTSUP; 14849 14850 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14851 return; 14852 14853 #ifdef RTE_LIBRTE_I40E_PMD 14854 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map); 14855 #endif 14856 14857 switch (ret) { 14858 case 0: 14859 break; 14860 case -EINVAL: 14861 printf("invalid tc_bitmap 0x%x\n", res->tc_map); 14862 break; 14863 case -ENODEV: 14864 printf("invalid port_id %d\n", res->port_id); 14865 break; 14866 case -ENOTSUP: 14867 printf("function not implemented\n"); 14868 break; 14869 default: 14870 printf("programming error: (%s)\n", strerror(-ret)); 14871 } 14872 } 14873 14874 cmdline_parse_inst_t cmd_strict_link_prio = { 14875 .f = cmd_strict_link_prio_parsed, 14876 .data = NULL, 14877 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>", 14878 .tokens = { 14879 (void *)&cmd_vf_tc_bw_set, 14880 (void *)&cmd_vf_tc_bw_tx, 14881 (void *)&cmd_vf_tc_bw_strict_link_prio, 14882 (void *)&cmd_vf_tc_bw_port_id, 14883 (void *)&cmd_vf_tc_bw_tc_map, 14884 NULL, 14885 }, 14886 }; 14887 14888 /* Load dynamic device personalization*/ 14889 struct cmd_ddp_add_result { 14890 cmdline_fixed_string_t ddp; 14891 cmdline_fixed_string_t add; 14892 portid_t port_id; 14893 char filepath[]; 14894 }; 14895 14896 cmdline_parse_token_string_t cmd_ddp_add_ddp = 14897 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp"); 14898 cmdline_parse_token_string_t cmd_ddp_add_add = 14899 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add"); 14900 cmdline_parse_token_num_t cmd_ddp_add_port_id = 14901 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16); 14902 cmdline_parse_token_string_t cmd_ddp_add_filepath = 14903 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL); 14904 14905 static void 14906 cmd_ddp_add_parsed( 14907 void *parsed_result, 14908 __attribute__((unused)) struct cmdline *cl, 14909 __attribute__((unused)) void *data) 14910 { 14911 struct cmd_ddp_add_result *res = parsed_result; 14912 uint8_t *buff; 14913 uint32_t size; 14914 char *filepath; 14915 char *file_fld[2]; 14916 int file_num; 14917 int ret = -ENOTSUP; 14918 14919 if (!all_ports_stopped()) { 14920 printf("Please stop all ports first\n"); 14921 return; 14922 } 14923 14924 filepath = strdup(res->filepath); 14925 if (filepath == NULL) { 14926 printf("Failed to allocate memory\n"); 14927 return; 14928 } 14929 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ','); 14930 14931 buff = open_file(file_fld[0], &size); 14932 if (!buff) { 14933 free((void *)filepath); 14934 return; 14935 } 14936 14937 #ifdef RTE_LIBRTE_I40E_PMD 14938 if (ret == -ENOTSUP) 14939 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 14940 buff, size, 14941 RTE_PMD_I40E_PKG_OP_WR_ADD); 14942 #endif 14943 14944 if (ret == -EEXIST) 14945 printf("Profile has already existed.\n"); 14946 else if (ret < 0) 14947 printf("Failed to load profile.\n"); 14948 else if (file_num == 2) 14949 save_file(file_fld[1], buff, size); 14950 14951 close_file(buff); 14952 free((void *)filepath); 14953 } 14954 14955 cmdline_parse_inst_t cmd_ddp_add = { 14956 .f = cmd_ddp_add_parsed, 14957 .data = NULL, 14958 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>", 14959 .tokens = { 14960 (void *)&cmd_ddp_add_ddp, 14961 (void *)&cmd_ddp_add_add, 14962 (void *)&cmd_ddp_add_port_id, 14963 (void *)&cmd_ddp_add_filepath, 14964 NULL, 14965 }, 14966 }; 14967 14968 /* Delete dynamic device personalization*/ 14969 struct cmd_ddp_del_result { 14970 cmdline_fixed_string_t ddp; 14971 cmdline_fixed_string_t del; 14972 portid_t port_id; 14973 char filepath[]; 14974 }; 14975 14976 cmdline_parse_token_string_t cmd_ddp_del_ddp = 14977 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp"); 14978 cmdline_parse_token_string_t cmd_ddp_del_del = 14979 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del"); 14980 cmdline_parse_token_num_t cmd_ddp_del_port_id = 14981 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16); 14982 cmdline_parse_token_string_t cmd_ddp_del_filepath = 14983 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL); 14984 14985 static void 14986 cmd_ddp_del_parsed( 14987 void *parsed_result, 14988 __attribute__((unused)) struct cmdline *cl, 14989 __attribute__((unused)) void *data) 14990 { 14991 struct cmd_ddp_del_result *res = parsed_result; 14992 uint8_t *buff; 14993 uint32_t size; 14994 int ret = -ENOTSUP; 14995 14996 if (!all_ports_stopped()) { 14997 printf("Please stop all ports first\n"); 14998 return; 14999 } 15000 15001 buff = open_file(res->filepath, &size); 15002 if (!buff) 15003 return; 15004 15005 #ifdef RTE_LIBRTE_I40E_PMD 15006 if (ret == -ENOTSUP) 15007 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 15008 buff, size, 15009 RTE_PMD_I40E_PKG_OP_WR_DEL); 15010 #endif 15011 15012 if (ret == -EACCES) 15013 printf("Profile does not exist.\n"); 15014 else if (ret < 0) 15015 printf("Failed to delete profile.\n"); 15016 15017 close_file(buff); 15018 } 15019 15020 cmdline_parse_inst_t cmd_ddp_del = { 15021 .f = cmd_ddp_del_parsed, 15022 .data = NULL, 15023 .help_str = "ddp del <port_id> <backup_profile_path>", 15024 .tokens = { 15025 (void *)&cmd_ddp_del_ddp, 15026 (void *)&cmd_ddp_del_del, 15027 (void *)&cmd_ddp_del_port_id, 15028 (void *)&cmd_ddp_del_filepath, 15029 NULL, 15030 }, 15031 }; 15032 15033 /* Get dynamic device personalization profile info */ 15034 struct cmd_ddp_info_result { 15035 cmdline_fixed_string_t ddp; 15036 cmdline_fixed_string_t get; 15037 cmdline_fixed_string_t info; 15038 char filepath[]; 15039 }; 15040 15041 cmdline_parse_token_string_t cmd_ddp_info_ddp = 15042 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp"); 15043 cmdline_parse_token_string_t cmd_ddp_info_get = 15044 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get"); 15045 cmdline_parse_token_string_t cmd_ddp_info_info = 15046 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info"); 15047 cmdline_parse_token_string_t cmd_ddp_info_filepath = 15048 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL); 15049 15050 static void 15051 cmd_ddp_info_parsed( 15052 void *parsed_result, 15053 __attribute__((unused)) struct cmdline *cl, 15054 __attribute__((unused)) void *data) 15055 { 15056 struct cmd_ddp_info_result *res = parsed_result; 15057 uint8_t *pkg; 15058 uint32_t pkg_size; 15059 int ret = -ENOTSUP; 15060 #ifdef RTE_LIBRTE_I40E_PMD 15061 uint32_t i, j, n; 15062 uint8_t *buff; 15063 uint32_t buff_size = 0; 15064 struct rte_pmd_i40e_profile_info info; 15065 uint32_t dev_num = 0; 15066 struct rte_pmd_i40e_ddp_device_id *devs; 15067 uint32_t proto_num = 0; 15068 struct rte_pmd_i40e_proto_info *proto = NULL; 15069 uint32_t pctype_num = 0; 15070 struct rte_pmd_i40e_ptype_info *pctype; 15071 uint32_t ptype_num = 0; 15072 struct rte_pmd_i40e_ptype_info *ptype; 15073 uint8_t proto_id; 15074 15075 #endif 15076 15077 pkg = open_file(res->filepath, &pkg_size); 15078 if (!pkg) 15079 return; 15080 15081 #ifdef RTE_LIBRTE_I40E_PMD 15082 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15083 (uint8_t *)&info, sizeof(info), 15084 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER); 15085 if (!ret) { 15086 printf("Global Track id: 0x%x\n", info.track_id); 15087 printf("Global Version: %d.%d.%d.%d\n", 15088 info.version.major, 15089 info.version.minor, 15090 info.version.update, 15091 info.version.draft); 15092 printf("Global Package name: %s\n\n", info.name); 15093 } 15094 15095 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15096 (uint8_t *)&info, sizeof(info), 15097 RTE_PMD_I40E_PKG_INFO_HEADER); 15098 if (!ret) { 15099 printf("i40e Profile Track id: 0x%x\n", info.track_id); 15100 printf("i40e Profile Version: %d.%d.%d.%d\n", 15101 info.version.major, 15102 info.version.minor, 15103 info.version.update, 15104 info.version.draft); 15105 printf("i40e Profile name: %s\n\n", info.name); 15106 } 15107 15108 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15109 (uint8_t *)&buff_size, sizeof(buff_size), 15110 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE); 15111 if (!ret && buff_size) { 15112 buff = (uint8_t *)malloc(buff_size); 15113 if (buff) { 15114 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15115 buff, buff_size, 15116 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES); 15117 if (!ret) 15118 printf("Package Notes:\n%s\n\n", buff); 15119 free(buff); 15120 } 15121 } 15122 15123 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15124 (uint8_t *)&dev_num, sizeof(dev_num), 15125 RTE_PMD_I40E_PKG_INFO_DEVID_NUM); 15126 if (!ret && dev_num) { 15127 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id); 15128 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size); 15129 if (devs) { 15130 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15131 (uint8_t *)devs, buff_size, 15132 RTE_PMD_I40E_PKG_INFO_DEVID_LIST); 15133 if (!ret) { 15134 printf("List of supported devices:\n"); 15135 for (i = 0; i < dev_num; i++) { 15136 printf(" %04X:%04X %04X:%04X\n", 15137 devs[i].vendor_dev_id >> 16, 15138 devs[i].vendor_dev_id & 0xFFFF, 15139 devs[i].sub_vendor_dev_id >> 16, 15140 devs[i].sub_vendor_dev_id & 0xFFFF); 15141 } 15142 printf("\n"); 15143 } 15144 free(devs); 15145 } 15146 } 15147 15148 /* get information about protocols and packet types */ 15149 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15150 (uint8_t *)&proto_num, sizeof(proto_num), 15151 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM); 15152 if (ret || !proto_num) 15153 goto no_print_return; 15154 15155 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info); 15156 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size); 15157 if (!proto) 15158 goto no_print_return; 15159 15160 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto, 15161 buff_size, 15162 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST); 15163 if (!ret) { 15164 printf("List of used protocols:\n"); 15165 for (i = 0; i < proto_num; i++) 15166 printf(" %2u: %s\n", proto[i].proto_id, 15167 proto[i].name); 15168 printf("\n"); 15169 } 15170 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15171 (uint8_t *)&pctype_num, sizeof(pctype_num), 15172 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM); 15173 if (ret || !pctype_num) 15174 goto no_print_pctypes; 15175 15176 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info); 15177 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 15178 if (!pctype) 15179 goto no_print_pctypes; 15180 15181 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype, 15182 buff_size, 15183 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST); 15184 if (ret) { 15185 free(pctype); 15186 goto no_print_pctypes; 15187 } 15188 15189 printf("List of defined packet classification types:\n"); 15190 for (i = 0; i < pctype_num; i++) { 15191 printf(" %2u:", pctype[i].ptype_id); 15192 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 15193 proto_id = pctype[i].protocols[j]; 15194 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 15195 for (n = 0; n < proto_num; n++) { 15196 if (proto[n].proto_id == proto_id) { 15197 printf(" %s", proto[n].name); 15198 break; 15199 } 15200 } 15201 } 15202 } 15203 printf("\n"); 15204 } 15205 printf("\n"); 15206 free(pctype); 15207 15208 no_print_pctypes: 15209 15210 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num, 15211 sizeof(ptype_num), 15212 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM); 15213 if (ret || !ptype_num) 15214 goto no_print_return; 15215 15216 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info); 15217 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 15218 if (!ptype) 15219 goto no_print_return; 15220 15221 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype, 15222 buff_size, 15223 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST); 15224 if (ret) { 15225 free(ptype); 15226 goto no_print_return; 15227 } 15228 printf("List of defined packet types:\n"); 15229 for (i = 0; i < ptype_num; i++) { 15230 printf(" %2u:", ptype[i].ptype_id); 15231 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 15232 proto_id = ptype[i].protocols[j]; 15233 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 15234 for (n = 0; n < proto_num; n++) { 15235 if (proto[n].proto_id == proto_id) { 15236 printf(" %s", proto[n].name); 15237 break; 15238 } 15239 } 15240 } 15241 } 15242 printf("\n"); 15243 } 15244 free(ptype); 15245 printf("\n"); 15246 15247 ret = 0; 15248 no_print_return: 15249 if (proto) 15250 free(proto); 15251 #endif 15252 if (ret == -ENOTSUP) 15253 printf("Function not supported in PMD driver\n"); 15254 close_file(pkg); 15255 } 15256 15257 cmdline_parse_inst_t cmd_ddp_get_info = { 15258 .f = cmd_ddp_info_parsed, 15259 .data = NULL, 15260 .help_str = "ddp get info <profile_path>", 15261 .tokens = { 15262 (void *)&cmd_ddp_info_ddp, 15263 (void *)&cmd_ddp_info_get, 15264 (void *)&cmd_ddp_info_info, 15265 (void *)&cmd_ddp_info_filepath, 15266 NULL, 15267 }, 15268 }; 15269 15270 /* Get dynamic device personalization profile info list*/ 15271 #define PROFILE_INFO_SIZE 48 15272 #define MAX_PROFILE_NUM 16 15273 15274 struct cmd_ddp_get_list_result { 15275 cmdline_fixed_string_t ddp; 15276 cmdline_fixed_string_t get; 15277 cmdline_fixed_string_t list; 15278 portid_t port_id; 15279 }; 15280 15281 cmdline_parse_token_string_t cmd_ddp_get_list_ddp = 15282 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp"); 15283 cmdline_parse_token_string_t cmd_ddp_get_list_get = 15284 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get"); 15285 cmdline_parse_token_string_t cmd_ddp_get_list_list = 15286 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list"); 15287 cmdline_parse_token_num_t cmd_ddp_get_list_port_id = 15288 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16); 15289 15290 static void 15291 cmd_ddp_get_list_parsed( 15292 __attribute__((unused)) void *parsed_result, 15293 __attribute__((unused)) struct cmdline *cl, 15294 __attribute__((unused)) void *data) 15295 { 15296 #ifdef RTE_LIBRTE_I40E_PMD 15297 struct cmd_ddp_get_list_result *res = parsed_result; 15298 struct rte_pmd_i40e_profile_list *p_list; 15299 struct rte_pmd_i40e_profile_info *p_info; 15300 uint32_t p_num; 15301 uint32_t size; 15302 uint32_t i; 15303 #endif 15304 int ret = -ENOTSUP; 15305 15306 #ifdef RTE_LIBRTE_I40E_PMD 15307 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4; 15308 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size); 15309 if (!p_list) 15310 printf("%s: Failed to malloc buffer\n", __func__); 15311 15312 if (ret == -ENOTSUP) 15313 ret = rte_pmd_i40e_get_ddp_list(res->port_id, 15314 (uint8_t *)p_list, size); 15315 15316 if (!ret) { 15317 p_num = p_list->p_count; 15318 printf("Profile number is: %d\n\n", p_num); 15319 15320 for (i = 0; i < p_num; i++) { 15321 p_info = &p_list->p_info[i]; 15322 printf("Profile %d:\n", i); 15323 printf("Track id: 0x%x\n", p_info->track_id); 15324 printf("Version: %d.%d.%d.%d\n", 15325 p_info->version.major, 15326 p_info->version.minor, 15327 p_info->version.update, 15328 p_info->version.draft); 15329 printf("Profile name: %s\n\n", p_info->name); 15330 } 15331 } 15332 15333 free(p_list); 15334 #endif 15335 15336 if (ret < 0) 15337 printf("Failed to get ddp list\n"); 15338 } 15339 15340 cmdline_parse_inst_t cmd_ddp_get_list = { 15341 .f = cmd_ddp_get_list_parsed, 15342 .data = NULL, 15343 .help_str = "ddp get list <port_id>", 15344 .tokens = { 15345 (void *)&cmd_ddp_get_list_ddp, 15346 (void *)&cmd_ddp_get_list_get, 15347 (void *)&cmd_ddp_get_list_list, 15348 (void *)&cmd_ddp_get_list_port_id, 15349 NULL, 15350 }, 15351 }; 15352 15353 /* Configure input set */ 15354 struct cmd_cfg_input_set_result { 15355 cmdline_fixed_string_t port; 15356 cmdline_fixed_string_t cfg; 15357 portid_t port_id; 15358 cmdline_fixed_string_t pctype; 15359 uint8_t pctype_id; 15360 cmdline_fixed_string_t inset_type; 15361 cmdline_fixed_string_t opt; 15362 cmdline_fixed_string_t field; 15363 uint8_t field_idx; 15364 }; 15365 15366 static void 15367 cmd_cfg_input_set_parsed( 15368 __attribute__((unused)) void *parsed_result, 15369 __attribute__((unused)) struct cmdline *cl, 15370 __attribute__((unused)) void *data) 15371 { 15372 #ifdef RTE_LIBRTE_I40E_PMD 15373 struct cmd_cfg_input_set_result *res = parsed_result; 15374 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 15375 struct rte_pmd_i40e_inset inset; 15376 #endif 15377 int ret = -ENOTSUP; 15378 15379 if (!all_ports_stopped()) { 15380 printf("Please stop all ports first\n"); 15381 return; 15382 } 15383 15384 #ifdef RTE_LIBRTE_I40E_PMD 15385 if (!strcmp(res->inset_type, "hash_inset")) 15386 inset_type = INSET_HASH; 15387 else if (!strcmp(res->inset_type, "fdir_inset")) 15388 inset_type = INSET_FDIR; 15389 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 15390 inset_type = INSET_FDIR_FLX; 15391 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id, 15392 &inset, inset_type); 15393 if (ret) { 15394 printf("Failed to get input set.\n"); 15395 return; 15396 } 15397 15398 if (!strcmp(res->opt, "get")) { 15399 ret = rte_pmd_i40e_inset_field_get(inset.inset, 15400 res->field_idx); 15401 if (ret) 15402 printf("Field index %d is enabled.\n", res->field_idx); 15403 else 15404 printf("Field index %d is disabled.\n", res->field_idx); 15405 return; 15406 } else if (!strcmp(res->opt, "set")) 15407 ret = rte_pmd_i40e_inset_field_set(&inset.inset, 15408 res->field_idx); 15409 else if (!strcmp(res->opt, "clear")) 15410 ret = rte_pmd_i40e_inset_field_clear(&inset.inset, 15411 res->field_idx); 15412 if (ret) { 15413 printf("Failed to configure input set field.\n"); 15414 return; 15415 } 15416 15417 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 15418 &inset, inset_type); 15419 if (ret) { 15420 printf("Failed to set input set.\n"); 15421 return; 15422 } 15423 #endif 15424 15425 if (ret == -ENOTSUP) 15426 printf("Function not supported\n"); 15427 } 15428 15429 cmdline_parse_token_string_t cmd_cfg_input_set_port = 15430 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 15431 port, "port"); 15432 cmdline_parse_token_string_t cmd_cfg_input_set_cfg = 15433 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 15434 cfg, "config"); 15435 cmdline_parse_token_num_t cmd_cfg_input_set_port_id = 15436 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 15437 port_id, UINT16); 15438 cmdline_parse_token_string_t cmd_cfg_input_set_pctype = 15439 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 15440 pctype, "pctype"); 15441 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id = 15442 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 15443 pctype_id, UINT8); 15444 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type = 15445 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 15446 inset_type, 15447 "hash_inset#fdir_inset#fdir_flx_inset"); 15448 cmdline_parse_token_string_t cmd_cfg_input_set_opt = 15449 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 15450 opt, "get#set#clear"); 15451 cmdline_parse_token_string_t cmd_cfg_input_set_field = 15452 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 15453 field, "field"); 15454 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx = 15455 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 15456 field_idx, UINT8); 15457 15458 cmdline_parse_inst_t cmd_cfg_input_set = { 15459 .f = cmd_cfg_input_set_parsed, 15460 .data = NULL, 15461 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 15462 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>", 15463 .tokens = { 15464 (void *)&cmd_cfg_input_set_port, 15465 (void *)&cmd_cfg_input_set_cfg, 15466 (void *)&cmd_cfg_input_set_port_id, 15467 (void *)&cmd_cfg_input_set_pctype, 15468 (void *)&cmd_cfg_input_set_pctype_id, 15469 (void *)&cmd_cfg_input_set_inset_type, 15470 (void *)&cmd_cfg_input_set_opt, 15471 (void *)&cmd_cfg_input_set_field, 15472 (void *)&cmd_cfg_input_set_field_idx, 15473 NULL, 15474 }, 15475 }; 15476 15477 /* Clear input set */ 15478 struct cmd_clear_input_set_result { 15479 cmdline_fixed_string_t port; 15480 cmdline_fixed_string_t cfg; 15481 portid_t port_id; 15482 cmdline_fixed_string_t pctype; 15483 uint8_t pctype_id; 15484 cmdline_fixed_string_t inset_type; 15485 cmdline_fixed_string_t clear; 15486 cmdline_fixed_string_t all; 15487 }; 15488 15489 static void 15490 cmd_clear_input_set_parsed( 15491 __attribute__((unused)) void *parsed_result, 15492 __attribute__((unused)) struct cmdline *cl, 15493 __attribute__((unused)) void *data) 15494 { 15495 #ifdef RTE_LIBRTE_I40E_PMD 15496 struct cmd_clear_input_set_result *res = parsed_result; 15497 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 15498 struct rte_pmd_i40e_inset inset; 15499 #endif 15500 int ret = -ENOTSUP; 15501 15502 if (!all_ports_stopped()) { 15503 printf("Please stop all ports first\n"); 15504 return; 15505 } 15506 15507 #ifdef RTE_LIBRTE_I40E_PMD 15508 if (!strcmp(res->inset_type, "hash_inset")) 15509 inset_type = INSET_HASH; 15510 else if (!strcmp(res->inset_type, "fdir_inset")) 15511 inset_type = INSET_FDIR; 15512 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 15513 inset_type = INSET_FDIR_FLX; 15514 15515 memset(&inset, 0, sizeof(inset)); 15516 15517 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 15518 &inset, inset_type); 15519 if (ret) { 15520 printf("Failed to clear input set.\n"); 15521 return; 15522 } 15523 15524 #endif 15525 15526 if (ret == -ENOTSUP) 15527 printf("Function not supported\n"); 15528 } 15529 15530 cmdline_parse_token_string_t cmd_clear_input_set_port = 15531 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 15532 port, "port"); 15533 cmdline_parse_token_string_t cmd_clear_input_set_cfg = 15534 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 15535 cfg, "config"); 15536 cmdline_parse_token_num_t cmd_clear_input_set_port_id = 15537 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 15538 port_id, UINT16); 15539 cmdline_parse_token_string_t cmd_clear_input_set_pctype = 15540 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 15541 pctype, "pctype"); 15542 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id = 15543 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 15544 pctype_id, UINT8); 15545 cmdline_parse_token_string_t cmd_clear_input_set_inset_type = 15546 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 15547 inset_type, 15548 "hash_inset#fdir_inset#fdir_flx_inset"); 15549 cmdline_parse_token_string_t cmd_clear_input_set_clear = 15550 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 15551 clear, "clear"); 15552 cmdline_parse_token_string_t cmd_clear_input_set_all = 15553 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 15554 all, "all"); 15555 15556 cmdline_parse_inst_t cmd_clear_input_set = { 15557 .f = cmd_clear_input_set_parsed, 15558 .data = NULL, 15559 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 15560 "fdir_inset|fdir_flx_inset clear all", 15561 .tokens = { 15562 (void *)&cmd_clear_input_set_port, 15563 (void *)&cmd_clear_input_set_cfg, 15564 (void *)&cmd_clear_input_set_port_id, 15565 (void *)&cmd_clear_input_set_pctype, 15566 (void *)&cmd_clear_input_set_pctype_id, 15567 (void *)&cmd_clear_input_set_inset_type, 15568 (void *)&cmd_clear_input_set_clear, 15569 (void *)&cmd_clear_input_set_all, 15570 NULL, 15571 }, 15572 }; 15573 15574 /* show vf stats */ 15575 15576 /* Common result structure for show vf stats */ 15577 struct cmd_show_vf_stats_result { 15578 cmdline_fixed_string_t show; 15579 cmdline_fixed_string_t vf; 15580 cmdline_fixed_string_t stats; 15581 portid_t port_id; 15582 uint16_t vf_id; 15583 }; 15584 15585 /* Common CLI fields show vf stats*/ 15586 cmdline_parse_token_string_t cmd_show_vf_stats_show = 15587 TOKEN_STRING_INITIALIZER 15588 (struct cmd_show_vf_stats_result, 15589 show, "show"); 15590 cmdline_parse_token_string_t cmd_show_vf_stats_vf = 15591 TOKEN_STRING_INITIALIZER 15592 (struct cmd_show_vf_stats_result, 15593 vf, "vf"); 15594 cmdline_parse_token_string_t cmd_show_vf_stats_stats = 15595 TOKEN_STRING_INITIALIZER 15596 (struct cmd_show_vf_stats_result, 15597 stats, "stats"); 15598 cmdline_parse_token_num_t cmd_show_vf_stats_port_id = 15599 TOKEN_NUM_INITIALIZER 15600 (struct cmd_show_vf_stats_result, 15601 port_id, UINT16); 15602 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id = 15603 TOKEN_NUM_INITIALIZER 15604 (struct cmd_show_vf_stats_result, 15605 vf_id, UINT16); 15606 15607 static void 15608 cmd_show_vf_stats_parsed( 15609 void *parsed_result, 15610 __attribute__((unused)) struct cmdline *cl, 15611 __attribute__((unused)) void *data) 15612 { 15613 struct cmd_show_vf_stats_result *res = parsed_result; 15614 struct rte_eth_stats stats; 15615 int ret = -ENOTSUP; 15616 static const char *nic_stats_border = "########################"; 15617 15618 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15619 return; 15620 15621 memset(&stats, 0, sizeof(stats)); 15622 15623 #ifdef RTE_LIBRTE_I40E_PMD 15624 if (ret == -ENOTSUP) 15625 ret = rte_pmd_i40e_get_vf_stats(res->port_id, 15626 res->vf_id, 15627 &stats); 15628 #endif 15629 #ifdef RTE_LIBRTE_BNXT_PMD 15630 if (ret == -ENOTSUP) 15631 ret = rte_pmd_bnxt_get_vf_stats(res->port_id, 15632 res->vf_id, 15633 &stats); 15634 #endif 15635 15636 switch (ret) { 15637 case 0: 15638 break; 15639 case -EINVAL: 15640 printf("invalid vf_id %d\n", res->vf_id); 15641 break; 15642 case -ENODEV: 15643 printf("invalid port_id %d\n", res->port_id); 15644 break; 15645 case -ENOTSUP: 15646 printf("function not implemented\n"); 15647 break; 15648 default: 15649 printf("programming error: (%s)\n", strerror(-ret)); 15650 } 15651 15652 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n", 15653 nic_stats_border, res->port_id, res->vf_id, nic_stats_border); 15654 15655 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " 15656 "%-"PRIu64"\n", 15657 stats.ipackets, stats.imissed, stats.ibytes); 15658 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); 15659 printf(" RX-nombuf: %-10"PRIu64"\n", 15660 stats.rx_nombuf); 15661 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " 15662 "%-"PRIu64"\n", 15663 stats.opackets, stats.oerrors, stats.obytes); 15664 15665 printf(" %s############################%s\n", 15666 nic_stats_border, nic_stats_border); 15667 } 15668 15669 cmdline_parse_inst_t cmd_show_vf_stats = { 15670 .f = cmd_show_vf_stats_parsed, 15671 .data = NULL, 15672 .help_str = "show vf stats <port_id> <vf_id>", 15673 .tokens = { 15674 (void *)&cmd_show_vf_stats_show, 15675 (void *)&cmd_show_vf_stats_vf, 15676 (void *)&cmd_show_vf_stats_stats, 15677 (void *)&cmd_show_vf_stats_port_id, 15678 (void *)&cmd_show_vf_stats_vf_id, 15679 NULL, 15680 }, 15681 }; 15682 15683 /* clear vf stats */ 15684 15685 /* Common result structure for clear vf stats */ 15686 struct cmd_clear_vf_stats_result { 15687 cmdline_fixed_string_t clear; 15688 cmdline_fixed_string_t vf; 15689 cmdline_fixed_string_t stats; 15690 portid_t port_id; 15691 uint16_t vf_id; 15692 }; 15693 15694 /* Common CLI fields clear vf stats*/ 15695 cmdline_parse_token_string_t cmd_clear_vf_stats_clear = 15696 TOKEN_STRING_INITIALIZER 15697 (struct cmd_clear_vf_stats_result, 15698 clear, "clear"); 15699 cmdline_parse_token_string_t cmd_clear_vf_stats_vf = 15700 TOKEN_STRING_INITIALIZER 15701 (struct cmd_clear_vf_stats_result, 15702 vf, "vf"); 15703 cmdline_parse_token_string_t cmd_clear_vf_stats_stats = 15704 TOKEN_STRING_INITIALIZER 15705 (struct cmd_clear_vf_stats_result, 15706 stats, "stats"); 15707 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id = 15708 TOKEN_NUM_INITIALIZER 15709 (struct cmd_clear_vf_stats_result, 15710 port_id, UINT16); 15711 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id = 15712 TOKEN_NUM_INITIALIZER 15713 (struct cmd_clear_vf_stats_result, 15714 vf_id, UINT16); 15715 15716 static void 15717 cmd_clear_vf_stats_parsed( 15718 void *parsed_result, 15719 __attribute__((unused)) struct cmdline *cl, 15720 __attribute__((unused)) void *data) 15721 { 15722 struct cmd_clear_vf_stats_result *res = parsed_result; 15723 int ret = -ENOTSUP; 15724 15725 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15726 return; 15727 15728 #ifdef RTE_LIBRTE_I40E_PMD 15729 if (ret == -ENOTSUP) 15730 ret = rte_pmd_i40e_reset_vf_stats(res->port_id, 15731 res->vf_id); 15732 #endif 15733 #ifdef RTE_LIBRTE_BNXT_PMD 15734 if (ret == -ENOTSUP) 15735 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id, 15736 res->vf_id); 15737 #endif 15738 15739 switch (ret) { 15740 case 0: 15741 break; 15742 case -EINVAL: 15743 printf("invalid vf_id %d\n", res->vf_id); 15744 break; 15745 case -ENODEV: 15746 printf("invalid port_id %d\n", res->port_id); 15747 break; 15748 case -ENOTSUP: 15749 printf("function not implemented\n"); 15750 break; 15751 default: 15752 printf("programming error: (%s)\n", strerror(-ret)); 15753 } 15754 } 15755 15756 cmdline_parse_inst_t cmd_clear_vf_stats = { 15757 .f = cmd_clear_vf_stats_parsed, 15758 .data = NULL, 15759 .help_str = "clear vf stats <port_id> <vf_id>", 15760 .tokens = { 15761 (void *)&cmd_clear_vf_stats_clear, 15762 (void *)&cmd_clear_vf_stats_vf, 15763 (void *)&cmd_clear_vf_stats_stats, 15764 (void *)&cmd_clear_vf_stats_port_id, 15765 (void *)&cmd_clear_vf_stats_vf_id, 15766 NULL, 15767 }, 15768 }; 15769 15770 /* port config pctype mapping reset */ 15771 15772 /* Common result structure for port config pctype mapping reset */ 15773 struct cmd_pctype_mapping_reset_result { 15774 cmdline_fixed_string_t port; 15775 cmdline_fixed_string_t config; 15776 portid_t port_id; 15777 cmdline_fixed_string_t pctype; 15778 cmdline_fixed_string_t mapping; 15779 cmdline_fixed_string_t reset; 15780 }; 15781 15782 /* Common CLI fields for port config pctype mapping reset*/ 15783 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port = 15784 TOKEN_STRING_INITIALIZER 15785 (struct cmd_pctype_mapping_reset_result, 15786 port, "port"); 15787 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config = 15788 TOKEN_STRING_INITIALIZER 15789 (struct cmd_pctype_mapping_reset_result, 15790 config, "config"); 15791 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id = 15792 TOKEN_NUM_INITIALIZER 15793 (struct cmd_pctype_mapping_reset_result, 15794 port_id, UINT16); 15795 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype = 15796 TOKEN_STRING_INITIALIZER 15797 (struct cmd_pctype_mapping_reset_result, 15798 pctype, "pctype"); 15799 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping = 15800 TOKEN_STRING_INITIALIZER 15801 (struct cmd_pctype_mapping_reset_result, 15802 mapping, "mapping"); 15803 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset = 15804 TOKEN_STRING_INITIALIZER 15805 (struct cmd_pctype_mapping_reset_result, 15806 reset, "reset"); 15807 15808 static void 15809 cmd_pctype_mapping_reset_parsed( 15810 void *parsed_result, 15811 __attribute__((unused)) struct cmdline *cl, 15812 __attribute__((unused)) void *data) 15813 { 15814 struct cmd_pctype_mapping_reset_result *res = parsed_result; 15815 int ret = -ENOTSUP; 15816 15817 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15818 return; 15819 15820 #ifdef RTE_LIBRTE_I40E_PMD 15821 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id); 15822 #endif 15823 15824 switch (ret) { 15825 case 0: 15826 break; 15827 case -ENODEV: 15828 printf("invalid port_id %d\n", res->port_id); 15829 break; 15830 case -ENOTSUP: 15831 printf("function not implemented\n"); 15832 break; 15833 default: 15834 printf("programming error: (%s)\n", strerror(-ret)); 15835 } 15836 } 15837 15838 cmdline_parse_inst_t cmd_pctype_mapping_reset = { 15839 .f = cmd_pctype_mapping_reset_parsed, 15840 .data = NULL, 15841 .help_str = "port config <port_id> pctype mapping reset", 15842 .tokens = { 15843 (void *)&cmd_pctype_mapping_reset_port, 15844 (void *)&cmd_pctype_mapping_reset_config, 15845 (void *)&cmd_pctype_mapping_reset_port_id, 15846 (void *)&cmd_pctype_mapping_reset_pctype, 15847 (void *)&cmd_pctype_mapping_reset_mapping, 15848 (void *)&cmd_pctype_mapping_reset_reset, 15849 NULL, 15850 }, 15851 }; 15852 15853 /* show port pctype mapping */ 15854 15855 /* Common result structure for show port pctype mapping */ 15856 struct cmd_pctype_mapping_get_result { 15857 cmdline_fixed_string_t show; 15858 cmdline_fixed_string_t port; 15859 portid_t port_id; 15860 cmdline_fixed_string_t pctype; 15861 cmdline_fixed_string_t mapping; 15862 }; 15863 15864 /* Common CLI fields for pctype mapping get */ 15865 cmdline_parse_token_string_t cmd_pctype_mapping_get_show = 15866 TOKEN_STRING_INITIALIZER 15867 (struct cmd_pctype_mapping_get_result, 15868 show, "show"); 15869 cmdline_parse_token_string_t cmd_pctype_mapping_get_port = 15870 TOKEN_STRING_INITIALIZER 15871 (struct cmd_pctype_mapping_get_result, 15872 port, "port"); 15873 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id = 15874 TOKEN_NUM_INITIALIZER 15875 (struct cmd_pctype_mapping_get_result, 15876 port_id, UINT16); 15877 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype = 15878 TOKEN_STRING_INITIALIZER 15879 (struct cmd_pctype_mapping_get_result, 15880 pctype, "pctype"); 15881 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping = 15882 TOKEN_STRING_INITIALIZER 15883 (struct cmd_pctype_mapping_get_result, 15884 mapping, "mapping"); 15885 15886 static void 15887 cmd_pctype_mapping_get_parsed( 15888 void *parsed_result, 15889 __attribute__((unused)) struct cmdline *cl, 15890 __attribute__((unused)) void *data) 15891 { 15892 struct cmd_pctype_mapping_get_result *res = parsed_result; 15893 int ret = -ENOTSUP; 15894 #ifdef RTE_LIBRTE_I40E_PMD 15895 struct rte_pmd_i40e_flow_type_mapping 15896 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 15897 int i, j, first_pctype; 15898 #endif 15899 15900 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15901 return; 15902 15903 #ifdef RTE_LIBRTE_I40E_PMD 15904 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping); 15905 #endif 15906 15907 switch (ret) { 15908 case 0: 15909 break; 15910 case -ENODEV: 15911 printf("invalid port_id %d\n", res->port_id); 15912 return; 15913 case -ENOTSUP: 15914 printf("function not implemented\n"); 15915 return; 15916 default: 15917 printf("programming error: (%s)\n", strerror(-ret)); 15918 return; 15919 } 15920 15921 #ifdef RTE_LIBRTE_I40E_PMD 15922 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) { 15923 if (mapping[i].pctype != 0ULL) { 15924 first_pctype = 1; 15925 15926 printf("pctype: "); 15927 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) { 15928 if (mapping[i].pctype & (1ULL << j)) { 15929 printf(first_pctype ? 15930 "%02d" : ",%02d", j); 15931 first_pctype = 0; 15932 } 15933 } 15934 printf(" -> flowtype: %02d\n", mapping[i].flow_type); 15935 } 15936 } 15937 #endif 15938 } 15939 15940 cmdline_parse_inst_t cmd_pctype_mapping_get = { 15941 .f = cmd_pctype_mapping_get_parsed, 15942 .data = NULL, 15943 .help_str = "show port <port_id> pctype mapping", 15944 .tokens = { 15945 (void *)&cmd_pctype_mapping_get_show, 15946 (void *)&cmd_pctype_mapping_get_port, 15947 (void *)&cmd_pctype_mapping_get_port_id, 15948 (void *)&cmd_pctype_mapping_get_pctype, 15949 (void *)&cmd_pctype_mapping_get_mapping, 15950 NULL, 15951 }, 15952 }; 15953 15954 /* port config pctype mapping update */ 15955 15956 /* Common result structure for port config pctype mapping update */ 15957 struct cmd_pctype_mapping_update_result { 15958 cmdline_fixed_string_t port; 15959 cmdline_fixed_string_t config; 15960 portid_t port_id; 15961 cmdline_fixed_string_t pctype; 15962 cmdline_fixed_string_t mapping; 15963 cmdline_fixed_string_t update; 15964 cmdline_fixed_string_t pctype_list; 15965 uint16_t flow_type; 15966 }; 15967 15968 /* Common CLI fields for pctype mapping update*/ 15969 cmdline_parse_token_string_t cmd_pctype_mapping_update_port = 15970 TOKEN_STRING_INITIALIZER 15971 (struct cmd_pctype_mapping_update_result, 15972 port, "port"); 15973 cmdline_parse_token_string_t cmd_pctype_mapping_update_config = 15974 TOKEN_STRING_INITIALIZER 15975 (struct cmd_pctype_mapping_update_result, 15976 config, "config"); 15977 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id = 15978 TOKEN_NUM_INITIALIZER 15979 (struct cmd_pctype_mapping_update_result, 15980 port_id, UINT16); 15981 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype = 15982 TOKEN_STRING_INITIALIZER 15983 (struct cmd_pctype_mapping_update_result, 15984 pctype, "pctype"); 15985 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping = 15986 TOKEN_STRING_INITIALIZER 15987 (struct cmd_pctype_mapping_update_result, 15988 mapping, "mapping"); 15989 cmdline_parse_token_string_t cmd_pctype_mapping_update_update = 15990 TOKEN_STRING_INITIALIZER 15991 (struct cmd_pctype_mapping_update_result, 15992 update, "update"); 15993 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type = 15994 TOKEN_STRING_INITIALIZER 15995 (struct cmd_pctype_mapping_update_result, 15996 pctype_list, NULL); 15997 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type = 15998 TOKEN_NUM_INITIALIZER 15999 (struct cmd_pctype_mapping_update_result, 16000 flow_type, UINT16); 16001 16002 static void 16003 cmd_pctype_mapping_update_parsed( 16004 void *parsed_result, 16005 __attribute__((unused)) struct cmdline *cl, 16006 __attribute__((unused)) void *data) 16007 { 16008 struct cmd_pctype_mapping_update_result *res = parsed_result; 16009 int ret = -ENOTSUP; 16010 #ifdef RTE_LIBRTE_I40E_PMD 16011 struct rte_pmd_i40e_flow_type_mapping mapping; 16012 unsigned int i; 16013 unsigned int nb_item; 16014 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX]; 16015 #endif 16016 16017 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16018 return; 16019 16020 #ifdef RTE_LIBRTE_I40E_PMD 16021 nb_item = parse_item_list(res->pctype_list, "pctypes", 16022 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1); 16023 mapping.flow_type = res->flow_type; 16024 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++) 16025 mapping.pctype |= (1ULL << pctype_list[i]); 16026 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id, 16027 &mapping, 16028 1, 16029 0); 16030 #endif 16031 16032 switch (ret) { 16033 case 0: 16034 break; 16035 case -EINVAL: 16036 printf("invalid pctype or flow type\n"); 16037 break; 16038 case -ENODEV: 16039 printf("invalid port_id %d\n", res->port_id); 16040 break; 16041 case -ENOTSUP: 16042 printf("function not implemented\n"); 16043 break; 16044 default: 16045 printf("programming error: (%s)\n", strerror(-ret)); 16046 } 16047 } 16048 16049 cmdline_parse_inst_t cmd_pctype_mapping_update = { 16050 .f = cmd_pctype_mapping_update_parsed, 16051 .data = NULL, 16052 .help_str = "port config <port_id> pctype mapping update" 16053 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>", 16054 .tokens = { 16055 (void *)&cmd_pctype_mapping_update_port, 16056 (void *)&cmd_pctype_mapping_update_config, 16057 (void *)&cmd_pctype_mapping_update_port_id, 16058 (void *)&cmd_pctype_mapping_update_pctype, 16059 (void *)&cmd_pctype_mapping_update_mapping, 16060 (void *)&cmd_pctype_mapping_update_update, 16061 (void *)&cmd_pctype_mapping_update_pc_type, 16062 (void *)&cmd_pctype_mapping_update_flow_type, 16063 NULL, 16064 }, 16065 }; 16066 16067 /* ptype mapping get */ 16068 16069 /* Common result structure for ptype mapping get */ 16070 struct cmd_ptype_mapping_get_result { 16071 cmdline_fixed_string_t ptype; 16072 cmdline_fixed_string_t mapping; 16073 cmdline_fixed_string_t get; 16074 portid_t port_id; 16075 uint8_t valid_only; 16076 }; 16077 16078 /* Common CLI fields for ptype mapping get */ 16079 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype = 16080 TOKEN_STRING_INITIALIZER 16081 (struct cmd_ptype_mapping_get_result, 16082 ptype, "ptype"); 16083 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping = 16084 TOKEN_STRING_INITIALIZER 16085 (struct cmd_ptype_mapping_get_result, 16086 mapping, "mapping"); 16087 cmdline_parse_token_string_t cmd_ptype_mapping_get_get = 16088 TOKEN_STRING_INITIALIZER 16089 (struct cmd_ptype_mapping_get_result, 16090 get, "get"); 16091 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id = 16092 TOKEN_NUM_INITIALIZER 16093 (struct cmd_ptype_mapping_get_result, 16094 port_id, UINT16); 16095 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only = 16096 TOKEN_NUM_INITIALIZER 16097 (struct cmd_ptype_mapping_get_result, 16098 valid_only, UINT8); 16099 16100 static void 16101 cmd_ptype_mapping_get_parsed( 16102 void *parsed_result, 16103 __attribute__((unused)) struct cmdline *cl, 16104 __attribute__((unused)) void *data) 16105 { 16106 struct cmd_ptype_mapping_get_result *res = parsed_result; 16107 int ret = -ENOTSUP; 16108 #ifdef RTE_LIBRTE_I40E_PMD 16109 int max_ptype_num = 256; 16110 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; 16111 uint16_t count; 16112 int i; 16113 #endif 16114 16115 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16116 return; 16117 16118 #ifdef RTE_LIBRTE_I40E_PMD 16119 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, 16120 mapping, 16121 max_ptype_num, 16122 &count, 16123 res->valid_only); 16124 #endif 16125 16126 switch (ret) { 16127 case 0: 16128 break; 16129 case -ENODEV: 16130 printf("invalid port_id %d\n", res->port_id); 16131 break; 16132 case -ENOTSUP: 16133 printf("function not implemented\n"); 16134 break; 16135 default: 16136 printf("programming error: (%s)\n", strerror(-ret)); 16137 } 16138 16139 #ifdef RTE_LIBRTE_I40E_PMD 16140 if (!ret) { 16141 for (i = 0; i < count; i++) 16142 printf("%3d\t0x%08x\n", 16143 mapping[i].hw_ptype, mapping[i].sw_ptype); 16144 } 16145 #endif 16146 } 16147 16148 cmdline_parse_inst_t cmd_ptype_mapping_get = { 16149 .f = cmd_ptype_mapping_get_parsed, 16150 .data = NULL, 16151 .help_str = "ptype mapping get <port_id> <valid_only>", 16152 .tokens = { 16153 (void *)&cmd_ptype_mapping_get_ptype, 16154 (void *)&cmd_ptype_mapping_get_mapping, 16155 (void *)&cmd_ptype_mapping_get_get, 16156 (void *)&cmd_ptype_mapping_get_port_id, 16157 (void *)&cmd_ptype_mapping_get_valid_only, 16158 NULL, 16159 }, 16160 }; 16161 16162 /* ptype mapping replace */ 16163 16164 /* Common result structure for ptype mapping replace */ 16165 struct cmd_ptype_mapping_replace_result { 16166 cmdline_fixed_string_t ptype; 16167 cmdline_fixed_string_t mapping; 16168 cmdline_fixed_string_t replace; 16169 portid_t port_id; 16170 uint32_t target; 16171 uint8_t mask; 16172 uint32_t pkt_type; 16173 }; 16174 16175 /* Common CLI fields for ptype mapping replace */ 16176 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype = 16177 TOKEN_STRING_INITIALIZER 16178 (struct cmd_ptype_mapping_replace_result, 16179 ptype, "ptype"); 16180 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping = 16181 TOKEN_STRING_INITIALIZER 16182 (struct cmd_ptype_mapping_replace_result, 16183 mapping, "mapping"); 16184 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace = 16185 TOKEN_STRING_INITIALIZER 16186 (struct cmd_ptype_mapping_replace_result, 16187 replace, "replace"); 16188 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id = 16189 TOKEN_NUM_INITIALIZER 16190 (struct cmd_ptype_mapping_replace_result, 16191 port_id, UINT16); 16192 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target = 16193 TOKEN_NUM_INITIALIZER 16194 (struct cmd_ptype_mapping_replace_result, 16195 target, UINT32); 16196 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask = 16197 TOKEN_NUM_INITIALIZER 16198 (struct cmd_ptype_mapping_replace_result, 16199 mask, UINT8); 16200 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type = 16201 TOKEN_NUM_INITIALIZER 16202 (struct cmd_ptype_mapping_replace_result, 16203 pkt_type, UINT32); 16204 16205 static void 16206 cmd_ptype_mapping_replace_parsed( 16207 void *parsed_result, 16208 __attribute__((unused)) struct cmdline *cl, 16209 __attribute__((unused)) void *data) 16210 { 16211 struct cmd_ptype_mapping_replace_result *res = parsed_result; 16212 int ret = -ENOTSUP; 16213 16214 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16215 return; 16216 16217 #ifdef RTE_LIBRTE_I40E_PMD 16218 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id, 16219 res->target, 16220 res->mask, 16221 res->pkt_type); 16222 #endif 16223 16224 switch (ret) { 16225 case 0: 16226 break; 16227 case -EINVAL: 16228 printf("invalid ptype 0x%8x or 0x%8x\n", 16229 res->target, res->pkt_type); 16230 break; 16231 case -ENODEV: 16232 printf("invalid port_id %d\n", res->port_id); 16233 break; 16234 case -ENOTSUP: 16235 printf("function not implemented\n"); 16236 break; 16237 default: 16238 printf("programming error: (%s)\n", strerror(-ret)); 16239 } 16240 } 16241 16242 cmdline_parse_inst_t cmd_ptype_mapping_replace = { 16243 .f = cmd_ptype_mapping_replace_parsed, 16244 .data = NULL, 16245 .help_str = 16246 "ptype mapping replace <port_id> <target> <mask> <pkt_type>", 16247 .tokens = { 16248 (void *)&cmd_ptype_mapping_replace_ptype, 16249 (void *)&cmd_ptype_mapping_replace_mapping, 16250 (void *)&cmd_ptype_mapping_replace_replace, 16251 (void *)&cmd_ptype_mapping_replace_port_id, 16252 (void *)&cmd_ptype_mapping_replace_target, 16253 (void *)&cmd_ptype_mapping_replace_mask, 16254 (void *)&cmd_ptype_mapping_replace_pkt_type, 16255 NULL, 16256 }, 16257 }; 16258 16259 /* ptype mapping reset */ 16260 16261 /* Common result structure for ptype mapping reset */ 16262 struct cmd_ptype_mapping_reset_result { 16263 cmdline_fixed_string_t ptype; 16264 cmdline_fixed_string_t mapping; 16265 cmdline_fixed_string_t reset; 16266 portid_t port_id; 16267 }; 16268 16269 /* Common CLI fields for ptype mapping reset*/ 16270 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype = 16271 TOKEN_STRING_INITIALIZER 16272 (struct cmd_ptype_mapping_reset_result, 16273 ptype, "ptype"); 16274 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping = 16275 TOKEN_STRING_INITIALIZER 16276 (struct cmd_ptype_mapping_reset_result, 16277 mapping, "mapping"); 16278 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset = 16279 TOKEN_STRING_INITIALIZER 16280 (struct cmd_ptype_mapping_reset_result, 16281 reset, "reset"); 16282 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id = 16283 TOKEN_NUM_INITIALIZER 16284 (struct cmd_ptype_mapping_reset_result, 16285 port_id, UINT16); 16286 16287 static void 16288 cmd_ptype_mapping_reset_parsed( 16289 void *parsed_result, 16290 __attribute__((unused)) struct cmdline *cl, 16291 __attribute__((unused)) void *data) 16292 { 16293 struct cmd_ptype_mapping_reset_result *res = parsed_result; 16294 int ret = -ENOTSUP; 16295 16296 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16297 return; 16298 16299 #ifdef RTE_LIBRTE_I40E_PMD 16300 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id); 16301 #endif 16302 16303 switch (ret) { 16304 case 0: 16305 break; 16306 case -ENODEV: 16307 printf("invalid port_id %d\n", res->port_id); 16308 break; 16309 case -ENOTSUP: 16310 printf("function not implemented\n"); 16311 break; 16312 default: 16313 printf("programming error: (%s)\n", strerror(-ret)); 16314 } 16315 } 16316 16317 cmdline_parse_inst_t cmd_ptype_mapping_reset = { 16318 .f = cmd_ptype_mapping_reset_parsed, 16319 .data = NULL, 16320 .help_str = "ptype mapping reset <port_id>", 16321 .tokens = { 16322 (void *)&cmd_ptype_mapping_reset_ptype, 16323 (void *)&cmd_ptype_mapping_reset_mapping, 16324 (void *)&cmd_ptype_mapping_reset_reset, 16325 (void *)&cmd_ptype_mapping_reset_port_id, 16326 NULL, 16327 }, 16328 }; 16329 16330 /* ptype mapping update */ 16331 16332 /* Common result structure for ptype mapping update */ 16333 struct cmd_ptype_mapping_update_result { 16334 cmdline_fixed_string_t ptype; 16335 cmdline_fixed_string_t mapping; 16336 cmdline_fixed_string_t reset; 16337 portid_t port_id; 16338 uint8_t hw_ptype; 16339 uint32_t sw_ptype; 16340 }; 16341 16342 /* Common CLI fields for ptype mapping update*/ 16343 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype = 16344 TOKEN_STRING_INITIALIZER 16345 (struct cmd_ptype_mapping_update_result, 16346 ptype, "ptype"); 16347 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping = 16348 TOKEN_STRING_INITIALIZER 16349 (struct cmd_ptype_mapping_update_result, 16350 mapping, "mapping"); 16351 cmdline_parse_token_string_t cmd_ptype_mapping_update_update = 16352 TOKEN_STRING_INITIALIZER 16353 (struct cmd_ptype_mapping_update_result, 16354 reset, "update"); 16355 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id = 16356 TOKEN_NUM_INITIALIZER 16357 (struct cmd_ptype_mapping_update_result, 16358 port_id, UINT16); 16359 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype = 16360 TOKEN_NUM_INITIALIZER 16361 (struct cmd_ptype_mapping_update_result, 16362 hw_ptype, UINT8); 16363 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype = 16364 TOKEN_NUM_INITIALIZER 16365 (struct cmd_ptype_mapping_update_result, 16366 sw_ptype, UINT32); 16367 16368 static void 16369 cmd_ptype_mapping_update_parsed( 16370 void *parsed_result, 16371 __attribute__((unused)) struct cmdline *cl, 16372 __attribute__((unused)) void *data) 16373 { 16374 struct cmd_ptype_mapping_update_result *res = parsed_result; 16375 int ret = -ENOTSUP; 16376 #ifdef RTE_LIBRTE_I40E_PMD 16377 struct rte_pmd_i40e_ptype_mapping mapping; 16378 #endif 16379 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16380 return; 16381 16382 #ifdef RTE_LIBRTE_I40E_PMD 16383 mapping.hw_ptype = res->hw_ptype; 16384 mapping.sw_ptype = res->sw_ptype; 16385 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id, 16386 &mapping, 16387 1, 16388 0); 16389 #endif 16390 16391 switch (ret) { 16392 case 0: 16393 break; 16394 case -EINVAL: 16395 printf("invalid ptype 0x%8x\n", res->sw_ptype); 16396 break; 16397 case -ENODEV: 16398 printf("invalid port_id %d\n", res->port_id); 16399 break; 16400 case -ENOTSUP: 16401 printf("function not implemented\n"); 16402 break; 16403 default: 16404 printf("programming error: (%s)\n", strerror(-ret)); 16405 } 16406 } 16407 16408 cmdline_parse_inst_t cmd_ptype_mapping_update = { 16409 .f = cmd_ptype_mapping_update_parsed, 16410 .data = NULL, 16411 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>", 16412 .tokens = { 16413 (void *)&cmd_ptype_mapping_update_ptype, 16414 (void *)&cmd_ptype_mapping_update_mapping, 16415 (void *)&cmd_ptype_mapping_update_update, 16416 (void *)&cmd_ptype_mapping_update_port_id, 16417 (void *)&cmd_ptype_mapping_update_hw_ptype, 16418 (void *)&cmd_ptype_mapping_update_sw_ptype, 16419 NULL, 16420 }, 16421 }; 16422 16423 /* Common result structure for file commands */ 16424 struct cmd_cmdfile_result { 16425 cmdline_fixed_string_t load; 16426 cmdline_fixed_string_t filename; 16427 }; 16428 16429 /* Common CLI fields for file commands */ 16430 cmdline_parse_token_string_t cmd_load_cmdfile = 16431 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load"); 16432 cmdline_parse_token_string_t cmd_load_cmdfile_filename = 16433 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL); 16434 16435 static void 16436 cmd_load_from_file_parsed( 16437 void *parsed_result, 16438 __attribute__((unused)) struct cmdline *cl, 16439 __attribute__((unused)) void *data) 16440 { 16441 struct cmd_cmdfile_result *res = parsed_result; 16442 16443 cmdline_read_from_file(res->filename); 16444 } 16445 16446 cmdline_parse_inst_t cmd_load_from_file = { 16447 .f = cmd_load_from_file_parsed, 16448 .data = NULL, 16449 .help_str = "load <filename>", 16450 .tokens = { 16451 (void *)&cmd_load_cmdfile, 16452 (void *)&cmd_load_cmdfile_filename, 16453 NULL, 16454 }, 16455 }; 16456 16457 /* ******************************************************************************** */ 16458 16459 /* list of instructions */ 16460 cmdline_parse_ctx_t main_ctx[] = { 16461 (cmdline_parse_inst_t *)&cmd_help_brief, 16462 (cmdline_parse_inst_t *)&cmd_help_long, 16463 (cmdline_parse_inst_t *)&cmd_quit, 16464 (cmdline_parse_inst_t *)&cmd_load_from_file, 16465 (cmdline_parse_inst_t *)&cmd_showport, 16466 (cmdline_parse_inst_t *)&cmd_showqueue, 16467 (cmdline_parse_inst_t *)&cmd_showportall, 16468 (cmdline_parse_inst_t *)&cmd_showcfg, 16469 (cmdline_parse_inst_t *)&cmd_start, 16470 (cmdline_parse_inst_t *)&cmd_start_tx_first, 16471 (cmdline_parse_inst_t *)&cmd_start_tx_first_n, 16472 (cmdline_parse_inst_t *)&cmd_set_link_up, 16473 (cmdline_parse_inst_t *)&cmd_set_link_down, 16474 (cmdline_parse_inst_t *)&cmd_reset, 16475 (cmdline_parse_inst_t *)&cmd_set_numbers, 16476 (cmdline_parse_inst_t *)&cmd_set_log, 16477 (cmdline_parse_inst_t *)&cmd_set_txpkts, 16478 (cmdline_parse_inst_t *)&cmd_set_txsplit, 16479 (cmdline_parse_inst_t *)&cmd_set_fwd_list, 16480 (cmdline_parse_inst_t *)&cmd_set_fwd_mask, 16481 (cmdline_parse_inst_t *)&cmd_set_fwd_mode, 16482 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode, 16483 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, 16484 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one, 16485 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all, 16486 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one, 16487 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, 16488 (cmdline_parse_inst_t *)&cmd_set_flush_rx, 16489 (cmdline_parse_inst_t *)&cmd_set_link_check, 16490 (cmdline_parse_inst_t *)&cmd_set_bypass_mode, 16491 (cmdline_parse_inst_t *)&cmd_set_bypass_event, 16492 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, 16493 (cmdline_parse_inst_t *)&cmd_show_bypass_config, 16494 #ifdef RTE_LIBRTE_PMD_BOND 16495 (cmdline_parse_inst_t *) &cmd_set_bonding_mode, 16496 (cmdline_parse_inst_t *) &cmd_show_bonding_config, 16497 (cmdline_parse_inst_t *) &cmd_set_bonding_primary, 16498 (cmdline_parse_inst_t *) &cmd_add_bonding_slave, 16499 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, 16500 (cmdline_parse_inst_t *) &cmd_create_bonded_device, 16501 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr, 16502 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy, 16503 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period, 16504 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues, 16505 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy, 16506 #endif 16507 (cmdline_parse_inst_t *)&cmd_vlan_offload, 16508 (cmdline_parse_inst_t *)&cmd_vlan_tpid, 16509 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all, 16510 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter, 16511 (cmdline_parse_inst_t *)&cmd_tx_vlan_set, 16512 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq, 16513 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, 16514 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, 16515 (cmdline_parse_inst_t *)&cmd_csum_set, 16516 (cmdline_parse_inst_t *)&cmd_csum_show, 16517 (cmdline_parse_inst_t *)&cmd_csum_tunnel, 16518 (cmdline_parse_inst_t *)&cmd_tso_set, 16519 (cmdline_parse_inst_t *)&cmd_tso_show, 16520 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, 16521 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, 16522 (cmdline_parse_inst_t *)&cmd_gro_enable, 16523 (cmdline_parse_inst_t *)&cmd_gro_flush, 16524 (cmdline_parse_inst_t *)&cmd_gro_show, 16525 (cmdline_parse_inst_t *)&cmd_gso_enable, 16526 (cmdline_parse_inst_t *)&cmd_gso_size, 16527 (cmdline_parse_inst_t *)&cmd_gso_show, 16528 (cmdline_parse_inst_t *)&cmd_link_flow_control_set, 16529 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, 16530 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx, 16531 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw, 16532 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw, 16533 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt, 16534 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, 16535 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, 16536 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, 16537 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, 16538 (cmdline_parse_inst_t *)&cmd_config_dcb, 16539 (cmdline_parse_inst_t *)&cmd_read_reg, 16540 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field, 16541 (cmdline_parse_inst_t *)&cmd_read_reg_bit, 16542 (cmdline_parse_inst_t *)&cmd_write_reg, 16543 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field, 16544 (cmdline_parse_inst_t *)&cmd_write_reg_bit, 16545 (cmdline_parse_inst_t *)&cmd_read_rxd_txd, 16546 (cmdline_parse_inst_t *)&cmd_stop, 16547 (cmdline_parse_inst_t *)&cmd_mac_addr, 16548 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, 16549 (cmdline_parse_inst_t *)&cmd_set_qmap, 16550 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, 16551 (cmdline_parse_inst_t *)&cmd_operate_port, 16552 (cmdline_parse_inst_t *)&cmd_operate_specific_port, 16553 (cmdline_parse_inst_t *)&cmd_operate_attach_port, 16554 (cmdline_parse_inst_t *)&cmd_operate_detach_port, 16555 (cmdline_parse_inst_t *)&cmd_config_speed_all, 16556 (cmdline_parse_inst_t *)&cmd_config_speed_specific, 16557 (cmdline_parse_inst_t *)&cmd_config_loopback_all, 16558 (cmdline_parse_inst_t *)&cmd_config_loopback_specific, 16559 (cmdline_parse_inst_t *)&cmd_config_rx_tx, 16560 (cmdline_parse_inst_t *)&cmd_config_mtu, 16561 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, 16562 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, 16563 (cmdline_parse_inst_t *)&cmd_config_rss, 16564 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size, 16565 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, 16566 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue, 16567 (cmdline_parse_inst_t *)&cmd_config_rss_reta, 16568 (cmdline_parse_inst_t *)&cmd_showport_reta, 16569 (cmdline_parse_inst_t *)&cmd_config_burst, 16570 (cmdline_parse_inst_t *)&cmd_config_thresh, 16571 (cmdline_parse_inst_t *)&cmd_config_threshold, 16572 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter, 16573 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, 16574 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, 16575 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter, 16576 (cmdline_parse_inst_t *)&cmd_queue_rate_limit, 16577 (cmdline_parse_inst_t *)&cmd_tunnel_filter, 16578 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, 16579 (cmdline_parse_inst_t *)&cmd_global_config, 16580 (cmdline_parse_inst_t *)&cmd_set_mirror_mask, 16581 (cmdline_parse_inst_t *)&cmd_set_mirror_link, 16582 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule, 16583 (cmdline_parse_inst_t *)&cmd_showport_rss_hash, 16584 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, 16585 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, 16586 (cmdline_parse_inst_t *)&cmd_dump, 16587 (cmdline_parse_inst_t *)&cmd_dump_one, 16588 (cmdline_parse_inst_t *)&cmd_ethertype_filter, 16589 (cmdline_parse_inst_t *)&cmd_syn_filter, 16590 (cmdline_parse_inst_t *)&cmd_2tuple_filter, 16591 (cmdline_parse_inst_t *)&cmd_5tuple_filter, 16592 (cmdline_parse_inst_t *)&cmd_flex_filter, 16593 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director, 16594 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director, 16595 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director, 16596 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director, 16597 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director, 16598 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director, 16599 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director, 16600 (cmdline_parse_inst_t *)&cmd_flush_flow_director, 16601 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask, 16602 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask, 16603 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask, 16604 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask, 16605 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload, 16606 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port, 16607 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port, 16608 (cmdline_parse_inst_t *)&cmd_get_hash_global_config, 16609 (cmdline_parse_inst_t *)&cmd_set_hash_global_config, 16610 (cmdline_parse_inst_t *)&cmd_set_hash_input_set, 16611 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set, 16612 (cmdline_parse_inst_t *)&cmd_flow, 16613 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap, 16614 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, 16615 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, 16616 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, 16617 (cmdline_parse_inst_t *)&cmd_create_port_meter, 16618 (cmdline_parse_inst_t *)&cmd_enable_port_meter, 16619 (cmdline_parse_inst_t *)&cmd_disable_port_meter, 16620 (cmdline_parse_inst_t *)&cmd_del_port_meter, 16621 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, 16622 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, 16623 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, 16624 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, 16625 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, 16626 (cmdline_parse_inst_t *)&cmd_mcast_addr, 16627 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all, 16628 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific, 16629 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all, 16630 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific, 16631 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en, 16632 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis, 16633 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis, 16634 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis, 16635 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add, 16636 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del, 16637 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, 16638 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, 16639 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, 16640 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, 16641 (cmdline_parse_inst_t *)&cmd_set_tx_loopback, 16642 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, 16643 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, 16644 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on, 16645 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off, 16646 (cmdline_parse_inst_t *)&cmd_set_macsec_sc, 16647 (cmdline_parse_inst_t *)&cmd_set_macsec_sa, 16648 (cmdline_parse_inst_t *)&cmd_set_vf_traffic, 16649 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, 16650 (cmdline_parse_inst_t *)&cmd_vf_rate_limit, 16651 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, 16652 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, 16653 (cmdline_parse_inst_t *)&cmd_set_vf_promisc, 16654 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti, 16655 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast, 16656 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag, 16657 (cmdline_parse_inst_t *)&cmd_vf_max_bw, 16658 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw, 16659 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw, 16660 (cmdline_parse_inst_t *)&cmd_strict_link_prio, 16661 (cmdline_parse_inst_t *)&cmd_tc_min_bw, 16662 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 16663 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default, 16664 #endif 16665 (cmdline_parse_inst_t *)&cmd_ddp_add, 16666 (cmdline_parse_inst_t *)&cmd_ddp_del, 16667 (cmdline_parse_inst_t *)&cmd_ddp_get_list, 16668 (cmdline_parse_inst_t *)&cmd_ddp_get_info, 16669 (cmdline_parse_inst_t *)&cmd_cfg_input_set, 16670 (cmdline_parse_inst_t *)&cmd_clear_input_set, 16671 (cmdline_parse_inst_t *)&cmd_show_vf_stats, 16672 (cmdline_parse_inst_t *)&cmd_clear_vf_stats, 16673 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, 16674 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, 16675 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, 16676 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update, 16677 16678 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get, 16679 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset, 16680 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update, 16681 (cmdline_parse_inst_t *)&cmd_queue_region, 16682 (cmdline_parse_inst_t *)&cmd_region_flowtype, 16683 (cmdline_parse_inst_t *)&cmd_user_priority_region, 16684 (cmdline_parse_inst_t *)&cmd_flush_queue_region, 16685 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all, 16686 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap, 16687 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap, 16688 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap, 16689 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type, 16690 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats, 16691 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile, 16692 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile, 16693 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper, 16694 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper, 16695 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile, 16696 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile, 16697 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile, 16698 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node, 16699 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node, 16700 (cmdline_parse_inst_t *)&cmd_del_port_tm_node, 16701 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent, 16702 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node, 16703 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node, 16704 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, 16705 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port, 16706 NULL, 16707 }; 16708 16709 /* read cmdline commands from file */ 16710 void 16711 cmdline_read_from_file(const char *filename) 16712 { 16713 struct cmdline *cl; 16714 16715 cl = cmdline_file_new(main_ctx, "testpmd> ", filename); 16716 if (cl == NULL) { 16717 printf("Failed to create file based cmdline context: %s\n", 16718 filename); 16719 return; 16720 } 16721 16722 cmdline_interact(cl); 16723 cmdline_quit(cl); 16724 16725 cmdline_free(cl); 16726 16727 printf("Read CLI commands from %s\n", filename); 16728 } 16729 16730 /* prompt function, called from main on MASTER lcore */ 16731 void 16732 prompt(void) 16733 { 16734 /* initialize non-constant commands */ 16735 cmd_set_fwd_mode_init(); 16736 cmd_set_fwd_retry_mode_init(); 16737 16738 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); 16739 if (testpmd_cl == NULL) 16740 return; 16741 cmdline_interact(testpmd_cl); 16742 cmdline_stdin_exit(testpmd_cl); 16743 } 16744 16745 void 16746 prompt_exit(void) 16747 { 16748 if (testpmd_cl != NULL) 16749 cmdline_quit(testpmd_cl); 16750 } 16751 16752 static void 16753 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) 16754 { 16755 if (id == (portid_t)RTE_PORT_ALL) { 16756 portid_t pid; 16757 16758 RTE_ETH_FOREACH_DEV(pid) { 16759 /* check if need_reconfig has been set to 1 */ 16760 if (ports[pid].need_reconfig == 0) 16761 ports[pid].need_reconfig = dev; 16762 /* check if need_reconfig_queues has been set to 1 */ 16763 if (ports[pid].need_reconfig_queues == 0) 16764 ports[pid].need_reconfig_queues = queue; 16765 } 16766 } else if (!port_id_is_invalid(id, DISABLED_WARN)) { 16767 /* check if need_reconfig has been set to 1 */ 16768 if (ports[id].need_reconfig == 0) 16769 ports[id].need_reconfig = dev; 16770 /* check if need_reconfig_queues has been set to 1 */ 16771 if (ports[id].need_reconfig_queues == 0) 16772 ports[id].need_reconfig_queues = queue; 16773 } 16774 } 16775