1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2010-2016 Intel Corporation. 3 * Copyright(c) 2014 6WIND S.A. 4 */ 5 6 #include <stdarg.h> 7 #include <errno.h> 8 #include <stdio.h> 9 #include <stdint.h> 10 #include <string.h> 11 #include <termios.h> 12 #include <unistd.h> 13 #include <inttypes.h> 14 #ifndef __linux__ 15 #ifndef __FreeBSD__ 16 #include <net/socket.h> 17 #else 18 #include <sys/socket.h> 19 #endif 20 #endif 21 #include <netinet/in.h> 22 23 #include <sys/queue.h> 24 25 #include <rte_common.h> 26 #include <rte_byteorder.h> 27 #include <rte_log.h> 28 #include <rte_debug.h> 29 #include <rte_cycles.h> 30 #include <rte_memory.h> 31 #include <rte_memzone.h> 32 #include <rte_malloc.h> 33 #include <rte_launch.h> 34 #include <rte_eal.h> 35 #include <rte_per_lcore.h> 36 #include <rte_lcore.h> 37 #include <rte_atomic.h> 38 #include <rte_branch_prediction.h> 39 #include <rte_ring.h> 40 #include <rte_mempool.h> 41 #include <rte_interrupts.h> 42 #include <rte_pci.h> 43 #include <rte_ether.h> 44 #include <rte_ethdev.h> 45 #include <rte_string_fns.h> 46 #include <rte_devargs.h> 47 #include <rte_eth_ctrl.h> 48 #include <rte_flow.h> 49 #include <rte_gro.h> 50 51 #include <cmdline_rdline.h> 52 #include <cmdline_parse.h> 53 #include <cmdline_parse_num.h> 54 #include <cmdline_parse_string.h> 55 #include <cmdline_parse_ipaddr.h> 56 #include <cmdline_parse_etheraddr.h> 57 #include <cmdline_socket.h> 58 #include <cmdline.h> 59 #ifdef RTE_LIBRTE_PMD_BOND 60 #include <rte_eth_bond.h> 61 #include <rte_eth_bond_8023ad.h> 62 #endif 63 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD 64 #include <rte_pmd_dpaa.h> 65 #endif 66 #ifdef RTE_LIBRTE_IXGBE_PMD 67 #include <rte_pmd_ixgbe.h> 68 #endif 69 #ifdef RTE_LIBRTE_I40E_PMD 70 #include <rte_pmd_i40e.h> 71 #endif 72 #ifdef RTE_LIBRTE_BNXT_PMD 73 #include <rte_pmd_bnxt.h> 74 #endif 75 #include "testpmd.h" 76 #include "cmdline_mtr.h" 77 #include "cmdline_tm.h" 78 #include "bpf_cmd.h" 79 80 static struct cmdline *testpmd_cl; 81 82 static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue); 83 84 /* *** Help command with introduction. *** */ 85 struct cmd_help_brief_result { 86 cmdline_fixed_string_t help; 87 }; 88 89 static void cmd_help_brief_parsed(__attribute__((unused)) void *parsed_result, 90 struct cmdline *cl, 91 __attribute__((unused)) void *data) 92 { 93 cmdline_printf( 94 cl, 95 "\n" 96 "Help is available for the following sections:\n\n" 97 " help control : Start and stop forwarding.\n" 98 " help display : Displaying port, stats and config " 99 "information.\n" 100 " help config : Configuration information.\n" 101 " help ports : Configuring ports.\n" 102 " help registers : Reading and setting port registers.\n" 103 " help filters : Filters configuration help.\n" 104 " help all : All of the above sections.\n\n" 105 ); 106 107 } 108 109 cmdline_parse_token_string_t cmd_help_brief_help = 110 TOKEN_STRING_INITIALIZER(struct cmd_help_brief_result, help, "help"); 111 112 cmdline_parse_inst_t cmd_help_brief = { 113 .f = cmd_help_brief_parsed, 114 .data = NULL, 115 .help_str = "help: Show help", 116 .tokens = { 117 (void *)&cmd_help_brief_help, 118 NULL, 119 }, 120 }; 121 122 /* *** Help command with help sections. *** */ 123 struct cmd_help_long_result { 124 cmdline_fixed_string_t help; 125 cmdline_fixed_string_t section; 126 }; 127 128 static void cmd_help_long_parsed(void *parsed_result, 129 struct cmdline *cl, 130 __attribute__((unused)) void *data) 131 { 132 int show_all = 0; 133 struct cmd_help_long_result *res = parsed_result; 134 135 if (!strcmp(res->section, "all")) 136 show_all = 1; 137 138 if (show_all || !strcmp(res->section, "control")) { 139 140 cmdline_printf( 141 cl, 142 "\n" 143 "Control forwarding:\n" 144 "-------------------\n\n" 145 146 "start\n" 147 " Start packet forwarding with current configuration.\n\n" 148 149 "start tx_first\n" 150 " Start packet forwarding with current config" 151 " after sending one burst of packets.\n\n" 152 153 "stop\n" 154 " Stop packet forwarding, and display accumulated" 155 " statistics.\n\n" 156 157 "quit\n" 158 " Quit to prompt.\n\n" 159 ); 160 } 161 162 if (show_all || !strcmp(res->section, "display")) { 163 164 cmdline_printf( 165 cl, 166 "\n" 167 "Display:\n" 168 "--------\n\n" 169 170 "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n" 171 " Display information for port_id, or all.\n\n" 172 173 "show port X rss reta (size) (mask0,mask1,...)\n" 174 " Display the rss redirection table entry indicated" 175 " by masks on port X. size is used to indicate the" 176 " hardware supported reta size\n\n" 177 178 "show port rss-hash ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|" 179 "ipv4-sctp|ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|" 180 "ipv6-other|l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex [key]\n" 181 " Display the RSS hash functions and RSS hash key" 182 " of port X\n\n" 183 184 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n" 185 " Clear information for port_id, or all.\n\n" 186 187 "show (rxq|txq) info (port_id) (queue_id)\n" 188 " Display information for configured RX/TX queue.\n\n" 189 190 "show config (rxtx|cores|fwd|txpkts)\n" 191 " Display the given configuration.\n\n" 192 193 "read rxd (port_id) (queue_id) (rxd_id)\n" 194 " Display an RX descriptor of a port RX queue.\n\n" 195 196 "read txd (port_id) (queue_id) (txd_id)\n" 197 " Display a TX descriptor of a port TX queue.\n\n" 198 199 "ddp get list (port_id)\n" 200 " Get ddp profile info list\n\n" 201 202 "ddp get info (profile_path)\n" 203 " Get ddp profile information.\n\n" 204 205 "show vf stats (port_id) (vf_id)\n" 206 " Display a VF's statistics.\n\n" 207 208 "clear vf stats (port_id) (vf_id)\n" 209 " Reset a VF's statistics.\n\n" 210 211 "show port (port_id) pctype mapping\n" 212 " Get flow ptype to pctype mapping on a port\n\n" 213 214 "show port meter stats (port_id) (meter_id) (clear)\n" 215 " Get meter stats on a port\n\n" 216 "show port tm cap (port_id)\n" 217 " Display the port TM capability.\n\n" 218 219 "show port tm level cap (port_id) (level_id)\n" 220 " Display the port TM hierarchical level capability.\n\n" 221 222 "show port tm node cap (port_id) (node_id)\n" 223 " Display the port TM node capability.\n\n" 224 225 "show port tm node type (port_id) (node_id)\n" 226 " Display the port TM node type.\n\n" 227 228 "show port tm node stats (port_id) (node_id) (clear)\n" 229 " Display the port TM node stats.\n\n" 230 231 ); 232 } 233 234 if (show_all || !strcmp(res->section, "config")) { 235 cmdline_printf( 236 cl, 237 "\n" 238 "Configuration:\n" 239 "--------------\n" 240 "Configuration changes only become active when" 241 " forwarding is started/restarted.\n\n" 242 243 "set default\n" 244 " Reset forwarding to the default configuration.\n\n" 245 246 "set verbose (level)\n" 247 " Set the debug verbosity level X.\n\n" 248 249 "set log global|(type) (level)\n" 250 " Set the log level.\n\n" 251 252 "set nbport (num)\n" 253 " Set number of ports.\n\n" 254 255 "set nbcore (num)\n" 256 " Set number of cores.\n\n" 257 258 "set coremask (mask)\n" 259 " Set the forwarding cores hexadecimal mask.\n\n" 260 261 "set portmask (mask)\n" 262 " Set the forwarding ports hexadecimal mask.\n\n" 263 264 "set burst (num)\n" 265 " Set number of packets per burst.\n\n" 266 267 "set burst tx delay (microseconds) retry (num)\n" 268 " Set the transmit delay time and number of retries," 269 " effective when retry is enabled.\n\n" 270 271 "set txpkts (x[,y]*)\n" 272 " Set the length of each segment of TXONLY" 273 " and optionally CSUM packets.\n\n" 274 275 "set txsplit (off|on|rand)\n" 276 " Set the split policy for the TX packets." 277 " Right now only applicable for CSUM and TXONLY" 278 " modes\n\n" 279 280 "set corelist (x[,y]*)\n" 281 " Set the list of forwarding cores.\n\n" 282 283 "set portlist (x[,y]*)\n" 284 " Set the list of forwarding ports.\n\n" 285 286 "set tx loopback (port_id) (on|off)\n" 287 " Enable or disable tx loopback.\n\n" 288 289 "set all queues drop (port_id) (on|off)\n" 290 " Set drop enable bit for all queues.\n\n" 291 292 "set vf split drop (port_id) (vf_id) (on|off)\n" 293 " Set split drop enable bit for a VF from the PF.\n\n" 294 295 "set vf mac antispoof (port_id) (vf_id) (on|off).\n" 296 " Set MAC antispoof for a VF from the PF.\n\n" 297 298 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n" 299 " Enable MACsec offload.\n\n" 300 301 "set macsec offload (port_id) off\n" 302 " Disable MACsec offload.\n\n" 303 304 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n" 305 " Configure MACsec secure connection (SC).\n\n" 306 307 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n" 308 " Configure MACsec secure association (SA).\n\n" 309 310 "set vf broadcast (port_id) (vf_id) (on|off)\n" 311 " Set VF broadcast for a VF from the PF.\n\n" 312 313 "vlan set strip (on|off) (port_id)\n" 314 " Set the VLAN strip on a port.\n\n" 315 316 "vlan set stripq (on|off) (port_id,queue_id)\n" 317 " Set the VLAN strip for a queue on a port.\n\n" 318 319 "set vf vlan stripq (port_id) (vf_id) (on|off)\n" 320 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n" 321 322 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n" 323 " Set VLAN insert for a VF from the PF.\n\n" 324 325 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n" 326 " Set VLAN antispoof for a VF from the PF.\n\n" 327 328 "set vf vlan tag (port_id) (vf_id) (on|off)\n" 329 " Set VLAN tag for a VF from the PF.\n\n" 330 331 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n" 332 " Set a VF's max bandwidth(Mbps).\n\n" 333 334 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n" 335 " Set all TCs' min bandwidth(%%) on a VF.\n\n" 336 337 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n" 338 " Set a TC's max bandwidth(Mbps) on a VF.\n\n" 339 340 "set tx strict-link-priority (port_id) (tc_bitmap)\n" 341 " Set some TCs' strict link priority mode on a physical port.\n\n" 342 343 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n" 344 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n" 345 346 "vlan set filter (on|off) (port_id)\n" 347 " Set the VLAN filter on a port.\n\n" 348 349 "vlan set qinq (on|off) (port_id)\n" 350 " Set the VLAN QinQ (extended queue in queue)" 351 " on a port.\n\n" 352 353 "vlan set (inner|outer) tpid (value) (port_id)\n" 354 " Set the VLAN TPID for Packet Filtering on" 355 " a port\n\n" 356 357 "rx_vlan add (vlan_id|all) (port_id)\n" 358 " Add a vlan_id, or all identifiers, to the set" 359 " of VLAN identifiers filtered by port_id.\n\n" 360 361 "rx_vlan rm (vlan_id|all) (port_id)\n" 362 " Remove a vlan_id, or all identifiers, from the set" 363 " of VLAN identifiers filtered by port_id.\n\n" 364 365 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n" 366 " Add a vlan_id, to the set of VLAN identifiers" 367 "filtered for VF(s) from port_id.\n\n" 368 369 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n" 370 " Remove a vlan_id, to the set of VLAN identifiers" 371 "filtered for VF(s) from port_id.\n\n" 372 373 "tunnel_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) " 374 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|" 375 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 376 " add a tunnel filter of a port.\n\n" 377 378 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) " 379 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|" 380 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 381 " remove a tunnel filter of a port.\n\n" 382 383 "rx_vxlan_port add (udp_port) (port_id)\n" 384 " Add an UDP port for VXLAN packet filter on a port\n\n" 385 386 "rx_vxlan_port rm (udp_port) (port_id)\n" 387 " Remove an UDP port for VXLAN packet filter on a port\n\n" 388 389 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n" 390 " Set hardware insertion of VLAN IDs (single or double VLAN " 391 "depends on the number of VLAN IDs) in packets sent on a port.\n\n" 392 393 "tx_vlan set pvid port_id vlan_id (on|off)\n" 394 " Set port based TX VLAN insertion.\n\n" 395 396 "tx_vlan reset (port_id)\n" 397 " Disable hardware insertion of a VLAN header in" 398 " packets sent on a port.\n\n" 399 400 "csum set (ip|udp|tcp|sctp|outer-ip) (hw|sw) (port_id)\n" 401 " Select hardware or software calculation of the" 402 " checksum when transmitting a packet using the" 403 " csum forward engine.\n" 404 " ip|udp|tcp|sctp always concern the inner layer.\n" 405 " outer-ip concerns the outer IP layer in" 406 " case the packet is recognized as a tunnel packet by" 407 " the forward engine (vxlan, gre and ipip are supported)\n" 408 " Please check the NIC datasheet for HW limits.\n\n" 409 410 "csum parse-tunnel (on|off) (tx_port_id)\n" 411 " If disabled, treat tunnel packets as non-tunneled" 412 " packets (treat inner headers as payload). The port\n" 413 " argument is the port used for TX in csum forward" 414 " engine.\n\n" 415 416 "csum show (port_id)\n" 417 " Display tx checksum offload configuration\n\n" 418 419 "tso set (segsize) (portid)\n" 420 " Enable TCP Segmentation Offload in csum forward" 421 " engine.\n" 422 " Please check the NIC datasheet for HW limits.\n\n" 423 424 "tso show (portid)" 425 " Display the status of TCP Segmentation Offload.\n\n" 426 427 "set port (port_id) gro on|off\n" 428 " Enable or disable Generic Receive Offload in" 429 " csum forwarding engine.\n\n" 430 431 "show port (port_id) gro\n" 432 " Display GRO configuration.\n\n" 433 434 "set gro flush (cycles)\n" 435 " Set the cycle to flush GROed packets from" 436 " reassembly tables.\n\n" 437 438 "set port (port_id) gso (on|off)" 439 " Enable or disable Generic Segmentation Offload in" 440 " csum forwarding engine.\n\n" 441 442 "set gso segsz (length)\n" 443 " Set max packet length for output GSO segments," 444 " including packet header and payload.\n\n" 445 446 "show port (port_id) gso\n" 447 " Show GSO configuration.\n\n" 448 449 "set fwd (%s)\n" 450 " Set packet forwarding mode.\n\n" 451 452 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n" 453 " Add a MAC address on port_id.\n\n" 454 455 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n" 456 " Remove a MAC address from port_id.\n\n" 457 458 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n" 459 " Set the default MAC address for port_id.\n\n" 460 461 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n" 462 " Add a MAC address for a VF on the port.\n\n" 463 464 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n" 465 " Set the MAC address for a VF from the PF.\n\n" 466 467 "set eth-peer (port_id) (peer_addr)\n" 468 " set the peer address for certain port.\n\n" 469 470 "set port (port_id) uta (mac_address|all) (on|off)\n" 471 " Add/Remove a or all unicast hash filter(s)" 472 "from port X.\n\n" 473 474 "set promisc (port_id|all) (on|off)\n" 475 " Set the promiscuous mode on port_id, or all.\n\n" 476 477 "set allmulti (port_id|all) (on|off)\n" 478 " Set the allmulti mode on port_id, or all.\n\n" 479 480 "set vf promisc (port_id) (vf_id) (on|off)\n" 481 " Set unicast promiscuous mode for a VF from the PF.\n\n" 482 483 "set vf allmulti (port_id) (vf_id) (on|off)\n" 484 " Set multicast promiscuous mode for a VF from the PF.\n\n" 485 486 "set flow_ctrl rx (on|off) tx (on|off) (high_water)" 487 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd" 488 " (on|off) autoneg (on|off) (port_id)\n" 489 "set flow_ctrl rx (on|off) (portid)\n" 490 "set flow_ctrl tx (on|off) (portid)\n" 491 "set flow_ctrl high_water (high_water) (portid)\n" 492 "set flow_ctrl low_water (low_water) (portid)\n" 493 "set flow_ctrl pause_time (pause_time) (portid)\n" 494 "set flow_ctrl send_xon (send_xon) (portid)\n" 495 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n" 496 "set flow_ctrl autoneg (on|off) (port_id)\n" 497 " Set the link flow control parameter on a port.\n\n" 498 499 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)" 500 " (low_water) (pause_time) (priority) (port_id)\n" 501 " Set the priority flow control parameter on a" 502 " port.\n\n" 503 504 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n" 505 " Set statistics mapping (qmapping 0..15) for RX/TX" 506 " queue on port.\n" 507 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2" 508 " on port 0 to mapping 5.\n\n" 509 510 "set xstats-hide-zero on|off\n" 511 " Set the option to hide the zero values" 512 " for xstats display.\n" 513 514 "set port (port_id) vf (vf_id) rx|tx on|off\n" 515 " Enable/Disable a VF receive/tranmit from a port\n\n" 516 517 "set port (port_id) vf (vf_id) (mac_addr)" 518 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n" 519 " Add/Remove unicast or multicast MAC addr filter" 520 " for a VF.\n\n" 521 522 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM" 523 "|MPE) (on|off)\n" 524 " AUPE:accepts untagged VLAN;" 525 "ROPE:accept unicast hash\n\n" 526 " BAM:accepts broadcast packets;" 527 "MPE:accepts all multicast packets\n\n" 528 " Enable/Disable a VF receive mode of a port\n\n" 529 530 "set port (port_id) queue (queue_id) rate (rate_num)\n" 531 " Set rate limit for a queue of a port\n\n" 532 533 "set port (port_id) vf (vf_id) rate (rate_num) " 534 "queue_mask (queue_mask_value)\n" 535 " Set rate limit for queues in VF of a port\n\n" 536 537 "set port (port_id) mirror-rule (rule_id)" 538 " (pool-mirror-up|pool-mirror-down|vlan-mirror)" 539 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n" 540 " Set pool or vlan type mirror rule on a port.\n" 541 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1" 542 " dst-pool 0 on' enable mirror traffic with vlan 0,1" 543 " to pool 0.\n\n" 544 545 "set port (port_id) mirror-rule (rule_id)" 546 " (uplink-mirror|downlink-mirror) dst-pool" 547 " (pool_id) (on|off)\n" 548 " Set uplink or downlink type mirror rule on a port.\n" 549 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool" 550 " 0 on' enable mirror income traffic to pool 0.\n\n" 551 552 "reset port (port_id) mirror-rule (rule_id)\n" 553 " Reset a mirror rule.\n\n" 554 555 "set flush_rx (on|off)\n" 556 " Flush (default) or don't flush RX streams before" 557 " forwarding. Mainly used with PCAP drivers.\n\n" 558 559 "set bypass mode (normal|bypass|isolate) (port_id)\n" 560 " Set the bypass mode for the lowest port on bypass enabled" 561 " NIC.\n\n" 562 563 "set bypass event (timeout|os_on|os_off|power_on|power_off) " 564 "mode (normal|bypass|isolate) (port_id)\n" 565 " Set the event required to initiate specified bypass mode for" 566 " the lowest port on a bypass enabled NIC where:\n" 567 " timeout = enable bypass after watchdog timeout.\n" 568 " os_on = enable bypass when OS/board is powered on.\n" 569 " os_off = enable bypass when OS/board is powered off.\n" 570 " power_on = enable bypass when power supply is turned on.\n" 571 " power_off = enable bypass when power supply is turned off." 572 "\n\n" 573 574 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n" 575 " Set the bypass watchdog timeout to 'n' seconds" 576 " where 0 = instant.\n\n" 577 578 "show bypass config (port_id)\n" 579 " Show the bypass configuration for a bypass enabled NIC" 580 " using the lowest port on the NIC.\n\n" 581 582 #ifdef RTE_LIBRTE_PMD_BOND 583 "create bonded device (mode) (socket)\n" 584 " Create a new bonded device with specific bonding mode and socket.\n\n" 585 586 "add bonding slave (slave_id) (port_id)\n" 587 " Add a slave device to a bonded device.\n\n" 588 589 "remove bonding slave (slave_id) (port_id)\n" 590 " Remove a slave device from a bonded device.\n\n" 591 592 "set bonding mode (value) (port_id)\n" 593 " Set the bonding mode on a bonded device.\n\n" 594 595 "set bonding primary (slave_id) (port_id)\n" 596 " Set the primary slave for a bonded device.\n\n" 597 598 "show bonding config (port_id)\n" 599 " Show the bonding config for port_id.\n\n" 600 601 "set bonding mac_addr (port_id) (address)\n" 602 " Set the MAC address of a bonded device.\n\n" 603 604 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)" 605 " Set Aggregation mode for IEEE802.3AD (mode 4)" 606 607 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n" 608 " Set the transmit balance policy for bonded device running in balance mode.\n\n" 609 610 "set bonding mon_period (port_id) (value)\n" 611 " Set the bonding link status monitoring polling period in ms.\n\n" 612 613 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n" 614 " Enable/disable dedicated queues for LACP control traffic.\n\n" 615 616 #endif 617 "set link-up port (port_id)\n" 618 " Set link up for a port.\n\n" 619 620 "set link-down port (port_id)\n" 621 " Set link down for a port.\n\n" 622 623 "E-tag set insertion on port-tag-id (value)" 624 " port (port_id) vf (vf_id)\n" 625 " Enable E-tag insertion for a VF on a port\n\n" 626 627 "E-tag set insertion off port (port_id) vf (vf_id)\n" 628 " Disable E-tag insertion for a VF on a port\n\n" 629 630 "E-tag set stripping (on|off) port (port_id)\n" 631 " Enable/disable E-tag stripping on a port\n\n" 632 633 "E-tag set forwarding (on|off) port (port_id)\n" 634 " Enable/disable E-tag based forwarding" 635 " on a port\n\n" 636 637 "E-tag set filter add e-tag-id (value) dst-pool" 638 " (pool_id) port (port_id)\n" 639 " Add an E-tag forwarding filter on a port\n\n" 640 641 "E-tag set filter del e-tag-id (value) port (port_id)\n" 642 " Delete an E-tag forwarding filter on a port\n\n" 643 644 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 645 "set port tm hierarchy default (port_id)\n" 646 " Set default traffic Management hierarchy on a port\n\n" 647 648 #endif 649 "ddp add (port_id) (profile_path[,backup_profile_path])\n" 650 " Load a profile package on a port\n\n" 651 652 "ddp del (port_id) (backup_profile_path)\n" 653 " Delete a profile package from a port\n\n" 654 655 "ptype mapping get (port_id) (valid_only)\n" 656 " Get ptype mapping on a port\n\n" 657 658 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n" 659 " Replace target with the pkt_type in ptype mapping\n\n" 660 661 "ptype mapping reset (port_id)\n" 662 " Reset ptype mapping on a port\n\n" 663 664 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n" 665 " Update a ptype mapping item on a port\n\n" 666 667 "set port (port_id) queue-region region_id (value) " 668 "queue_start_index (value) queue_num (value)\n" 669 " Set a queue region on a port\n\n" 670 671 "set port (port_id) queue-region region_id (value) " 672 "flowtype (value)\n" 673 " Set a flowtype region index on a port\n\n" 674 675 "set port (port_id) queue-region UP (value) region_id (value)\n" 676 " Set the mapping of User Priority to " 677 "queue region on a port\n\n" 678 679 "set port (port_id) queue-region flush (on|off)\n" 680 " flush all queue region related configuration\n\n" 681 682 "show port meter cap (port_id)\n" 683 " Show port meter capability information\n\n" 684 685 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n" 686 " meter profile add - srtcm rfc 2697\n\n" 687 688 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n" 689 " meter profile add - trtcm rfc 2698\n\n" 690 691 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n" 692 " meter profile add - trtcm rfc 4115\n\n" 693 694 "del port meter profile (port_id) (profile_id)\n" 695 " meter profile delete\n\n" 696 697 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n" 698 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n" 699 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" 700 "(dscp_tbl_entry63)]\n" 701 " meter create\n\n" 702 703 "enable port meter (port_id) (mtr_id)\n" 704 " meter enable\n\n" 705 706 "disable port meter (port_id) (mtr_id)\n" 707 " meter disable\n\n" 708 709 "del port meter (port_id) (mtr_id)\n" 710 " meter delete\n\n" 711 712 "set port meter profile (port_id) (mtr_id) (profile_id)\n" 713 " meter update meter profile\n\n" 714 715 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n" 716 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n" 717 " update meter dscp table entries\n\n" 718 719 "set port meter policer action (port_id) (mtr_id) (action_mask)\n" 720 "(action0) [(action1) (action2)]\n" 721 " meter update policer action\n\n" 722 723 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n" 724 " meter update stats\n\n" 725 726 "show port (port_id) queue-region\n" 727 " show all queue region related configuration info\n\n" 728 729 "add port tm node shaper profile (port_id) (shaper_profile_id)" 730 " (tb_rate) (tb_size) (packet_length_adjust)\n" 731 " Add port tm node private shaper profile.\n\n" 732 733 "del port tm node shaper profile (port_id) (shaper_profile_id)\n" 734 " Delete port tm node private shaper profile.\n\n" 735 736 "add port tm node shared shaper (port_id) (shared_shaper_id)" 737 " (shaper_profile_id)\n" 738 " Add/update port tm node shared shaper.\n\n" 739 740 "del port tm node shared shaper (port_id) (shared_shaper_id)\n" 741 " Delete port tm node shared shaper.\n\n" 742 743 "set port tm node shaper profile (port_id) (node_id)" 744 " (shaper_profile_id)\n" 745 " Set port tm node shaper profile.\n\n" 746 747 "add port tm node wred profile (port_id) (wred_profile_id)" 748 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)" 749 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)" 750 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n" 751 " Add port tm node wred profile.\n\n" 752 753 "del port tm node wred profile (port_id) (wred_profile_id)\n" 754 " Delete port tm node wred profile.\n\n" 755 756 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)" 757 " (priority) (weight) (level_id) (shaper_profile_id)" 758 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 759 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 760 " Add port tm nonleaf node.\n\n" 761 762 "add port tm leaf node (port_id) (node_id) (parent_node_id)" 763 " (priority) (weight) (level_id) (shaper_profile_id)" 764 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)" 765 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 766 " Add port tm leaf node.\n\n" 767 768 "del port tm node (port_id) (node_id)\n" 769 " Delete port tm node.\n\n" 770 771 "set port tm node parent (port_id) (node_id) (parent_node_id)" 772 " (priority) (weight)\n" 773 " Set port tm node parent.\n\n" 774 775 "suspend port tm node (port_id) (node_id)" 776 " Suspend tm node.\n\n" 777 778 "resume port tm node (port_id) (node_id)" 779 " Resume tm node.\n\n" 780 781 "port tm hierarchy commit (port_id) (clean_on_fail)\n" 782 " Commit tm hierarchy.\n\n" 783 784 "vxlan ip-version (ipv4|ipv6) vni (vni) udp-src" 785 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst" 786 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n" 787 " Configure the VXLAN encapsulation for flows.\n\n" 788 789 "vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)" 790 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)" 791 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)" 792 " eth-dst (eth-dst)\n" 793 " Configure the VXLAN encapsulation for flows.\n\n" 794 795 "nvgre ip-version (ipv4|ipv6) tni (tni) ip-src" 796 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst" 797 " (eth-dst)\n" 798 " Configure the NVGRE encapsulation for flows.\n\n" 799 800 "nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)" 801 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)" 802 " eth-src (eth-src) eth-dst (eth-dst)\n" 803 " Configure the NVGRE encapsulation for flows.\n\n" 804 805 , list_pkt_forwarding_modes() 806 ); 807 } 808 809 if (show_all || !strcmp(res->section, "ports")) { 810 811 cmdline_printf( 812 cl, 813 "\n" 814 "Port Operations:\n" 815 "----------------\n\n" 816 817 "port start (port_id|all)\n" 818 " Start all ports or port_id.\n\n" 819 820 "port stop (port_id|all)\n" 821 " Stop all ports or port_id.\n\n" 822 823 "port close (port_id|all)\n" 824 " Close all ports or port_id.\n\n" 825 826 "port attach (ident)\n" 827 " Attach physical or virtual dev by pci address or virtual device name\n\n" 828 829 "port detach (port_id)\n" 830 " Detach physical or virtual dev by port_id\n\n" 831 832 "port config (port_id|all)" 833 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)" 834 " duplex (half|full|auto)\n" 835 " Set speed and duplex for all ports or port_id\n\n" 836 837 "port config (port_id|all) loopback (mode)\n" 838 " Set loopback mode for all ports or port_id\n\n" 839 840 "port config all (rxq|txq|rxd|txd) (value)\n" 841 " Set number for rxq/txq/rxd/txd.\n\n" 842 843 "port config all max-pkt-len (value)\n" 844 " Set the max packet length.\n\n" 845 846 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|" 847 "hw-vlan-strip|hw-vlan-extend|drop-en)" 848 " (on|off)\n" 849 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en" 850 " for ports.\n\n" 851 852 "port config all rss (all|default|ip|tcp|udp|sctp|" 853 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n" 854 " Set the RSS mode.\n\n" 855 856 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" 857 " Set the RSS redirection table.\n\n" 858 859 "port config (port_id) dcb vt (on|off) (traffic_class)" 860 " pfc (on|off)\n" 861 " Set the DCB mode.\n\n" 862 863 "port config all burst (value)\n" 864 " Set the number of packets per burst.\n\n" 865 866 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)" 867 " (value)\n" 868 " Set the ring prefetch/host/writeback threshold" 869 " for tx/rx queue.\n\n" 870 871 "port config all (txfreet|txrst|rxfreet) (value)\n" 872 " Set free threshold for rx/tx, or set" 873 " tx rs bit threshold.\n\n" 874 "port config mtu X value\n" 875 " Set the MTU of port X to a given value\n\n" 876 877 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n" 878 " Set a rx/tx queue's ring size configuration, the new" 879 " value will take effect after command that (re-)start the port" 880 " or command that setup the specific queue\n\n" 881 882 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n" 883 " Start/stop a rx/tx queue of port X. Only take effect" 884 " when port X is started\n\n" 885 886 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n" 887 " Switch on/off a deferred start of port X rx/tx queue. Only" 888 " take effect when port X is stopped.\n\n" 889 890 "port (port_id) (rxq|txq) (queue_id) setup\n" 891 " Setup a rx/tx queue of port X.\n\n" 892 893 "port config (port_id|all) l2-tunnel E-tag ether-type" 894 " (value)\n" 895 " Set the value of E-tag ether-type.\n\n" 896 897 "port config (port_id|all) l2-tunnel E-tag" 898 " (enable|disable)\n" 899 " Enable/disable the E-tag support.\n\n" 900 901 "port config (port_id) pctype mapping reset\n" 902 " Reset flow type to pctype mapping on a port\n\n" 903 904 "port config (port_id) pctype mapping update" 905 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n" 906 " Update a flow type to pctype mapping item on a port\n\n" 907 908 "port config (port_id) pctype (pctype_id) hash_inset|" 909 "fdir_inset|fdir_flx_inset get|set|clear field\n" 910 " (field_idx)\n" 911 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n" 912 913 "port config (port_id) pctype (pctype_id) hash_inset|" 914 "fdir_inset|fdir_flx_inset clear all" 915 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n" 916 917 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n" 918 " Add/remove UDP tunnel port for tunneling offload\n\n" 919 ); 920 } 921 922 if (show_all || !strcmp(res->section, "registers")) { 923 924 cmdline_printf( 925 cl, 926 "\n" 927 "Registers:\n" 928 "----------\n\n" 929 930 "read reg (port_id) (address)\n" 931 " Display value of a port register.\n\n" 932 933 "read regfield (port_id) (address) (bit_x) (bit_y)\n" 934 " Display a port register bit field.\n\n" 935 936 "read regbit (port_id) (address) (bit_x)\n" 937 " Display a single port register bit.\n\n" 938 939 "write reg (port_id) (address) (value)\n" 940 " Set value of a port register.\n\n" 941 942 "write regfield (port_id) (address) (bit_x) (bit_y)" 943 " (value)\n" 944 " Set bit field of a port register.\n\n" 945 946 "write regbit (port_id) (address) (bit_x) (value)\n" 947 " Set single bit value of a port register.\n\n" 948 ); 949 } 950 if (show_all || !strcmp(res->section, "filters")) { 951 952 cmdline_printf( 953 cl, 954 "\n" 955 "filters:\n" 956 "--------\n\n" 957 958 "ethertype_filter (port_id) (add|del)" 959 " (mac_addr|mac_ignr) (mac_address) ethertype" 960 " (ether_type) (drop|fwd) queue (queue_id)\n" 961 " Add/Del an ethertype filter.\n\n" 962 963 "2tuple_filter (port_id) (add|del)" 964 " dst_port (dst_port_value) protocol (protocol_value)" 965 " mask (mask_value) tcp_flags (tcp_flags_value)" 966 " priority (prio_value) queue (queue_id)\n" 967 " Add/Del a 2tuple filter.\n\n" 968 969 "5tuple_filter (port_id) (add|del)" 970 " dst_ip (dst_address) src_ip (src_address)" 971 " dst_port (dst_port_value) src_port (src_port_value)" 972 " protocol (protocol_value)" 973 " mask (mask_value) tcp_flags (tcp_flags_value)" 974 " priority (prio_value) queue (queue_id)\n" 975 " Add/Del a 5tuple filter.\n\n" 976 977 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)" 978 " Add/Del syn filter.\n\n" 979 980 "flex_filter (port_id) (add|del) len (len_value)" 981 " bytes (bytes_value) mask (mask_value)" 982 " priority (prio_value) queue (queue_id)\n" 983 " Add/Del a flex filter.\n\n" 984 985 "flow_director_filter (port_id) mode IP (add|del|update)" 986 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)" 987 " src (src_ip_address) dst (dst_ip_address)" 988 " tos (tos_value) proto (proto_value) ttl (ttl_value)" 989 " vlan (vlan_value) flexbytes (flexbytes_value)" 990 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 991 " fd_id (fd_id_value)\n" 992 " Add/Del an IP type flow director filter.\n\n" 993 994 "flow_director_filter (port_id) mode IP (add|del|update)" 995 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)" 996 " src (src_ip_address) (src_port)" 997 " dst (dst_ip_address) (dst_port)" 998 " tos (tos_value) ttl (ttl_value)" 999 " vlan (vlan_value) flexbytes (flexbytes_value)" 1000 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 1001 " fd_id (fd_id_value)\n" 1002 " Add/Del an UDP/TCP type flow director filter.\n\n" 1003 1004 "flow_director_filter (port_id) mode IP (add|del|update)" 1005 " flow (ipv4-sctp|ipv6-sctp)" 1006 " src (src_ip_address) (src_port)" 1007 " dst (dst_ip_address) (dst_port)" 1008 " tag (verification_tag) " 1009 " tos (tos_value) ttl (ttl_value)" 1010 " vlan (vlan_value)" 1011 " flexbytes (flexbytes_value) (drop|fwd)" 1012 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 1013 " Add/Del a SCTP type flow director filter.\n\n" 1014 1015 "flow_director_filter (port_id) mode IP (add|del|update)" 1016 " flow l2_payload ether (ethertype)" 1017 " flexbytes (flexbytes_value) (drop|fwd)" 1018 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 1019 " Add/Del a l2 payload type flow director filter.\n\n" 1020 1021 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)" 1022 " mac (mac_address) vlan (vlan_value)" 1023 " flexbytes (flexbytes_value) (drop|fwd)" 1024 " queue (queue_id) fd_id (fd_id_value)\n" 1025 " Add/Del a MAC-VLAN flow director filter.\n\n" 1026 1027 "flow_director_filter (port_id) mode Tunnel (add|del|update)" 1028 " mac (mac_address) vlan (vlan_value)" 1029 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)" 1030 " flexbytes (flexbytes_value) (drop|fwd)" 1031 " queue (queue_id) fd_id (fd_id_value)\n" 1032 " Add/Del a Tunnel flow director filter.\n\n" 1033 1034 "flow_director_filter (port_id) mode raw (add|del|update)" 1035 " flow (flow_id) (drop|fwd) queue (queue_id)" 1036 " fd_id (fd_id_value) packet (packet file name)\n" 1037 " Add/Del a raw type flow director filter.\n\n" 1038 1039 "flush_flow_director (port_id)\n" 1040 " Flush all flow director entries of a device.\n\n" 1041 1042 "flow_director_mask (port_id) mode IP vlan (vlan_value)" 1043 " src_mask (ipv4_src) (ipv6_src) (src_port)" 1044 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n" 1045 " Set flow director IP mask.\n\n" 1046 1047 "flow_director_mask (port_id) mode MAC-VLAN" 1048 " vlan (vlan_value)\n" 1049 " Set flow director MAC-VLAN mask.\n\n" 1050 1051 "flow_director_mask (port_id) mode Tunnel" 1052 " vlan (vlan_value) mac (mac_value)" 1053 " tunnel-type (tunnel_type_value)" 1054 " tunnel-id (tunnel_id_value)\n" 1055 " Set flow director Tunnel mask.\n\n" 1056 1057 "flow_director_flex_mask (port_id)" 1058 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 1059 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)" 1060 " (mask)\n" 1061 " Configure mask of flex payload.\n\n" 1062 1063 "flow_director_flex_payload (port_id)" 1064 " (raw|l2|l3|l4) (config)\n" 1065 " Configure flex payload selection.\n\n" 1066 1067 "get_sym_hash_ena_per_port (port_id)\n" 1068 " get symmetric hash enable configuration per port.\n\n" 1069 1070 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n" 1071 " set symmetric hash enable configuration per port" 1072 " to enable or disable.\n\n" 1073 1074 "get_hash_global_config (port_id)\n" 1075 " Get the global configurations of hash filters.\n\n" 1076 1077 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)" 1078 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1079 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)" 1080 " (enable|disable)\n" 1081 " Set the global configurations of hash filters.\n\n" 1082 1083 "set_hash_input_set (port_id) (ipv4|ipv4-frag|" 1084 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1085 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1086 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|" 1087 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|" 1088 "ipv6-next-header|udp-src-port|udp-dst-port|" 1089 "tcp-src-port|tcp-dst-port|sctp-src-port|" 1090 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|" 1091 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|" 1092 "fld-8th|none) (select|add)\n" 1093 " Set the input set for hash.\n\n" 1094 1095 "set_fdir_input_set (port_id) " 1096 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 1097 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1098 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|" 1099 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|" 1100 "ipv6-next-header|ipv6-hop-limits|udp-src-port|" 1101 "udp-dst-port|tcp-src-port|tcp-dst-port|" 1102 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)" 1103 " (select|add)\n" 1104 " Set the input set for FDir.\n\n" 1105 1106 "flow validate {port_id}" 1107 " [group {group_id}] [priority {level}]" 1108 " [ingress] [egress]" 1109 " pattern {item} [/ {item} [...]] / end" 1110 " actions {action} [/ {action} [...]] / end\n" 1111 " Check whether a flow rule can be created.\n\n" 1112 1113 "flow create {port_id}" 1114 " [group {group_id}] [priority {level}]" 1115 " [ingress] [egress]" 1116 " pattern {item} [/ {item} [...]] / end" 1117 " actions {action} [/ {action} [...]] / end\n" 1118 " Create a flow rule.\n\n" 1119 1120 "flow destroy {port_id} rule {rule_id} [...]\n" 1121 " Destroy specific flow rules.\n\n" 1122 1123 "flow flush {port_id}\n" 1124 " Destroy all flow rules.\n\n" 1125 1126 "flow query {port_id} {rule_id} {action}\n" 1127 " Query an existing flow rule.\n\n" 1128 1129 "flow list {port_id} [group {group_id}] [...]\n" 1130 " List existing flow rules sorted by priority," 1131 " filtered by group identifiers.\n\n" 1132 1133 "flow isolate {port_id} {boolean}\n" 1134 " Restrict ingress traffic to the defined" 1135 " flow rules\n\n" 1136 ); 1137 } 1138 } 1139 1140 cmdline_parse_token_string_t cmd_help_long_help = 1141 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help"); 1142 1143 cmdline_parse_token_string_t cmd_help_long_section = 1144 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section, 1145 "all#control#display#config#" 1146 "ports#registers#filters"); 1147 1148 cmdline_parse_inst_t cmd_help_long = { 1149 .f = cmd_help_long_parsed, 1150 .data = NULL, 1151 .help_str = "help all|control|display|config|ports|register|filters: " 1152 "Show help", 1153 .tokens = { 1154 (void *)&cmd_help_long_help, 1155 (void *)&cmd_help_long_section, 1156 NULL, 1157 }, 1158 }; 1159 1160 1161 /* *** start/stop/close all ports *** */ 1162 struct cmd_operate_port_result { 1163 cmdline_fixed_string_t keyword; 1164 cmdline_fixed_string_t name; 1165 cmdline_fixed_string_t value; 1166 }; 1167 1168 static void cmd_operate_port_parsed(void *parsed_result, 1169 __attribute__((unused)) struct cmdline *cl, 1170 __attribute__((unused)) void *data) 1171 { 1172 struct cmd_operate_port_result *res = parsed_result; 1173 1174 if (!strcmp(res->name, "start")) 1175 start_port(RTE_PORT_ALL); 1176 else if (!strcmp(res->name, "stop")) 1177 stop_port(RTE_PORT_ALL); 1178 else if (!strcmp(res->name, "close")) 1179 close_port(RTE_PORT_ALL); 1180 else if (!strcmp(res->name, "reset")) 1181 reset_port(RTE_PORT_ALL); 1182 else 1183 printf("Unknown parameter\n"); 1184 } 1185 1186 cmdline_parse_token_string_t cmd_operate_port_all_cmd = 1187 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword, 1188 "port"); 1189 cmdline_parse_token_string_t cmd_operate_port_all_port = 1190 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name, 1191 "start#stop#close#reset"); 1192 cmdline_parse_token_string_t cmd_operate_port_all_all = 1193 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all"); 1194 1195 cmdline_parse_inst_t cmd_operate_port = { 1196 .f = cmd_operate_port_parsed, 1197 .data = NULL, 1198 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports", 1199 .tokens = { 1200 (void *)&cmd_operate_port_all_cmd, 1201 (void *)&cmd_operate_port_all_port, 1202 (void *)&cmd_operate_port_all_all, 1203 NULL, 1204 }, 1205 }; 1206 1207 /* *** start/stop/close specific port *** */ 1208 struct cmd_operate_specific_port_result { 1209 cmdline_fixed_string_t keyword; 1210 cmdline_fixed_string_t name; 1211 uint8_t value; 1212 }; 1213 1214 static void cmd_operate_specific_port_parsed(void *parsed_result, 1215 __attribute__((unused)) struct cmdline *cl, 1216 __attribute__((unused)) void *data) 1217 { 1218 struct cmd_operate_specific_port_result *res = parsed_result; 1219 1220 if (!strcmp(res->name, "start")) 1221 start_port(res->value); 1222 else if (!strcmp(res->name, "stop")) 1223 stop_port(res->value); 1224 else if (!strcmp(res->name, "close")) 1225 close_port(res->value); 1226 else if (!strcmp(res->name, "reset")) 1227 reset_port(res->value); 1228 else 1229 printf("Unknown parameter\n"); 1230 } 1231 1232 cmdline_parse_token_string_t cmd_operate_specific_port_cmd = 1233 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1234 keyword, "port"); 1235 cmdline_parse_token_string_t cmd_operate_specific_port_port = 1236 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1237 name, "start#stop#close#reset"); 1238 cmdline_parse_token_num_t cmd_operate_specific_port_id = 1239 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result, 1240 value, UINT8); 1241 1242 cmdline_parse_inst_t cmd_operate_specific_port = { 1243 .f = cmd_operate_specific_port_parsed, 1244 .data = NULL, 1245 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id", 1246 .tokens = { 1247 (void *)&cmd_operate_specific_port_cmd, 1248 (void *)&cmd_operate_specific_port_port, 1249 (void *)&cmd_operate_specific_port_id, 1250 NULL, 1251 }, 1252 }; 1253 1254 /* *** attach a specified port *** */ 1255 struct cmd_operate_attach_port_result { 1256 cmdline_fixed_string_t port; 1257 cmdline_fixed_string_t keyword; 1258 cmdline_fixed_string_t identifier; 1259 }; 1260 1261 static void cmd_operate_attach_port_parsed(void *parsed_result, 1262 __attribute__((unused)) struct cmdline *cl, 1263 __attribute__((unused)) void *data) 1264 { 1265 struct cmd_operate_attach_port_result *res = parsed_result; 1266 1267 if (!strcmp(res->keyword, "attach")) 1268 attach_port(res->identifier); 1269 else 1270 printf("Unknown parameter\n"); 1271 } 1272 1273 cmdline_parse_token_string_t cmd_operate_attach_port_port = 1274 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1275 port, "port"); 1276 cmdline_parse_token_string_t cmd_operate_attach_port_keyword = 1277 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1278 keyword, "attach"); 1279 cmdline_parse_token_string_t cmd_operate_attach_port_identifier = 1280 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1281 identifier, NULL); 1282 1283 cmdline_parse_inst_t cmd_operate_attach_port = { 1284 .f = cmd_operate_attach_port_parsed, 1285 .data = NULL, 1286 .help_str = "port attach <identifier>: " 1287 "(identifier: pci address or virtual dev name)", 1288 .tokens = { 1289 (void *)&cmd_operate_attach_port_port, 1290 (void *)&cmd_operate_attach_port_keyword, 1291 (void *)&cmd_operate_attach_port_identifier, 1292 NULL, 1293 }, 1294 }; 1295 1296 /* *** detach a specified port *** */ 1297 struct cmd_operate_detach_port_result { 1298 cmdline_fixed_string_t port; 1299 cmdline_fixed_string_t keyword; 1300 portid_t port_id; 1301 }; 1302 1303 static void cmd_operate_detach_port_parsed(void *parsed_result, 1304 __attribute__((unused)) struct cmdline *cl, 1305 __attribute__((unused)) void *data) 1306 { 1307 struct cmd_operate_detach_port_result *res = parsed_result; 1308 1309 if (!strcmp(res->keyword, "detach")) 1310 detach_port(res->port_id); 1311 else 1312 printf("Unknown parameter\n"); 1313 } 1314 1315 cmdline_parse_token_string_t cmd_operate_detach_port_port = 1316 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1317 port, "port"); 1318 cmdline_parse_token_string_t cmd_operate_detach_port_keyword = 1319 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1320 keyword, "detach"); 1321 cmdline_parse_token_num_t cmd_operate_detach_port_port_id = 1322 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result, 1323 port_id, UINT16); 1324 1325 cmdline_parse_inst_t cmd_operate_detach_port = { 1326 .f = cmd_operate_detach_port_parsed, 1327 .data = NULL, 1328 .help_str = "port detach <port_id>", 1329 .tokens = { 1330 (void *)&cmd_operate_detach_port_port, 1331 (void *)&cmd_operate_detach_port_keyword, 1332 (void *)&cmd_operate_detach_port_port_id, 1333 NULL, 1334 }, 1335 }; 1336 1337 /* *** configure speed for all ports *** */ 1338 struct cmd_config_speed_all { 1339 cmdline_fixed_string_t port; 1340 cmdline_fixed_string_t keyword; 1341 cmdline_fixed_string_t all; 1342 cmdline_fixed_string_t item1; 1343 cmdline_fixed_string_t item2; 1344 cmdline_fixed_string_t value1; 1345 cmdline_fixed_string_t value2; 1346 }; 1347 1348 static int 1349 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed) 1350 { 1351 1352 int duplex; 1353 1354 if (!strcmp(duplexstr, "half")) { 1355 duplex = ETH_LINK_HALF_DUPLEX; 1356 } else if (!strcmp(duplexstr, "full")) { 1357 duplex = ETH_LINK_FULL_DUPLEX; 1358 } else if (!strcmp(duplexstr, "auto")) { 1359 duplex = ETH_LINK_FULL_DUPLEX; 1360 } else { 1361 printf("Unknown duplex parameter\n"); 1362 return -1; 1363 } 1364 1365 if (!strcmp(speedstr, "10")) { 1366 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1367 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M; 1368 } else if (!strcmp(speedstr, "100")) { 1369 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1370 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M; 1371 } else { 1372 if (duplex != ETH_LINK_FULL_DUPLEX) { 1373 printf("Invalid speed/duplex parameters\n"); 1374 return -1; 1375 } 1376 if (!strcmp(speedstr, "1000")) { 1377 *speed = ETH_LINK_SPEED_1G; 1378 } else if (!strcmp(speedstr, "10000")) { 1379 *speed = ETH_LINK_SPEED_10G; 1380 } else if (!strcmp(speedstr, "25000")) { 1381 *speed = ETH_LINK_SPEED_25G; 1382 } else if (!strcmp(speedstr, "40000")) { 1383 *speed = ETH_LINK_SPEED_40G; 1384 } else if (!strcmp(speedstr, "50000")) { 1385 *speed = ETH_LINK_SPEED_50G; 1386 } else if (!strcmp(speedstr, "100000")) { 1387 *speed = ETH_LINK_SPEED_100G; 1388 } else if (!strcmp(speedstr, "auto")) { 1389 *speed = ETH_LINK_SPEED_AUTONEG; 1390 } else { 1391 printf("Unknown speed parameter\n"); 1392 return -1; 1393 } 1394 } 1395 1396 return 0; 1397 } 1398 1399 static void 1400 cmd_config_speed_all_parsed(void *parsed_result, 1401 __attribute__((unused)) struct cmdline *cl, 1402 __attribute__((unused)) void *data) 1403 { 1404 struct cmd_config_speed_all *res = parsed_result; 1405 uint32_t link_speed; 1406 portid_t pid; 1407 1408 if (!all_ports_stopped()) { 1409 printf("Please stop all ports first\n"); 1410 return; 1411 } 1412 1413 if (parse_and_check_speed_duplex(res->value1, res->value2, 1414 &link_speed) < 0) 1415 return; 1416 1417 RTE_ETH_FOREACH_DEV(pid) { 1418 ports[pid].dev_conf.link_speeds = link_speed; 1419 } 1420 1421 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1422 } 1423 1424 cmdline_parse_token_string_t cmd_config_speed_all_port = 1425 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port"); 1426 cmdline_parse_token_string_t cmd_config_speed_all_keyword = 1427 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword, 1428 "config"); 1429 cmdline_parse_token_string_t cmd_config_speed_all_all = 1430 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all"); 1431 cmdline_parse_token_string_t cmd_config_speed_all_item1 = 1432 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed"); 1433 cmdline_parse_token_string_t cmd_config_speed_all_value1 = 1434 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1, 1435 "10#100#1000#10000#25000#40000#50000#100000#auto"); 1436 cmdline_parse_token_string_t cmd_config_speed_all_item2 = 1437 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex"); 1438 cmdline_parse_token_string_t cmd_config_speed_all_value2 = 1439 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2, 1440 "half#full#auto"); 1441 1442 cmdline_parse_inst_t cmd_config_speed_all = { 1443 .f = cmd_config_speed_all_parsed, 1444 .data = NULL, 1445 .help_str = "port config all speed " 1446 "10|100|1000|10000|25000|40000|50000|100000|auto duplex " 1447 "half|full|auto", 1448 .tokens = { 1449 (void *)&cmd_config_speed_all_port, 1450 (void *)&cmd_config_speed_all_keyword, 1451 (void *)&cmd_config_speed_all_all, 1452 (void *)&cmd_config_speed_all_item1, 1453 (void *)&cmd_config_speed_all_value1, 1454 (void *)&cmd_config_speed_all_item2, 1455 (void *)&cmd_config_speed_all_value2, 1456 NULL, 1457 }, 1458 }; 1459 1460 /* *** configure speed for specific port *** */ 1461 struct cmd_config_speed_specific { 1462 cmdline_fixed_string_t port; 1463 cmdline_fixed_string_t keyword; 1464 portid_t id; 1465 cmdline_fixed_string_t item1; 1466 cmdline_fixed_string_t item2; 1467 cmdline_fixed_string_t value1; 1468 cmdline_fixed_string_t value2; 1469 }; 1470 1471 static void 1472 cmd_config_speed_specific_parsed(void *parsed_result, 1473 __attribute__((unused)) struct cmdline *cl, 1474 __attribute__((unused)) void *data) 1475 { 1476 struct cmd_config_speed_specific *res = parsed_result; 1477 uint32_t link_speed; 1478 1479 if (!all_ports_stopped()) { 1480 printf("Please stop all ports first\n"); 1481 return; 1482 } 1483 1484 if (port_id_is_invalid(res->id, ENABLED_WARN)) 1485 return; 1486 1487 if (parse_and_check_speed_duplex(res->value1, res->value2, 1488 &link_speed) < 0) 1489 return; 1490 1491 ports[res->id].dev_conf.link_speeds = link_speed; 1492 1493 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1494 } 1495 1496 1497 cmdline_parse_token_string_t cmd_config_speed_specific_port = 1498 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port, 1499 "port"); 1500 cmdline_parse_token_string_t cmd_config_speed_specific_keyword = 1501 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword, 1502 "config"); 1503 cmdline_parse_token_num_t cmd_config_speed_specific_id = 1504 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16); 1505 cmdline_parse_token_string_t cmd_config_speed_specific_item1 = 1506 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1, 1507 "speed"); 1508 cmdline_parse_token_string_t cmd_config_speed_specific_value1 = 1509 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1, 1510 "10#100#1000#10000#25000#40000#50000#100000#auto"); 1511 cmdline_parse_token_string_t cmd_config_speed_specific_item2 = 1512 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2, 1513 "duplex"); 1514 cmdline_parse_token_string_t cmd_config_speed_specific_value2 = 1515 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2, 1516 "half#full#auto"); 1517 1518 cmdline_parse_inst_t cmd_config_speed_specific = { 1519 .f = cmd_config_speed_specific_parsed, 1520 .data = NULL, 1521 .help_str = "port config <port_id> speed " 1522 "10|100|1000|10000|25000|40000|50000|100000|auto duplex " 1523 "half|full|auto", 1524 .tokens = { 1525 (void *)&cmd_config_speed_specific_port, 1526 (void *)&cmd_config_speed_specific_keyword, 1527 (void *)&cmd_config_speed_specific_id, 1528 (void *)&cmd_config_speed_specific_item1, 1529 (void *)&cmd_config_speed_specific_value1, 1530 (void *)&cmd_config_speed_specific_item2, 1531 (void *)&cmd_config_speed_specific_value2, 1532 NULL, 1533 }, 1534 }; 1535 1536 /* *** configure loopback for all ports *** */ 1537 struct cmd_config_loopback_all { 1538 cmdline_fixed_string_t port; 1539 cmdline_fixed_string_t keyword; 1540 cmdline_fixed_string_t all; 1541 cmdline_fixed_string_t item; 1542 uint32_t mode; 1543 }; 1544 1545 static void 1546 cmd_config_loopback_all_parsed(void *parsed_result, 1547 __attribute__((unused)) struct cmdline *cl, 1548 __attribute__((unused)) void *data) 1549 { 1550 struct cmd_config_loopback_all *res = parsed_result; 1551 portid_t pid; 1552 1553 if (!all_ports_stopped()) { 1554 printf("Please stop all ports first\n"); 1555 return; 1556 } 1557 1558 RTE_ETH_FOREACH_DEV(pid) { 1559 ports[pid].dev_conf.lpbk_mode = res->mode; 1560 } 1561 1562 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1563 } 1564 1565 cmdline_parse_token_string_t cmd_config_loopback_all_port = 1566 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port"); 1567 cmdline_parse_token_string_t cmd_config_loopback_all_keyword = 1568 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword, 1569 "config"); 1570 cmdline_parse_token_string_t cmd_config_loopback_all_all = 1571 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all"); 1572 cmdline_parse_token_string_t cmd_config_loopback_all_item = 1573 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item, 1574 "loopback"); 1575 cmdline_parse_token_num_t cmd_config_loopback_all_mode = 1576 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32); 1577 1578 cmdline_parse_inst_t cmd_config_loopback_all = { 1579 .f = cmd_config_loopback_all_parsed, 1580 .data = NULL, 1581 .help_str = "port config all loopback <mode>", 1582 .tokens = { 1583 (void *)&cmd_config_loopback_all_port, 1584 (void *)&cmd_config_loopback_all_keyword, 1585 (void *)&cmd_config_loopback_all_all, 1586 (void *)&cmd_config_loopback_all_item, 1587 (void *)&cmd_config_loopback_all_mode, 1588 NULL, 1589 }, 1590 }; 1591 1592 /* *** configure loopback for specific port *** */ 1593 struct cmd_config_loopback_specific { 1594 cmdline_fixed_string_t port; 1595 cmdline_fixed_string_t keyword; 1596 uint16_t port_id; 1597 cmdline_fixed_string_t item; 1598 uint32_t mode; 1599 }; 1600 1601 static void 1602 cmd_config_loopback_specific_parsed(void *parsed_result, 1603 __attribute__((unused)) struct cmdline *cl, 1604 __attribute__((unused)) void *data) 1605 { 1606 struct cmd_config_loopback_specific *res = parsed_result; 1607 1608 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 1609 return; 1610 1611 if (!port_is_stopped(res->port_id)) { 1612 printf("Please stop port %u first\n", res->port_id); 1613 return; 1614 } 1615 1616 ports[res->port_id].dev_conf.lpbk_mode = res->mode; 1617 1618 cmd_reconfig_device_queue(res->port_id, 1, 1); 1619 } 1620 1621 1622 cmdline_parse_token_string_t cmd_config_loopback_specific_port = 1623 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port, 1624 "port"); 1625 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword = 1626 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword, 1627 "config"); 1628 cmdline_parse_token_num_t cmd_config_loopback_specific_id = 1629 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id, 1630 UINT16); 1631 cmdline_parse_token_string_t cmd_config_loopback_specific_item = 1632 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item, 1633 "loopback"); 1634 cmdline_parse_token_num_t cmd_config_loopback_specific_mode = 1635 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode, 1636 UINT32); 1637 1638 cmdline_parse_inst_t cmd_config_loopback_specific = { 1639 .f = cmd_config_loopback_specific_parsed, 1640 .data = NULL, 1641 .help_str = "port config <port_id> loopback <mode>", 1642 .tokens = { 1643 (void *)&cmd_config_loopback_specific_port, 1644 (void *)&cmd_config_loopback_specific_keyword, 1645 (void *)&cmd_config_loopback_specific_id, 1646 (void *)&cmd_config_loopback_specific_item, 1647 (void *)&cmd_config_loopback_specific_mode, 1648 NULL, 1649 }, 1650 }; 1651 1652 /* *** configure txq/rxq, txd/rxd *** */ 1653 struct cmd_config_rx_tx { 1654 cmdline_fixed_string_t port; 1655 cmdline_fixed_string_t keyword; 1656 cmdline_fixed_string_t all; 1657 cmdline_fixed_string_t name; 1658 uint16_t value; 1659 }; 1660 1661 static void 1662 cmd_config_rx_tx_parsed(void *parsed_result, 1663 __attribute__((unused)) struct cmdline *cl, 1664 __attribute__((unused)) void *data) 1665 { 1666 struct cmd_config_rx_tx *res = parsed_result; 1667 1668 if (!all_ports_stopped()) { 1669 printf("Please stop all ports first\n"); 1670 return; 1671 } 1672 if (!strcmp(res->name, "rxq")) { 1673 if (!res->value && !nb_txq) { 1674 printf("Warning: Either rx or tx queues should be non zero\n"); 1675 return; 1676 } 1677 if (check_nb_rxq(res->value) != 0) 1678 return; 1679 nb_rxq = res->value; 1680 } 1681 else if (!strcmp(res->name, "txq")) { 1682 if (!res->value && !nb_rxq) { 1683 printf("Warning: Either rx or tx queues should be non zero\n"); 1684 return; 1685 } 1686 if (check_nb_txq(res->value) != 0) 1687 return; 1688 nb_txq = res->value; 1689 } 1690 else if (!strcmp(res->name, "rxd")) { 1691 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) { 1692 printf("rxd %d invalid - must be > 0 && <= %d\n", 1693 res->value, RTE_TEST_RX_DESC_MAX); 1694 return; 1695 } 1696 nb_rxd = res->value; 1697 } else if (!strcmp(res->name, "txd")) { 1698 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) { 1699 printf("txd %d invalid - must be > 0 && <= %d\n", 1700 res->value, RTE_TEST_TX_DESC_MAX); 1701 return; 1702 } 1703 nb_txd = res->value; 1704 } else { 1705 printf("Unknown parameter\n"); 1706 return; 1707 } 1708 1709 fwd_config_setup(); 1710 1711 init_port_config(); 1712 1713 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1714 } 1715 1716 cmdline_parse_token_string_t cmd_config_rx_tx_port = 1717 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port"); 1718 cmdline_parse_token_string_t cmd_config_rx_tx_keyword = 1719 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config"); 1720 cmdline_parse_token_string_t cmd_config_rx_tx_all = 1721 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all"); 1722 cmdline_parse_token_string_t cmd_config_rx_tx_name = 1723 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name, 1724 "rxq#txq#rxd#txd"); 1725 cmdline_parse_token_num_t cmd_config_rx_tx_value = 1726 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16); 1727 1728 cmdline_parse_inst_t cmd_config_rx_tx = { 1729 .f = cmd_config_rx_tx_parsed, 1730 .data = NULL, 1731 .help_str = "port config all rxq|txq|rxd|txd <value>", 1732 .tokens = { 1733 (void *)&cmd_config_rx_tx_port, 1734 (void *)&cmd_config_rx_tx_keyword, 1735 (void *)&cmd_config_rx_tx_all, 1736 (void *)&cmd_config_rx_tx_name, 1737 (void *)&cmd_config_rx_tx_value, 1738 NULL, 1739 }, 1740 }; 1741 1742 /* *** config max packet length *** */ 1743 struct cmd_config_max_pkt_len_result { 1744 cmdline_fixed_string_t port; 1745 cmdline_fixed_string_t keyword; 1746 cmdline_fixed_string_t all; 1747 cmdline_fixed_string_t name; 1748 uint32_t value; 1749 }; 1750 1751 static void 1752 cmd_config_max_pkt_len_parsed(void *parsed_result, 1753 __attribute__((unused)) struct cmdline *cl, 1754 __attribute__((unused)) void *data) 1755 { 1756 struct cmd_config_max_pkt_len_result *res = parsed_result; 1757 portid_t pid; 1758 1759 if (!all_ports_stopped()) { 1760 printf("Please stop all ports first\n"); 1761 return; 1762 } 1763 1764 RTE_ETH_FOREACH_DEV(pid) { 1765 struct rte_port *port = &ports[pid]; 1766 uint64_t rx_offloads = port->dev_conf.rxmode.offloads; 1767 1768 if (!strcmp(res->name, "max-pkt-len")) { 1769 if (res->value < ETHER_MIN_LEN) { 1770 printf("max-pkt-len can not be less than %d\n", 1771 ETHER_MIN_LEN); 1772 return; 1773 } 1774 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len) 1775 return; 1776 1777 port->dev_conf.rxmode.max_rx_pkt_len = res->value; 1778 if (res->value > ETHER_MAX_LEN) 1779 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; 1780 else 1781 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; 1782 port->dev_conf.rxmode.offloads = rx_offloads; 1783 } else { 1784 printf("Unknown parameter\n"); 1785 return; 1786 } 1787 } 1788 1789 init_port_config(); 1790 1791 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1792 } 1793 1794 cmdline_parse_token_string_t cmd_config_max_pkt_len_port = 1795 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port, 1796 "port"); 1797 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword = 1798 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword, 1799 "config"); 1800 cmdline_parse_token_string_t cmd_config_max_pkt_len_all = 1801 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all, 1802 "all"); 1803 cmdline_parse_token_string_t cmd_config_max_pkt_len_name = 1804 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name, 1805 "max-pkt-len"); 1806 cmdline_parse_token_num_t cmd_config_max_pkt_len_value = 1807 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value, 1808 UINT32); 1809 1810 cmdline_parse_inst_t cmd_config_max_pkt_len = { 1811 .f = cmd_config_max_pkt_len_parsed, 1812 .data = NULL, 1813 .help_str = "port config all max-pkt-len <value>", 1814 .tokens = { 1815 (void *)&cmd_config_max_pkt_len_port, 1816 (void *)&cmd_config_max_pkt_len_keyword, 1817 (void *)&cmd_config_max_pkt_len_all, 1818 (void *)&cmd_config_max_pkt_len_name, 1819 (void *)&cmd_config_max_pkt_len_value, 1820 NULL, 1821 }, 1822 }; 1823 1824 /* *** configure port MTU *** */ 1825 struct cmd_config_mtu_result { 1826 cmdline_fixed_string_t port; 1827 cmdline_fixed_string_t keyword; 1828 cmdline_fixed_string_t mtu; 1829 portid_t port_id; 1830 uint16_t value; 1831 }; 1832 1833 static void 1834 cmd_config_mtu_parsed(void *parsed_result, 1835 __attribute__((unused)) struct cmdline *cl, 1836 __attribute__((unused)) void *data) 1837 { 1838 struct cmd_config_mtu_result *res = parsed_result; 1839 1840 if (res->value < ETHER_MIN_LEN) { 1841 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN); 1842 return; 1843 } 1844 port_mtu_set(res->port_id, res->value); 1845 } 1846 1847 cmdline_parse_token_string_t cmd_config_mtu_port = 1848 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port, 1849 "port"); 1850 cmdline_parse_token_string_t cmd_config_mtu_keyword = 1851 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 1852 "config"); 1853 cmdline_parse_token_string_t cmd_config_mtu_mtu = 1854 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 1855 "mtu"); 1856 cmdline_parse_token_num_t cmd_config_mtu_port_id = 1857 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16); 1858 cmdline_parse_token_num_t cmd_config_mtu_value = 1859 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16); 1860 1861 cmdline_parse_inst_t cmd_config_mtu = { 1862 .f = cmd_config_mtu_parsed, 1863 .data = NULL, 1864 .help_str = "port config mtu <port_id> <value>", 1865 .tokens = { 1866 (void *)&cmd_config_mtu_port, 1867 (void *)&cmd_config_mtu_keyword, 1868 (void *)&cmd_config_mtu_mtu, 1869 (void *)&cmd_config_mtu_port_id, 1870 (void *)&cmd_config_mtu_value, 1871 NULL, 1872 }, 1873 }; 1874 1875 /* *** configure rx mode *** */ 1876 struct cmd_config_rx_mode_flag { 1877 cmdline_fixed_string_t port; 1878 cmdline_fixed_string_t keyword; 1879 cmdline_fixed_string_t all; 1880 cmdline_fixed_string_t name; 1881 cmdline_fixed_string_t value; 1882 }; 1883 1884 static void 1885 cmd_config_rx_mode_flag_parsed(void *parsed_result, 1886 __attribute__((unused)) struct cmdline *cl, 1887 __attribute__((unused)) void *data) 1888 { 1889 struct cmd_config_rx_mode_flag *res = parsed_result; 1890 portid_t pid; 1891 1892 if (!all_ports_stopped()) { 1893 printf("Please stop all ports first\n"); 1894 return; 1895 } 1896 1897 RTE_ETH_FOREACH_DEV(pid) { 1898 struct rte_port *port; 1899 uint64_t rx_offloads; 1900 1901 port = &ports[pid]; 1902 rx_offloads = port->dev_conf.rxmode.offloads; 1903 if (!strcmp(res->name, "crc-strip")) { 1904 if (!strcmp(res->value, "on")) { 1905 rx_offloads &= ~DEV_RX_OFFLOAD_KEEP_CRC; 1906 } else if (!strcmp(res->value, "off")) { 1907 rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC; 1908 } else { 1909 printf("Unknown parameter\n"); 1910 return; 1911 } 1912 } else if (!strcmp(res->name, "scatter")) { 1913 if (!strcmp(res->value, "on")) { 1914 rx_offloads |= DEV_RX_OFFLOAD_SCATTER; 1915 } else if (!strcmp(res->value, "off")) { 1916 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER; 1917 } else { 1918 printf("Unknown parameter\n"); 1919 return; 1920 } 1921 } else if (!strcmp(res->name, "rx-cksum")) { 1922 if (!strcmp(res->value, "on")) 1923 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM; 1924 else if (!strcmp(res->value, "off")) 1925 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM; 1926 else { 1927 printf("Unknown parameter\n"); 1928 return; 1929 } 1930 } else if (!strcmp(res->name, "rx-timestamp")) { 1931 if (!strcmp(res->value, "on")) 1932 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP; 1933 else if (!strcmp(res->value, "off")) 1934 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP; 1935 else { 1936 printf("Unknown parameter\n"); 1937 return; 1938 } 1939 } else if (!strcmp(res->name, "hw-vlan")) { 1940 if (!strcmp(res->value, "on")) { 1941 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER | 1942 DEV_RX_OFFLOAD_VLAN_STRIP); 1943 } else if (!strcmp(res->value, "off")) { 1944 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER | 1945 DEV_RX_OFFLOAD_VLAN_STRIP); 1946 } else { 1947 printf("Unknown parameter\n"); 1948 return; 1949 } 1950 } else if (!strcmp(res->name, "hw-vlan-filter")) { 1951 if (!strcmp(res->value, "on")) 1952 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER; 1953 else if (!strcmp(res->value, "off")) 1954 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER; 1955 else { 1956 printf("Unknown parameter\n"); 1957 return; 1958 } 1959 } else if (!strcmp(res->name, "hw-vlan-strip")) { 1960 if (!strcmp(res->value, "on")) 1961 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP; 1962 else if (!strcmp(res->value, "off")) 1963 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP; 1964 else { 1965 printf("Unknown parameter\n"); 1966 return; 1967 } 1968 } else if (!strcmp(res->name, "hw-vlan-extend")) { 1969 if (!strcmp(res->value, "on")) 1970 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND; 1971 else if (!strcmp(res->value, "off")) 1972 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND; 1973 else { 1974 printf("Unknown parameter\n"); 1975 return; 1976 } 1977 } else if (!strcmp(res->name, "drop-en")) { 1978 if (!strcmp(res->value, "on")) 1979 rx_drop_en = 1; 1980 else if (!strcmp(res->value, "off")) 1981 rx_drop_en = 0; 1982 else { 1983 printf("Unknown parameter\n"); 1984 return; 1985 } 1986 } else { 1987 printf("Unknown parameter\n"); 1988 return; 1989 } 1990 port->dev_conf.rxmode.offloads = rx_offloads; 1991 } 1992 1993 init_port_config(); 1994 1995 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1996 } 1997 1998 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port = 1999 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port"); 2000 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword = 2001 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword, 2002 "config"); 2003 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all = 2004 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all"); 2005 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name = 2006 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name, 2007 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#" 2008 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend"); 2009 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = 2010 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value, 2011 "on#off"); 2012 2013 cmdline_parse_inst_t cmd_config_rx_mode_flag = { 2014 .f = cmd_config_rx_mode_flag_parsed, 2015 .data = NULL, 2016 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|" 2017 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off", 2018 .tokens = { 2019 (void *)&cmd_config_rx_mode_flag_port, 2020 (void *)&cmd_config_rx_mode_flag_keyword, 2021 (void *)&cmd_config_rx_mode_flag_all, 2022 (void *)&cmd_config_rx_mode_flag_name, 2023 (void *)&cmd_config_rx_mode_flag_value, 2024 NULL, 2025 }, 2026 }; 2027 2028 /* *** configure rss *** */ 2029 struct cmd_config_rss { 2030 cmdline_fixed_string_t port; 2031 cmdline_fixed_string_t keyword; 2032 cmdline_fixed_string_t all; 2033 cmdline_fixed_string_t name; 2034 cmdline_fixed_string_t value; 2035 }; 2036 2037 static void 2038 cmd_config_rss_parsed(void *parsed_result, 2039 __attribute__((unused)) struct cmdline *cl, 2040 __attribute__((unused)) void *data) 2041 { 2042 struct cmd_config_rss *res = parsed_result; 2043 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, }; 2044 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, }; 2045 int use_default = 0; 2046 int all_updated = 1; 2047 int diag; 2048 uint16_t i; 2049 2050 if (!strcmp(res->value, "all")) 2051 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP | 2052 ETH_RSS_UDP | ETH_RSS_SCTP | 2053 ETH_RSS_L2_PAYLOAD; 2054 else if (!strcmp(res->value, "ip")) 2055 rss_conf.rss_hf = ETH_RSS_IP; 2056 else if (!strcmp(res->value, "udp")) 2057 rss_conf.rss_hf = ETH_RSS_UDP; 2058 else if (!strcmp(res->value, "tcp")) 2059 rss_conf.rss_hf = ETH_RSS_TCP; 2060 else if (!strcmp(res->value, "sctp")) 2061 rss_conf.rss_hf = ETH_RSS_SCTP; 2062 else if (!strcmp(res->value, "ether")) 2063 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD; 2064 else if (!strcmp(res->value, "port")) 2065 rss_conf.rss_hf = ETH_RSS_PORT; 2066 else if (!strcmp(res->value, "vxlan")) 2067 rss_conf.rss_hf = ETH_RSS_VXLAN; 2068 else if (!strcmp(res->value, "geneve")) 2069 rss_conf.rss_hf = ETH_RSS_GENEVE; 2070 else if (!strcmp(res->value, "nvgre")) 2071 rss_conf.rss_hf = ETH_RSS_NVGRE; 2072 else if (!strcmp(res->value, "none")) 2073 rss_conf.rss_hf = 0; 2074 else if (!strcmp(res->value, "default")) 2075 use_default = 1; 2076 else if (isdigit(res->value[0]) && atoi(res->value) > 0 && 2077 atoi(res->value) < 64) 2078 rss_conf.rss_hf = 1ULL << atoi(res->value); 2079 else { 2080 printf("Unknown parameter\n"); 2081 return; 2082 } 2083 rss_conf.rss_key = NULL; 2084 /* Update global configuration for RSS types. */ 2085 RTE_ETH_FOREACH_DEV(i) { 2086 struct rte_eth_rss_conf local_rss_conf; 2087 2088 rte_eth_dev_info_get(i, &dev_info); 2089 if (use_default) 2090 rss_conf.rss_hf = dev_info.flow_type_rss_offloads; 2091 2092 local_rss_conf = rss_conf; 2093 local_rss_conf.rss_hf = rss_conf.rss_hf & 2094 dev_info.flow_type_rss_offloads; 2095 if (local_rss_conf.rss_hf != rss_conf.rss_hf) { 2096 printf("Port %u modified RSS hash function based on hardware support," 2097 "requested:%#"PRIx64" configured:%#"PRIx64"\n", 2098 i, rss_conf.rss_hf, local_rss_conf.rss_hf); 2099 } 2100 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf); 2101 if (diag < 0) { 2102 all_updated = 0; 2103 printf("Configuration of RSS hash at ethernet port %d " 2104 "failed with error (%d): %s.\n", 2105 i, -diag, strerror(-diag)); 2106 } 2107 } 2108 if (all_updated && !use_default) 2109 rss_hf = rss_conf.rss_hf; 2110 } 2111 2112 cmdline_parse_token_string_t cmd_config_rss_port = 2113 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port"); 2114 cmdline_parse_token_string_t cmd_config_rss_keyword = 2115 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config"); 2116 cmdline_parse_token_string_t cmd_config_rss_all = 2117 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all"); 2118 cmdline_parse_token_string_t cmd_config_rss_name = 2119 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss"); 2120 cmdline_parse_token_string_t cmd_config_rss_value = 2121 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL); 2122 2123 cmdline_parse_inst_t cmd_config_rss = { 2124 .f = cmd_config_rss_parsed, 2125 .data = NULL, 2126 .help_str = "port config all rss " 2127 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>", 2128 .tokens = { 2129 (void *)&cmd_config_rss_port, 2130 (void *)&cmd_config_rss_keyword, 2131 (void *)&cmd_config_rss_all, 2132 (void *)&cmd_config_rss_name, 2133 (void *)&cmd_config_rss_value, 2134 NULL, 2135 }, 2136 }; 2137 2138 /* *** configure rss hash key *** */ 2139 struct cmd_config_rss_hash_key { 2140 cmdline_fixed_string_t port; 2141 cmdline_fixed_string_t config; 2142 portid_t port_id; 2143 cmdline_fixed_string_t rss_hash_key; 2144 cmdline_fixed_string_t rss_type; 2145 cmdline_fixed_string_t key; 2146 }; 2147 2148 static uint8_t 2149 hexa_digit_to_value(char hexa_digit) 2150 { 2151 if ((hexa_digit >= '0') && (hexa_digit <= '9')) 2152 return (uint8_t) (hexa_digit - '0'); 2153 if ((hexa_digit >= 'a') && (hexa_digit <= 'f')) 2154 return (uint8_t) ((hexa_digit - 'a') + 10); 2155 if ((hexa_digit >= 'A') && (hexa_digit <= 'F')) 2156 return (uint8_t) ((hexa_digit - 'A') + 10); 2157 /* Invalid hexa digit */ 2158 return 0xFF; 2159 } 2160 2161 static uint8_t 2162 parse_and_check_key_hexa_digit(char *key, int idx) 2163 { 2164 uint8_t hexa_v; 2165 2166 hexa_v = hexa_digit_to_value(key[idx]); 2167 if (hexa_v == 0xFF) 2168 printf("invalid key: character %c at position %d is not a " 2169 "valid hexa digit\n", key[idx], idx); 2170 return hexa_v; 2171 } 2172 2173 static void 2174 cmd_config_rss_hash_key_parsed(void *parsed_result, 2175 __attribute__((unused)) struct cmdline *cl, 2176 __attribute__((unused)) void *data) 2177 { 2178 struct cmd_config_rss_hash_key *res = parsed_result; 2179 uint8_t hash_key[RSS_HASH_KEY_LENGTH]; 2180 uint8_t xdgt0; 2181 uint8_t xdgt1; 2182 int i; 2183 struct rte_eth_dev_info dev_info; 2184 uint8_t hash_key_size; 2185 uint32_t key_len; 2186 2187 memset(&dev_info, 0, sizeof(dev_info)); 2188 rte_eth_dev_info_get(res->port_id, &dev_info); 2189 if (dev_info.hash_key_size > 0 && 2190 dev_info.hash_key_size <= sizeof(hash_key)) 2191 hash_key_size = dev_info.hash_key_size; 2192 else { 2193 printf("dev_info did not provide a valid hash key size\n"); 2194 return; 2195 } 2196 /* Check the length of the RSS hash key */ 2197 key_len = strlen(res->key); 2198 if (key_len != (hash_key_size * 2)) { 2199 printf("key length: %d invalid - key must be a string of %d" 2200 " hexa-decimal numbers\n", 2201 (int) key_len, hash_key_size * 2); 2202 return; 2203 } 2204 /* Translate RSS hash key into binary representation */ 2205 for (i = 0; i < hash_key_size; i++) { 2206 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 2207 if (xdgt0 == 0xFF) 2208 return; 2209 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 2210 if (xdgt1 == 0xFF) 2211 return; 2212 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 2213 } 2214 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key, 2215 hash_key_size); 2216 } 2217 2218 cmdline_parse_token_string_t cmd_config_rss_hash_key_port = 2219 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port"); 2220 cmdline_parse_token_string_t cmd_config_rss_hash_key_config = 2221 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config, 2222 "config"); 2223 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id = 2224 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16); 2225 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key = 2226 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, 2227 rss_hash_key, "rss-hash-key"); 2228 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type = 2229 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type, 2230 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2231 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2232 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2233 "ipv6-tcp-ex#ipv6-udp-ex"); 2234 cmdline_parse_token_string_t cmd_config_rss_hash_key_value = 2235 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL); 2236 2237 cmdline_parse_inst_t cmd_config_rss_hash_key = { 2238 .f = cmd_config_rss_hash_key_parsed, 2239 .data = NULL, 2240 .help_str = "port config <port_id> rss-hash-key " 2241 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2242 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2243 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex " 2244 "<string of hex digits (variable length, NIC dependent)>", 2245 .tokens = { 2246 (void *)&cmd_config_rss_hash_key_port, 2247 (void *)&cmd_config_rss_hash_key_config, 2248 (void *)&cmd_config_rss_hash_key_port_id, 2249 (void *)&cmd_config_rss_hash_key_rss_hash_key, 2250 (void *)&cmd_config_rss_hash_key_rss_type, 2251 (void *)&cmd_config_rss_hash_key_value, 2252 NULL, 2253 }, 2254 }; 2255 2256 /* *** configure port rxq/txq ring size *** */ 2257 struct cmd_config_rxtx_ring_size { 2258 cmdline_fixed_string_t port; 2259 cmdline_fixed_string_t config; 2260 portid_t portid; 2261 cmdline_fixed_string_t rxtxq; 2262 uint16_t qid; 2263 cmdline_fixed_string_t rsize; 2264 uint16_t size; 2265 }; 2266 2267 static void 2268 cmd_config_rxtx_ring_size_parsed(void *parsed_result, 2269 __attribute__((unused)) struct cmdline *cl, 2270 __attribute__((unused)) void *data) 2271 { 2272 struct cmd_config_rxtx_ring_size *res = parsed_result; 2273 struct rte_port *port; 2274 uint8_t isrx; 2275 2276 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2277 return; 2278 2279 if (res->portid == (portid_t)RTE_PORT_ALL) { 2280 printf("Invalid port id\n"); 2281 return; 2282 } 2283 2284 port = &ports[res->portid]; 2285 2286 if (!strcmp(res->rxtxq, "rxq")) 2287 isrx = 1; 2288 else if (!strcmp(res->rxtxq, "txq")) 2289 isrx = 0; 2290 else { 2291 printf("Unknown parameter\n"); 2292 return; 2293 } 2294 2295 if (isrx && rx_queue_id_is_invalid(res->qid)) 2296 return; 2297 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2298 return; 2299 2300 if (isrx && res->size != 0 && res->size <= rx_free_thresh) { 2301 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n", 2302 rx_free_thresh); 2303 return; 2304 } 2305 2306 if (isrx) 2307 port->nb_rx_desc[res->qid] = res->size; 2308 else 2309 port->nb_tx_desc[res->qid] = res->size; 2310 2311 cmd_reconfig_device_queue(res->portid, 0, 1); 2312 } 2313 2314 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port = 2315 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2316 port, "port"); 2317 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config = 2318 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2319 config, "config"); 2320 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid = 2321 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2322 portid, UINT16); 2323 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq = 2324 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2325 rxtxq, "rxq#txq"); 2326 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid = 2327 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2328 qid, UINT16); 2329 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize = 2330 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2331 rsize, "ring_size"); 2332 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size = 2333 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2334 size, UINT16); 2335 2336 cmdline_parse_inst_t cmd_config_rxtx_ring_size = { 2337 .f = cmd_config_rxtx_ring_size_parsed, 2338 .data = NULL, 2339 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>", 2340 .tokens = { 2341 (void *)&cmd_config_rxtx_ring_size_port, 2342 (void *)&cmd_config_rxtx_ring_size_config, 2343 (void *)&cmd_config_rxtx_ring_size_portid, 2344 (void *)&cmd_config_rxtx_ring_size_rxtxq, 2345 (void *)&cmd_config_rxtx_ring_size_qid, 2346 (void *)&cmd_config_rxtx_ring_size_rsize, 2347 (void *)&cmd_config_rxtx_ring_size_size, 2348 NULL, 2349 }, 2350 }; 2351 2352 /* *** configure port rxq/txq start/stop *** */ 2353 struct cmd_config_rxtx_queue { 2354 cmdline_fixed_string_t port; 2355 portid_t portid; 2356 cmdline_fixed_string_t rxtxq; 2357 uint16_t qid; 2358 cmdline_fixed_string_t opname; 2359 }; 2360 2361 static void 2362 cmd_config_rxtx_queue_parsed(void *parsed_result, 2363 __attribute__((unused)) struct cmdline *cl, 2364 __attribute__((unused)) void *data) 2365 { 2366 struct cmd_config_rxtx_queue *res = parsed_result; 2367 uint8_t isrx; 2368 uint8_t isstart; 2369 int ret = 0; 2370 2371 if (test_done == 0) { 2372 printf("Please stop forwarding first\n"); 2373 return; 2374 } 2375 2376 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2377 return; 2378 2379 if (port_is_started(res->portid) != 1) { 2380 printf("Please start port %u first\n", res->portid); 2381 return; 2382 } 2383 2384 if (!strcmp(res->rxtxq, "rxq")) 2385 isrx = 1; 2386 else if (!strcmp(res->rxtxq, "txq")) 2387 isrx = 0; 2388 else { 2389 printf("Unknown parameter\n"); 2390 return; 2391 } 2392 2393 if (isrx && rx_queue_id_is_invalid(res->qid)) 2394 return; 2395 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2396 return; 2397 2398 if (!strcmp(res->opname, "start")) 2399 isstart = 1; 2400 else if (!strcmp(res->opname, "stop")) 2401 isstart = 0; 2402 else { 2403 printf("Unknown parameter\n"); 2404 return; 2405 } 2406 2407 if (isstart && isrx) 2408 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid); 2409 else if (!isstart && isrx) 2410 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid); 2411 else if (isstart && !isrx) 2412 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid); 2413 else 2414 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid); 2415 2416 if (ret == -ENOTSUP) 2417 printf("Function not supported in PMD driver\n"); 2418 } 2419 2420 cmdline_parse_token_string_t cmd_config_rxtx_queue_port = 2421 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port"); 2422 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid = 2423 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16); 2424 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq = 2425 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq"); 2426 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid = 2427 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16); 2428 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname = 2429 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname, 2430 "start#stop"); 2431 2432 cmdline_parse_inst_t cmd_config_rxtx_queue = { 2433 .f = cmd_config_rxtx_queue_parsed, 2434 .data = NULL, 2435 .help_str = "port <port_id> rxq|txq <queue_id> start|stop", 2436 .tokens = { 2437 (void *)&cmd_config_rxtx_queue_port, 2438 (void *)&cmd_config_rxtx_queue_portid, 2439 (void *)&cmd_config_rxtx_queue_rxtxq, 2440 (void *)&cmd_config_rxtx_queue_qid, 2441 (void *)&cmd_config_rxtx_queue_opname, 2442 NULL, 2443 }, 2444 }; 2445 2446 /* *** configure port rxq/txq deferred start on/off *** */ 2447 struct cmd_config_deferred_start_rxtx_queue { 2448 cmdline_fixed_string_t port; 2449 portid_t port_id; 2450 cmdline_fixed_string_t rxtxq; 2451 uint16_t qid; 2452 cmdline_fixed_string_t opname; 2453 cmdline_fixed_string_t state; 2454 }; 2455 2456 static void 2457 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result, 2458 __attribute__((unused)) struct cmdline *cl, 2459 __attribute__((unused)) void *data) 2460 { 2461 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result; 2462 struct rte_port *port; 2463 uint8_t isrx; 2464 uint8_t ison; 2465 uint8_t needreconfig = 0; 2466 2467 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 2468 return; 2469 2470 if (port_is_started(res->port_id) != 0) { 2471 printf("Please stop port %u first\n", res->port_id); 2472 return; 2473 } 2474 2475 port = &ports[res->port_id]; 2476 2477 isrx = !strcmp(res->rxtxq, "rxq"); 2478 2479 if (isrx && rx_queue_id_is_invalid(res->qid)) 2480 return; 2481 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2482 return; 2483 2484 ison = !strcmp(res->state, "on"); 2485 2486 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) { 2487 port->rx_conf[res->qid].rx_deferred_start = ison; 2488 needreconfig = 1; 2489 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) { 2490 port->tx_conf[res->qid].tx_deferred_start = ison; 2491 needreconfig = 1; 2492 } 2493 2494 if (needreconfig) 2495 cmd_reconfig_device_queue(res->port_id, 0, 1); 2496 } 2497 2498 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port = 2499 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2500 port, "port"); 2501 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id = 2502 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2503 port_id, UINT16); 2504 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq = 2505 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2506 rxtxq, "rxq#txq"); 2507 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid = 2508 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2509 qid, UINT16); 2510 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname = 2511 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2512 opname, "deferred_start"); 2513 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state = 2514 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2515 state, "on#off"); 2516 2517 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = { 2518 .f = cmd_config_deferred_start_rxtx_queue_parsed, 2519 .data = NULL, 2520 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off", 2521 .tokens = { 2522 (void *)&cmd_config_deferred_start_rxtx_queue_port, 2523 (void *)&cmd_config_deferred_start_rxtx_queue_port_id, 2524 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq, 2525 (void *)&cmd_config_deferred_start_rxtx_queue_qid, 2526 (void *)&cmd_config_deferred_start_rxtx_queue_opname, 2527 (void *)&cmd_config_deferred_start_rxtx_queue_state, 2528 NULL, 2529 }, 2530 }; 2531 2532 /* *** configure port rxq/txq setup *** */ 2533 struct cmd_setup_rxtx_queue { 2534 cmdline_fixed_string_t port; 2535 portid_t portid; 2536 cmdline_fixed_string_t rxtxq; 2537 uint16_t qid; 2538 cmdline_fixed_string_t setup; 2539 }; 2540 2541 /* Common CLI fields for queue setup */ 2542 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port = 2543 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port"); 2544 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid = 2545 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16); 2546 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq = 2547 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq"); 2548 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid = 2549 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16); 2550 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup = 2551 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup"); 2552 2553 static void 2554 cmd_setup_rxtx_queue_parsed( 2555 void *parsed_result, 2556 __attribute__((unused)) struct cmdline *cl, 2557 __attribute__((unused)) void *data) 2558 { 2559 struct cmd_setup_rxtx_queue *res = parsed_result; 2560 struct rte_port *port; 2561 struct rte_mempool *mp; 2562 unsigned int socket_id; 2563 uint8_t isrx = 0; 2564 int ret; 2565 2566 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2567 return; 2568 2569 if (res->portid == (portid_t)RTE_PORT_ALL) { 2570 printf("Invalid port id\n"); 2571 return; 2572 } 2573 2574 if (!strcmp(res->rxtxq, "rxq")) 2575 isrx = 1; 2576 else if (!strcmp(res->rxtxq, "txq")) 2577 isrx = 0; 2578 else { 2579 printf("Unknown parameter\n"); 2580 return; 2581 } 2582 2583 if (isrx && rx_queue_id_is_invalid(res->qid)) { 2584 printf("Invalid rx queue\n"); 2585 return; 2586 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) { 2587 printf("Invalid tx queue\n"); 2588 return; 2589 } 2590 2591 port = &ports[res->portid]; 2592 if (isrx) { 2593 socket_id = rxring_numa[res->portid]; 2594 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2595 socket_id = port->socket_id; 2596 2597 mp = mbuf_pool_find(socket_id); 2598 if (mp == NULL) { 2599 printf("Failed to setup RX queue: " 2600 "No mempool allocation" 2601 " on the socket %d\n", 2602 rxring_numa[res->portid]); 2603 return; 2604 } 2605 ret = rte_eth_rx_queue_setup(res->portid, 2606 res->qid, 2607 port->nb_rx_desc[res->qid], 2608 socket_id, 2609 &port->rx_conf[res->qid], 2610 mp); 2611 if (ret) 2612 printf("Failed to setup RX queue\n"); 2613 } else { 2614 socket_id = txring_numa[res->portid]; 2615 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2616 socket_id = port->socket_id; 2617 2618 ret = rte_eth_tx_queue_setup(res->portid, 2619 res->qid, 2620 port->nb_tx_desc[res->qid], 2621 socket_id, 2622 &port->tx_conf[res->qid]); 2623 if (ret) 2624 printf("Failed to setup TX queue\n"); 2625 } 2626 } 2627 2628 cmdline_parse_inst_t cmd_setup_rxtx_queue = { 2629 .f = cmd_setup_rxtx_queue_parsed, 2630 .data = NULL, 2631 .help_str = "port <port_id> rxq|txq <queue_idx> setup", 2632 .tokens = { 2633 (void *)&cmd_setup_rxtx_queue_port, 2634 (void *)&cmd_setup_rxtx_queue_portid, 2635 (void *)&cmd_setup_rxtx_queue_rxtxq, 2636 (void *)&cmd_setup_rxtx_queue_qid, 2637 (void *)&cmd_setup_rxtx_queue_setup, 2638 NULL, 2639 }, 2640 }; 2641 2642 2643 /* *** Configure RSS RETA *** */ 2644 struct cmd_config_rss_reta { 2645 cmdline_fixed_string_t port; 2646 cmdline_fixed_string_t keyword; 2647 portid_t port_id; 2648 cmdline_fixed_string_t name; 2649 cmdline_fixed_string_t list_name; 2650 cmdline_fixed_string_t list_of_items; 2651 }; 2652 2653 static int 2654 parse_reta_config(const char *str, 2655 struct rte_eth_rss_reta_entry64 *reta_conf, 2656 uint16_t nb_entries) 2657 { 2658 int i; 2659 unsigned size; 2660 uint16_t hash_index, idx, shift; 2661 uint16_t nb_queue; 2662 char s[256]; 2663 const char *p, *p0 = str; 2664 char *end; 2665 enum fieldnames { 2666 FLD_HASH_INDEX = 0, 2667 FLD_QUEUE, 2668 _NUM_FLD 2669 }; 2670 unsigned long int_fld[_NUM_FLD]; 2671 char *str_fld[_NUM_FLD]; 2672 2673 while ((p = strchr(p0,'(')) != NULL) { 2674 ++p; 2675 if((p0 = strchr(p,')')) == NULL) 2676 return -1; 2677 2678 size = p0 - p; 2679 if(size >= sizeof(s)) 2680 return -1; 2681 2682 snprintf(s, sizeof(s), "%.*s", size, p); 2683 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 2684 return -1; 2685 for (i = 0; i < _NUM_FLD; i++) { 2686 errno = 0; 2687 int_fld[i] = strtoul(str_fld[i], &end, 0); 2688 if (errno != 0 || end == str_fld[i] || 2689 int_fld[i] > 65535) 2690 return -1; 2691 } 2692 2693 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX]; 2694 nb_queue = (uint16_t)int_fld[FLD_QUEUE]; 2695 2696 if (hash_index >= nb_entries) { 2697 printf("Invalid RETA hash index=%d\n", hash_index); 2698 return -1; 2699 } 2700 2701 idx = hash_index / RTE_RETA_GROUP_SIZE; 2702 shift = hash_index % RTE_RETA_GROUP_SIZE; 2703 reta_conf[idx].mask |= (1ULL << shift); 2704 reta_conf[idx].reta[shift] = nb_queue; 2705 } 2706 2707 return 0; 2708 } 2709 2710 static void 2711 cmd_set_rss_reta_parsed(void *parsed_result, 2712 __attribute__((unused)) struct cmdline *cl, 2713 __attribute__((unused)) void *data) 2714 { 2715 int ret; 2716 struct rte_eth_dev_info dev_info; 2717 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2718 struct cmd_config_rss_reta *res = parsed_result; 2719 2720 memset(&dev_info, 0, sizeof(dev_info)); 2721 rte_eth_dev_info_get(res->port_id, &dev_info); 2722 if (dev_info.reta_size == 0) { 2723 printf("Redirection table size is 0 which is " 2724 "invalid for RSS\n"); 2725 return; 2726 } else 2727 printf("The reta size of port %d is %u\n", 2728 res->port_id, dev_info.reta_size); 2729 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) { 2730 printf("Currently do not support more than %u entries of " 2731 "redirection table\n", ETH_RSS_RETA_SIZE_512); 2732 return; 2733 } 2734 2735 memset(reta_conf, 0, sizeof(reta_conf)); 2736 if (!strcmp(res->list_name, "reta")) { 2737 if (parse_reta_config(res->list_of_items, reta_conf, 2738 dev_info.reta_size)) { 2739 printf("Invalid RSS Redirection Table " 2740 "config entered\n"); 2741 return; 2742 } 2743 ret = rte_eth_dev_rss_reta_update(res->port_id, 2744 reta_conf, dev_info.reta_size); 2745 if (ret != 0) 2746 printf("Bad redirection table parameter, " 2747 "return code = %d \n", ret); 2748 } 2749 } 2750 2751 cmdline_parse_token_string_t cmd_config_rss_reta_port = 2752 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port"); 2753 cmdline_parse_token_string_t cmd_config_rss_reta_keyword = 2754 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config"); 2755 cmdline_parse_token_num_t cmd_config_rss_reta_port_id = 2756 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16); 2757 cmdline_parse_token_string_t cmd_config_rss_reta_name = 2758 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss"); 2759 cmdline_parse_token_string_t cmd_config_rss_reta_list_name = 2760 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta"); 2761 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items = 2762 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items, 2763 NULL); 2764 cmdline_parse_inst_t cmd_config_rss_reta = { 2765 .f = cmd_set_rss_reta_parsed, 2766 .data = NULL, 2767 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>", 2768 .tokens = { 2769 (void *)&cmd_config_rss_reta_port, 2770 (void *)&cmd_config_rss_reta_keyword, 2771 (void *)&cmd_config_rss_reta_port_id, 2772 (void *)&cmd_config_rss_reta_name, 2773 (void *)&cmd_config_rss_reta_list_name, 2774 (void *)&cmd_config_rss_reta_list_of_items, 2775 NULL, 2776 }, 2777 }; 2778 2779 /* *** SHOW PORT RETA INFO *** */ 2780 struct cmd_showport_reta { 2781 cmdline_fixed_string_t show; 2782 cmdline_fixed_string_t port; 2783 portid_t port_id; 2784 cmdline_fixed_string_t rss; 2785 cmdline_fixed_string_t reta; 2786 uint16_t size; 2787 cmdline_fixed_string_t list_of_items; 2788 }; 2789 2790 static int 2791 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf, 2792 uint16_t nb_entries, 2793 char *str) 2794 { 2795 uint32_t size; 2796 const char *p, *p0 = str; 2797 char s[256]; 2798 char *end; 2799 char *str_fld[8]; 2800 uint16_t i; 2801 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) / 2802 RTE_RETA_GROUP_SIZE; 2803 int ret; 2804 2805 p = strchr(p0, '('); 2806 if (p == NULL) 2807 return -1; 2808 p++; 2809 p0 = strchr(p, ')'); 2810 if (p0 == NULL) 2811 return -1; 2812 size = p0 - p; 2813 if (size >= sizeof(s)) { 2814 printf("The string size exceeds the internal buffer size\n"); 2815 return -1; 2816 } 2817 snprintf(s, sizeof(s), "%.*s", size, p); 2818 ret = rte_strsplit(s, sizeof(s), str_fld, num, ','); 2819 if (ret <= 0 || ret != num) { 2820 printf("The bits of masks do not match the number of " 2821 "reta entries: %u\n", num); 2822 return -1; 2823 } 2824 for (i = 0; i < ret; i++) 2825 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0); 2826 2827 return 0; 2828 } 2829 2830 static void 2831 cmd_showport_reta_parsed(void *parsed_result, 2832 __attribute__((unused)) struct cmdline *cl, 2833 __attribute__((unused)) void *data) 2834 { 2835 struct cmd_showport_reta *res = parsed_result; 2836 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2837 struct rte_eth_dev_info dev_info; 2838 uint16_t max_reta_size; 2839 2840 memset(&dev_info, 0, sizeof(dev_info)); 2841 rte_eth_dev_info_get(res->port_id, &dev_info); 2842 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512); 2843 if (res->size == 0 || res->size > max_reta_size) { 2844 printf("Invalid redirection table size: %u (1-%u)\n", 2845 res->size, max_reta_size); 2846 return; 2847 } 2848 2849 memset(reta_conf, 0, sizeof(reta_conf)); 2850 if (showport_parse_reta_config(reta_conf, res->size, 2851 res->list_of_items) < 0) { 2852 printf("Invalid string: %s for reta masks\n", 2853 res->list_of_items); 2854 return; 2855 } 2856 port_rss_reta_info(res->port_id, reta_conf, res->size); 2857 } 2858 2859 cmdline_parse_token_string_t cmd_showport_reta_show = 2860 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show"); 2861 cmdline_parse_token_string_t cmd_showport_reta_port = 2862 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port"); 2863 cmdline_parse_token_num_t cmd_showport_reta_port_id = 2864 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16); 2865 cmdline_parse_token_string_t cmd_showport_reta_rss = 2866 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss"); 2867 cmdline_parse_token_string_t cmd_showport_reta_reta = 2868 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta"); 2869 cmdline_parse_token_num_t cmd_showport_reta_size = 2870 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16); 2871 cmdline_parse_token_string_t cmd_showport_reta_list_of_items = 2872 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, 2873 list_of_items, NULL); 2874 2875 cmdline_parse_inst_t cmd_showport_reta = { 2876 .f = cmd_showport_reta_parsed, 2877 .data = NULL, 2878 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>", 2879 .tokens = { 2880 (void *)&cmd_showport_reta_show, 2881 (void *)&cmd_showport_reta_port, 2882 (void *)&cmd_showport_reta_port_id, 2883 (void *)&cmd_showport_reta_rss, 2884 (void *)&cmd_showport_reta_reta, 2885 (void *)&cmd_showport_reta_size, 2886 (void *)&cmd_showport_reta_list_of_items, 2887 NULL, 2888 }, 2889 }; 2890 2891 /* *** Show RSS hash configuration *** */ 2892 struct cmd_showport_rss_hash { 2893 cmdline_fixed_string_t show; 2894 cmdline_fixed_string_t port; 2895 portid_t port_id; 2896 cmdline_fixed_string_t rss_hash; 2897 cmdline_fixed_string_t rss_type; 2898 cmdline_fixed_string_t key; /* optional argument */ 2899 }; 2900 2901 static void cmd_showport_rss_hash_parsed(void *parsed_result, 2902 __attribute__((unused)) struct cmdline *cl, 2903 void *show_rss_key) 2904 { 2905 struct cmd_showport_rss_hash *res = parsed_result; 2906 2907 port_rss_hash_conf_show(res->port_id, res->rss_type, 2908 show_rss_key != NULL); 2909 } 2910 2911 cmdline_parse_token_string_t cmd_showport_rss_hash_show = 2912 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show"); 2913 cmdline_parse_token_string_t cmd_showport_rss_hash_port = 2914 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port"); 2915 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id = 2916 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16); 2917 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = 2918 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash, 2919 "rss-hash"); 2920 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash_info = 2921 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_type, 2922 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2923 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2924 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2925 "ipv6-tcp-ex#ipv6-udp-ex"); 2926 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = 2927 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); 2928 2929 cmdline_parse_inst_t cmd_showport_rss_hash = { 2930 .f = cmd_showport_rss_hash_parsed, 2931 .data = NULL, 2932 .help_str = "show port <port_id> rss-hash " 2933 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2934 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2935 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex", 2936 .tokens = { 2937 (void *)&cmd_showport_rss_hash_show, 2938 (void *)&cmd_showport_rss_hash_port, 2939 (void *)&cmd_showport_rss_hash_port_id, 2940 (void *)&cmd_showport_rss_hash_rss_hash, 2941 (void *)&cmd_showport_rss_hash_rss_hash_info, 2942 NULL, 2943 }, 2944 }; 2945 2946 cmdline_parse_inst_t cmd_showport_rss_hash_key = { 2947 .f = cmd_showport_rss_hash_parsed, 2948 .data = (void *)1, 2949 .help_str = "show port <port_id> rss-hash " 2950 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2951 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2952 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex key", 2953 .tokens = { 2954 (void *)&cmd_showport_rss_hash_show, 2955 (void *)&cmd_showport_rss_hash_port, 2956 (void *)&cmd_showport_rss_hash_port_id, 2957 (void *)&cmd_showport_rss_hash_rss_hash, 2958 (void *)&cmd_showport_rss_hash_rss_hash_info, 2959 (void *)&cmd_showport_rss_hash_rss_key, 2960 NULL, 2961 }, 2962 }; 2963 2964 /* *** Configure DCB *** */ 2965 struct cmd_config_dcb { 2966 cmdline_fixed_string_t port; 2967 cmdline_fixed_string_t config; 2968 portid_t port_id; 2969 cmdline_fixed_string_t dcb; 2970 cmdline_fixed_string_t vt; 2971 cmdline_fixed_string_t vt_en; 2972 uint8_t num_tcs; 2973 cmdline_fixed_string_t pfc; 2974 cmdline_fixed_string_t pfc_en; 2975 }; 2976 2977 static void 2978 cmd_config_dcb_parsed(void *parsed_result, 2979 __attribute__((unused)) struct cmdline *cl, 2980 __attribute__((unused)) void *data) 2981 { 2982 struct cmd_config_dcb *res = parsed_result; 2983 portid_t port_id = res->port_id; 2984 struct rte_port *port; 2985 uint8_t pfc_en; 2986 int ret; 2987 2988 port = &ports[port_id]; 2989 /** Check if the port is not started **/ 2990 if (port->port_status != RTE_PORT_STOPPED) { 2991 printf("Please stop port %d first\n", port_id); 2992 return; 2993 } 2994 2995 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) { 2996 printf("The invalid number of traffic class," 2997 " only 4 or 8 allowed.\n"); 2998 return; 2999 } 3000 3001 if (nb_fwd_lcores < res->num_tcs) { 3002 printf("nb_cores shouldn't be less than number of TCs.\n"); 3003 return; 3004 } 3005 if (!strncmp(res->pfc_en, "on", 2)) 3006 pfc_en = 1; 3007 else 3008 pfc_en = 0; 3009 3010 /* DCB in VT mode */ 3011 if (!strncmp(res->vt_en, "on", 2)) 3012 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED, 3013 (enum rte_eth_nb_tcs)res->num_tcs, 3014 pfc_en); 3015 else 3016 ret = init_port_dcb_config(port_id, DCB_ENABLED, 3017 (enum rte_eth_nb_tcs)res->num_tcs, 3018 pfc_en); 3019 3020 3021 if (ret != 0) { 3022 printf("Cannot initialize network ports.\n"); 3023 return; 3024 } 3025 3026 cmd_reconfig_device_queue(port_id, 1, 1); 3027 } 3028 3029 cmdline_parse_token_string_t cmd_config_dcb_port = 3030 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port"); 3031 cmdline_parse_token_string_t cmd_config_dcb_config = 3032 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config"); 3033 cmdline_parse_token_num_t cmd_config_dcb_port_id = 3034 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16); 3035 cmdline_parse_token_string_t cmd_config_dcb_dcb = 3036 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb"); 3037 cmdline_parse_token_string_t cmd_config_dcb_vt = 3038 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt"); 3039 cmdline_parse_token_string_t cmd_config_dcb_vt_en = 3040 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off"); 3041 cmdline_parse_token_num_t cmd_config_dcb_num_tcs = 3042 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8); 3043 cmdline_parse_token_string_t cmd_config_dcb_pfc= 3044 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc"); 3045 cmdline_parse_token_string_t cmd_config_dcb_pfc_en = 3046 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off"); 3047 3048 cmdline_parse_inst_t cmd_config_dcb = { 3049 .f = cmd_config_dcb_parsed, 3050 .data = NULL, 3051 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off", 3052 .tokens = { 3053 (void *)&cmd_config_dcb_port, 3054 (void *)&cmd_config_dcb_config, 3055 (void *)&cmd_config_dcb_port_id, 3056 (void *)&cmd_config_dcb_dcb, 3057 (void *)&cmd_config_dcb_vt, 3058 (void *)&cmd_config_dcb_vt_en, 3059 (void *)&cmd_config_dcb_num_tcs, 3060 (void *)&cmd_config_dcb_pfc, 3061 (void *)&cmd_config_dcb_pfc_en, 3062 NULL, 3063 }, 3064 }; 3065 3066 /* *** configure number of packets per burst *** */ 3067 struct cmd_config_burst { 3068 cmdline_fixed_string_t port; 3069 cmdline_fixed_string_t keyword; 3070 cmdline_fixed_string_t all; 3071 cmdline_fixed_string_t name; 3072 uint16_t value; 3073 }; 3074 3075 static void 3076 cmd_config_burst_parsed(void *parsed_result, 3077 __attribute__((unused)) struct cmdline *cl, 3078 __attribute__((unused)) void *data) 3079 { 3080 struct cmd_config_burst *res = parsed_result; 3081 struct rte_eth_dev_info dev_info; 3082 uint16_t rec_nb_pkts; 3083 3084 if (!all_ports_stopped()) { 3085 printf("Please stop all ports first\n"); 3086 return; 3087 } 3088 3089 if (!strcmp(res->name, "burst")) { 3090 if (res->value == 0) { 3091 /* If user gives a value of zero, query the PMD for 3092 * its recommended Rx burst size. Testpmd uses a single 3093 * size for all ports, so assume all ports are the same 3094 * NIC model and use the values from Port 0. 3095 */ 3096 rte_eth_dev_info_get(0, &dev_info); 3097 rec_nb_pkts = dev_info.default_rxportconf.burst_size; 3098 3099 if (rec_nb_pkts == 0) { 3100 printf("PMD does not recommend a burst size.\n" 3101 "User provided value must be between" 3102 " 1 and %d\n", MAX_PKT_BURST); 3103 return; 3104 } else if (rec_nb_pkts > MAX_PKT_BURST) { 3105 printf("PMD recommended burst size of %d" 3106 " exceeds maximum value of %d\n", 3107 rec_nb_pkts, MAX_PKT_BURST); 3108 return; 3109 } 3110 printf("Using PMD-provided burst value of %d\n", 3111 rec_nb_pkts); 3112 nb_pkt_per_burst = rec_nb_pkts; 3113 } else if (res->value > MAX_PKT_BURST) { 3114 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST); 3115 return; 3116 } else 3117 nb_pkt_per_burst = res->value; 3118 } else { 3119 printf("Unknown parameter\n"); 3120 return; 3121 } 3122 3123 init_port_config(); 3124 3125 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3126 } 3127 3128 cmdline_parse_token_string_t cmd_config_burst_port = 3129 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port"); 3130 cmdline_parse_token_string_t cmd_config_burst_keyword = 3131 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config"); 3132 cmdline_parse_token_string_t cmd_config_burst_all = 3133 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all"); 3134 cmdline_parse_token_string_t cmd_config_burst_name = 3135 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst"); 3136 cmdline_parse_token_num_t cmd_config_burst_value = 3137 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16); 3138 3139 cmdline_parse_inst_t cmd_config_burst = { 3140 .f = cmd_config_burst_parsed, 3141 .data = NULL, 3142 .help_str = "port config all burst <value>", 3143 .tokens = { 3144 (void *)&cmd_config_burst_port, 3145 (void *)&cmd_config_burst_keyword, 3146 (void *)&cmd_config_burst_all, 3147 (void *)&cmd_config_burst_name, 3148 (void *)&cmd_config_burst_value, 3149 NULL, 3150 }, 3151 }; 3152 3153 /* *** configure rx/tx queues *** */ 3154 struct cmd_config_thresh { 3155 cmdline_fixed_string_t port; 3156 cmdline_fixed_string_t keyword; 3157 cmdline_fixed_string_t all; 3158 cmdline_fixed_string_t name; 3159 uint8_t value; 3160 }; 3161 3162 static void 3163 cmd_config_thresh_parsed(void *parsed_result, 3164 __attribute__((unused)) struct cmdline *cl, 3165 __attribute__((unused)) void *data) 3166 { 3167 struct cmd_config_thresh *res = parsed_result; 3168 3169 if (!all_ports_stopped()) { 3170 printf("Please stop all ports first\n"); 3171 return; 3172 } 3173 3174 if (!strcmp(res->name, "txpt")) 3175 tx_pthresh = res->value; 3176 else if(!strcmp(res->name, "txht")) 3177 tx_hthresh = res->value; 3178 else if(!strcmp(res->name, "txwt")) 3179 tx_wthresh = res->value; 3180 else if(!strcmp(res->name, "rxpt")) 3181 rx_pthresh = res->value; 3182 else if(!strcmp(res->name, "rxht")) 3183 rx_hthresh = res->value; 3184 else if(!strcmp(res->name, "rxwt")) 3185 rx_wthresh = res->value; 3186 else { 3187 printf("Unknown parameter\n"); 3188 return; 3189 } 3190 3191 init_port_config(); 3192 3193 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3194 } 3195 3196 cmdline_parse_token_string_t cmd_config_thresh_port = 3197 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port"); 3198 cmdline_parse_token_string_t cmd_config_thresh_keyword = 3199 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config"); 3200 cmdline_parse_token_string_t cmd_config_thresh_all = 3201 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all"); 3202 cmdline_parse_token_string_t cmd_config_thresh_name = 3203 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name, 3204 "txpt#txht#txwt#rxpt#rxht#rxwt"); 3205 cmdline_parse_token_num_t cmd_config_thresh_value = 3206 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8); 3207 3208 cmdline_parse_inst_t cmd_config_thresh = { 3209 .f = cmd_config_thresh_parsed, 3210 .data = NULL, 3211 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>", 3212 .tokens = { 3213 (void *)&cmd_config_thresh_port, 3214 (void *)&cmd_config_thresh_keyword, 3215 (void *)&cmd_config_thresh_all, 3216 (void *)&cmd_config_thresh_name, 3217 (void *)&cmd_config_thresh_value, 3218 NULL, 3219 }, 3220 }; 3221 3222 /* *** configure free/rs threshold *** */ 3223 struct cmd_config_threshold { 3224 cmdline_fixed_string_t port; 3225 cmdline_fixed_string_t keyword; 3226 cmdline_fixed_string_t all; 3227 cmdline_fixed_string_t name; 3228 uint16_t value; 3229 }; 3230 3231 static void 3232 cmd_config_threshold_parsed(void *parsed_result, 3233 __attribute__((unused)) struct cmdline *cl, 3234 __attribute__((unused)) void *data) 3235 { 3236 struct cmd_config_threshold *res = parsed_result; 3237 3238 if (!all_ports_stopped()) { 3239 printf("Please stop all ports first\n"); 3240 return; 3241 } 3242 3243 if (!strcmp(res->name, "txfreet")) 3244 tx_free_thresh = res->value; 3245 else if (!strcmp(res->name, "txrst")) 3246 tx_rs_thresh = res->value; 3247 else if (!strcmp(res->name, "rxfreet")) 3248 rx_free_thresh = res->value; 3249 else { 3250 printf("Unknown parameter\n"); 3251 return; 3252 } 3253 3254 init_port_config(); 3255 3256 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3257 } 3258 3259 cmdline_parse_token_string_t cmd_config_threshold_port = 3260 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port"); 3261 cmdline_parse_token_string_t cmd_config_threshold_keyword = 3262 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword, 3263 "config"); 3264 cmdline_parse_token_string_t cmd_config_threshold_all = 3265 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all"); 3266 cmdline_parse_token_string_t cmd_config_threshold_name = 3267 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name, 3268 "txfreet#txrst#rxfreet"); 3269 cmdline_parse_token_num_t cmd_config_threshold_value = 3270 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16); 3271 3272 cmdline_parse_inst_t cmd_config_threshold = { 3273 .f = cmd_config_threshold_parsed, 3274 .data = NULL, 3275 .help_str = "port config all txfreet|txrst|rxfreet <value>", 3276 .tokens = { 3277 (void *)&cmd_config_threshold_port, 3278 (void *)&cmd_config_threshold_keyword, 3279 (void *)&cmd_config_threshold_all, 3280 (void *)&cmd_config_threshold_name, 3281 (void *)&cmd_config_threshold_value, 3282 NULL, 3283 }, 3284 }; 3285 3286 /* *** stop *** */ 3287 struct cmd_stop_result { 3288 cmdline_fixed_string_t stop; 3289 }; 3290 3291 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result, 3292 __attribute__((unused)) struct cmdline *cl, 3293 __attribute__((unused)) void *data) 3294 { 3295 stop_packet_forwarding(); 3296 } 3297 3298 cmdline_parse_token_string_t cmd_stop_stop = 3299 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop"); 3300 3301 cmdline_parse_inst_t cmd_stop = { 3302 .f = cmd_stop_parsed, 3303 .data = NULL, 3304 .help_str = "stop: Stop packet forwarding", 3305 .tokens = { 3306 (void *)&cmd_stop_stop, 3307 NULL, 3308 }, 3309 }; 3310 3311 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */ 3312 3313 unsigned int 3314 parse_item_list(char* str, const char* item_name, unsigned int max_items, 3315 unsigned int *parsed_items, int check_unique_values) 3316 { 3317 unsigned int nb_item; 3318 unsigned int value; 3319 unsigned int i; 3320 unsigned int j; 3321 int value_ok; 3322 char c; 3323 3324 /* 3325 * First parse all items in the list and store their value. 3326 */ 3327 value = 0; 3328 nb_item = 0; 3329 value_ok = 0; 3330 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) { 3331 c = str[i]; 3332 if ((c >= '0') && (c <= '9')) { 3333 value = (unsigned int) (value * 10 + (c - '0')); 3334 value_ok = 1; 3335 continue; 3336 } 3337 if (c != ',') { 3338 printf("character %c is not a decimal digit\n", c); 3339 return 0; 3340 } 3341 if (! value_ok) { 3342 printf("No valid value before comma\n"); 3343 return 0; 3344 } 3345 if (nb_item < max_items) { 3346 parsed_items[nb_item] = value; 3347 value_ok = 0; 3348 value = 0; 3349 } 3350 nb_item++; 3351 } 3352 if (nb_item >= max_items) { 3353 printf("Number of %s = %u > %u (maximum items)\n", 3354 item_name, nb_item + 1, max_items); 3355 return 0; 3356 } 3357 parsed_items[nb_item++] = value; 3358 if (! check_unique_values) 3359 return nb_item; 3360 3361 /* 3362 * Then, check that all values in the list are differents. 3363 * No optimization here... 3364 */ 3365 for (i = 0; i < nb_item; i++) { 3366 for (j = i + 1; j < nb_item; j++) { 3367 if (parsed_items[j] == parsed_items[i]) { 3368 printf("duplicated %s %u at index %u and %u\n", 3369 item_name, parsed_items[i], i, j); 3370 return 0; 3371 } 3372 } 3373 } 3374 return nb_item; 3375 } 3376 3377 struct cmd_set_list_result { 3378 cmdline_fixed_string_t cmd_keyword; 3379 cmdline_fixed_string_t list_name; 3380 cmdline_fixed_string_t list_of_items; 3381 }; 3382 3383 static void cmd_set_list_parsed(void *parsed_result, 3384 __attribute__((unused)) struct cmdline *cl, 3385 __attribute__((unused)) void *data) 3386 { 3387 struct cmd_set_list_result *res; 3388 union { 3389 unsigned int lcorelist[RTE_MAX_LCORE]; 3390 unsigned int portlist[RTE_MAX_ETHPORTS]; 3391 } parsed_items; 3392 unsigned int nb_item; 3393 3394 if (test_done == 0) { 3395 printf("Please stop forwarding first\n"); 3396 return; 3397 } 3398 3399 res = parsed_result; 3400 if (!strcmp(res->list_name, "corelist")) { 3401 nb_item = parse_item_list(res->list_of_items, "core", 3402 RTE_MAX_LCORE, 3403 parsed_items.lcorelist, 1); 3404 if (nb_item > 0) { 3405 set_fwd_lcores_list(parsed_items.lcorelist, nb_item); 3406 fwd_config_setup(); 3407 } 3408 return; 3409 } 3410 if (!strcmp(res->list_name, "portlist")) { 3411 nb_item = parse_item_list(res->list_of_items, "port", 3412 RTE_MAX_ETHPORTS, 3413 parsed_items.portlist, 1); 3414 if (nb_item > 0) { 3415 set_fwd_ports_list(parsed_items.portlist, nb_item); 3416 fwd_config_setup(); 3417 } 3418 } 3419 } 3420 3421 cmdline_parse_token_string_t cmd_set_list_keyword = 3422 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword, 3423 "set"); 3424 cmdline_parse_token_string_t cmd_set_list_name = 3425 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name, 3426 "corelist#portlist"); 3427 cmdline_parse_token_string_t cmd_set_list_of_items = 3428 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items, 3429 NULL); 3430 3431 cmdline_parse_inst_t cmd_set_fwd_list = { 3432 .f = cmd_set_list_parsed, 3433 .data = NULL, 3434 .help_str = "set corelist|portlist <list0[,list1]*>", 3435 .tokens = { 3436 (void *)&cmd_set_list_keyword, 3437 (void *)&cmd_set_list_name, 3438 (void *)&cmd_set_list_of_items, 3439 NULL, 3440 }, 3441 }; 3442 3443 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */ 3444 3445 struct cmd_setmask_result { 3446 cmdline_fixed_string_t set; 3447 cmdline_fixed_string_t mask; 3448 uint64_t hexavalue; 3449 }; 3450 3451 static void cmd_set_mask_parsed(void *parsed_result, 3452 __attribute__((unused)) struct cmdline *cl, 3453 __attribute__((unused)) void *data) 3454 { 3455 struct cmd_setmask_result *res = parsed_result; 3456 3457 if (test_done == 0) { 3458 printf("Please stop forwarding first\n"); 3459 return; 3460 } 3461 if (!strcmp(res->mask, "coremask")) { 3462 set_fwd_lcores_mask(res->hexavalue); 3463 fwd_config_setup(); 3464 } else if (!strcmp(res->mask, "portmask")) { 3465 set_fwd_ports_mask(res->hexavalue); 3466 fwd_config_setup(); 3467 } 3468 } 3469 3470 cmdline_parse_token_string_t cmd_setmask_set = 3471 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set"); 3472 cmdline_parse_token_string_t cmd_setmask_mask = 3473 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask, 3474 "coremask#portmask"); 3475 cmdline_parse_token_num_t cmd_setmask_value = 3476 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64); 3477 3478 cmdline_parse_inst_t cmd_set_fwd_mask = { 3479 .f = cmd_set_mask_parsed, 3480 .data = NULL, 3481 .help_str = "set coremask|portmask <hexadecimal value>", 3482 .tokens = { 3483 (void *)&cmd_setmask_set, 3484 (void *)&cmd_setmask_mask, 3485 (void *)&cmd_setmask_value, 3486 NULL, 3487 }, 3488 }; 3489 3490 /* 3491 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION 3492 */ 3493 struct cmd_set_result { 3494 cmdline_fixed_string_t set; 3495 cmdline_fixed_string_t what; 3496 uint16_t value; 3497 }; 3498 3499 static void cmd_set_parsed(void *parsed_result, 3500 __attribute__((unused)) struct cmdline *cl, 3501 __attribute__((unused)) void *data) 3502 { 3503 struct cmd_set_result *res = parsed_result; 3504 if (!strcmp(res->what, "nbport")) { 3505 set_fwd_ports_number(res->value); 3506 fwd_config_setup(); 3507 } else if (!strcmp(res->what, "nbcore")) { 3508 set_fwd_lcores_number(res->value); 3509 fwd_config_setup(); 3510 } else if (!strcmp(res->what, "burst")) 3511 set_nb_pkt_per_burst(res->value); 3512 else if (!strcmp(res->what, "verbose")) 3513 set_verbose_level(res->value); 3514 } 3515 3516 cmdline_parse_token_string_t cmd_set_set = 3517 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set"); 3518 cmdline_parse_token_string_t cmd_set_what = 3519 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what, 3520 "nbport#nbcore#burst#verbose"); 3521 cmdline_parse_token_num_t cmd_set_value = 3522 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16); 3523 3524 cmdline_parse_inst_t cmd_set_numbers = { 3525 .f = cmd_set_parsed, 3526 .data = NULL, 3527 .help_str = "set nbport|nbcore|burst|verbose <value>", 3528 .tokens = { 3529 (void *)&cmd_set_set, 3530 (void *)&cmd_set_what, 3531 (void *)&cmd_set_value, 3532 NULL, 3533 }, 3534 }; 3535 3536 /* *** SET LOG LEVEL CONFIGURATION *** */ 3537 3538 struct cmd_set_log_result { 3539 cmdline_fixed_string_t set; 3540 cmdline_fixed_string_t log; 3541 cmdline_fixed_string_t type; 3542 uint32_t level; 3543 }; 3544 3545 static void 3546 cmd_set_log_parsed(void *parsed_result, 3547 __attribute__((unused)) struct cmdline *cl, 3548 __attribute__((unused)) void *data) 3549 { 3550 struct cmd_set_log_result *res; 3551 int ret; 3552 3553 res = parsed_result; 3554 if (!strcmp(res->type, "global")) 3555 rte_log_set_global_level(res->level); 3556 else { 3557 ret = rte_log_set_level_regexp(res->type, res->level); 3558 if (ret < 0) 3559 printf("Unable to set log level\n"); 3560 } 3561 } 3562 3563 cmdline_parse_token_string_t cmd_set_log_set = 3564 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set"); 3565 cmdline_parse_token_string_t cmd_set_log_log = 3566 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log"); 3567 cmdline_parse_token_string_t cmd_set_log_type = 3568 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL); 3569 cmdline_parse_token_num_t cmd_set_log_level = 3570 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32); 3571 3572 cmdline_parse_inst_t cmd_set_log = { 3573 .f = cmd_set_log_parsed, 3574 .data = NULL, 3575 .help_str = "set log global|<type> <level>", 3576 .tokens = { 3577 (void *)&cmd_set_log_set, 3578 (void *)&cmd_set_log_log, 3579 (void *)&cmd_set_log_type, 3580 (void *)&cmd_set_log_level, 3581 NULL, 3582 }, 3583 }; 3584 3585 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ 3586 3587 struct cmd_set_txpkts_result { 3588 cmdline_fixed_string_t cmd_keyword; 3589 cmdline_fixed_string_t txpkts; 3590 cmdline_fixed_string_t seg_lengths; 3591 }; 3592 3593 static void 3594 cmd_set_txpkts_parsed(void *parsed_result, 3595 __attribute__((unused)) struct cmdline *cl, 3596 __attribute__((unused)) void *data) 3597 { 3598 struct cmd_set_txpkts_result *res; 3599 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; 3600 unsigned int nb_segs; 3601 3602 res = parsed_result; 3603 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3604 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0); 3605 if (nb_segs > 0) 3606 set_tx_pkt_segments(seg_lengths, nb_segs); 3607 } 3608 3609 cmdline_parse_token_string_t cmd_set_txpkts_keyword = 3610 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3611 cmd_keyword, "set"); 3612 cmdline_parse_token_string_t cmd_set_txpkts_name = 3613 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3614 txpkts, "txpkts"); 3615 cmdline_parse_token_string_t cmd_set_txpkts_lengths = 3616 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3617 seg_lengths, NULL); 3618 3619 cmdline_parse_inst_t cmd_set_txpkts = { 3620 .f = cmd_set_txpkts_parsed, 3621 .data = NULL, 3622 .help_str = "set txpkts <len0[,len1]*>", 3623 .tokens = { 3624 (void *)&cmd_set_txpkts_keyword, 3625 (void *)&cmd_set_txpkts_name, 3626 (void *)&cmd_set_txpkts_lengths, 3627 NULL, 3628 }, 3629 }; 3630 3631 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */ 3632 3633 struct cmd_set_txsplit_result { 3634 cmdline_fixed_string_t cmd_keyword; 3635 cmdline_fixed_string_t txsplit; 3636 cmdline_fixed_string_t mode; 3637 }; 3638 3639 static void 3640 cmd_set_txsplit_parsed(void *parsed_result, 3641 __attribute__((unused)) struct cmdline *cl, 3642 __attribute__((unused)) void *data) 3643 { 3644 struct cmd_set_txsplit_result *res; 3645 3646 res = parsed_result; 3647 set_tx_pkt_split(res->mode); 3648 } 3649 3650 cmdline_parse_token_string_t cmd_set_txsplit_keyword = 3651 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3652 cmd_keyword, "set"); 3653 cmdline_parse_token_string_t cmd_set_txsplit_name = 3654 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3655 txsplit, "txsplit"); 3656 cmdline_parse_token_string_t cmd_set_txsplit_mode = 3657 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3658 mode, NULL); 3659 3660 cmdline_parse_inst_t cmd_set_txsplit = { 3661 .f = cmd_set_txsplit_parsed, 3662 .data = NULL, 3663 .help_str = "set txsplit on|off|rand", 3664 .tokens = { 3665 (void *)&cmd_set_txsplit_keyword, 3666 (void *)&cmd_set_txsplit_name, 3667 (void *)&cmd_set_txsplit_mode, 3668 NULL, 3669 }, 3670 }; 3671 3672 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */ 3673 struct cmd_rx_vlan_filter_all_result { 3674 cmdline_fixed_string_t rx_vlan; 3675 cmdline_fixed_string_t what; 3676 cmdline_fixed_string_t all; 3677 portid_t port_id; 3678 }; 3679 3680 static void 3681 cmd_rx_vlan_filter_all_parsed(void *parsed_result, 3682 __attribute__((unused)) struct cmdline *cl, 3683 __attribute__((unused)) void *data) 3684 { 3685 struct cmd_rx_vlan_filter_all_result *res = parsed_result; 3686 3687 if (!strcmp(res->what, "add")) 3688 rx_vlan_all_filter_set(res->port_id, 1); 3689 else 3690 rx_vlan_all_filter_set(res->port_id, 0); 3691 } 3692 3693 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan = 3694 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3695 rx_vlan, "rx_vlan"); 3696 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what = 3697 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3698 what, "add#rm"); 3699 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all = 3700 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3701 all, "all"); 3702 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid = 3703 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3704 port_id, UINT16); 3705 3706 cmdline_parse_inst_t cmd_rx_vlan_filter_all = { 3707 .f = cmd_rx_vlan_filter_all_parsed, 3708 .data = NULL, 3709 .help_str = "rx_vlan add|rm all <port_id>: " 3710 "Add/Remove all identifiers to/from the set of VLAN " 3711 "identifiers filtered by a port", 3712 .tokens = { 3713 (void *)&cmd_rx_vlan_filter_all_rx_vlan, 3714 (void *)&cmd_rx_vlan_filter_all_what, 3715 (void *)&cmd_rx_vlan_filter_all_all, 3716 (void *)&cmd_rx_vlan_filter_all_portid, 3717 NULL, 3718 }, 3719 }; 3720 3721 /* *** VLAN OFFLOAD SET ON A PORT *** */ 3722 struct cmd_vlan_offload_result { 3723 cmdline_fixed_string_t vlan; 3724 cmdline_fixed_string_t set; 3725 cmdline_fixed_string_t vlan_type; 3726 cmdline_fixed_string_t what; 3727 cmdline_fixed_string_t on; 3728 cmdline_fixed_string_t port_id; 3729 }; 3730 3731 static void 3732 cmd_vlan_offload_parsed(void *parsed_result, 3733 __attribute__((unused)) struct cmdline *cl, 3734 __attribute__((unused)) void *data) 3735 { 3736 int on; 3737 struct cmd_vlan_offload_result *res = parsed_result; 3738 char *str; 3739 int i, len = 0; 3740 portid_t port_id = 0; 3741 unsigned int tmp; 3742 3743 str = res->port_id; 3744 len = strnlen(str, STR_TOKEN_SIZE); 3745 i = 0; 3746 /* Get port_id first */ 3747 while(i < len){ 3748 if(str[i] == ',') 3749 break; 3750 3751 i++; 3752 } 3753 str[i]='\0'; 3754 tmp = strtoul(str, NULL, 0); 3755 /* If port_id greater that what portid_t can represent, return */ 3756 if(tmp >= RTE_MAX_ETHPORTS) 3757 return; 3758 port_id = (portid_t)tmp; 3759 3760 if (!strcmp(res->on, "on")) 3761 on = 1; 3762 else 3763 on = 0; 3764 3765 if (!strcmp(res->what, "strip")) 3766 rx_vlan_strip_set(port_id, on); 3767 else if(!strcmp(res->what, "stripq")){ 3768 uint16_t queue_id = 0; 3769 3770 /* No queue_id, return */ 3771 if(i + 1 >= len) { 3772 printf("must specify (port,queue_id)\n"); 3773 return; 3774 } 3775 tmp = strtoul(str + i + 1, NULL, 0); 3776 /* If queue_id greater that what 16-bits can represent, return */ 3777 if(tmp > 0xffff) 3778 return; 3779 3780 queue_id = (uint16_t)tmp; 3781 rx_vlan_strip_set_on_queue(port_id, queue_id, on); 3782 } 3783 else if (!strcmp(res->what, "filter")) 3784 rx_vlan_filter_set(port_id, on); 3785 else 3786 vlan_extend_set(port_id, on); 3787 3788 return; 3789 } 3790 3791 cmdline_parse_token_string_t cmd_vlan_offload_vlan = 3792 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3793 vlan, "vlan"); 3794 cmdline_parse_token_string_t cmd_vlan_offload_set = 3795 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3796 set, "set"); 3797 cmdline_parse_token_string_t cmd_vlan_offload_what = 3798 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3799 what, "strip#filter#qinq#stripq"); 3800 cmdline_parse_token_string_t cmd_vlan_offload_on = 3801 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3802 on, "on#off"); 3803 cmdline_parse_token_string_t cmd_vlan_offload_portid = 3804 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3805 port_id, NULL); 3806 3807 cmdline_parse_inst_t cmd_vlan_offload = { 3808 .f = cmd_vlan_offload_parsed, 3809 .data = NULL, 3810 .help_str = "vlan set strip|filter|qinq|stripq on|off " 3811 "<port_id[,queue_id]>: " 3812 "Filter/Strip for rx side qinq(extended) for both rx/tx sides", 3813 .tokens = { 3814 (void *)&cmd_vlan_offload_vlan, 3815 (void *)&cmd_vlan_offload_set, 3816 (void *)&cmd_vlan_offload_what, 3817 (void *)&cmd_vlan_offload_on, 3818 (void *)&cmd_vlan_offload_portid, 3819 NULL, 3820 }, 3821 }; 3822 3823 /* *** VLAN TPID SET ON A PORT *** */ 3824 struct cmd_vlan_tpid_result { 3825 cmdline_fixed_string_t vlan; 3826 cmdline_fixed_string_t set; 3827 cmdline_fixed_string_t vlan_type; 3828 cmdline_fixed_string_t what; 3829 uint16_t tp_id; 3830 portid_t port_id; 3831 }; 3832 3833 static void 3834 cmd_vlan_tpid_parsed(void *parsed_result, 3835 __attribute__((unused)) struct cmdline *cl, 3836 __attribute__((unused)) void *data) 3837 { 3838 struct cmd_vlan_tpid_result *res = parsed_result; 3839 enum rte_vlan_type vlan_type; 3840 3841 if (!strcmp(res->vlan_type, "inner")) 3842 vlan_type = ETH_VLAN_TYPE_INNER; 3843 else if (!strcmp(res->vlan_type, "outer")) 3844 vlan_type = ETH_VLAN_TYPE_OUTER; 3845 else { 3846 printf("Unknown vlan type\n"); 3847 return; 3848 } 3849 vlan_tpid_set(res->port_id, vlan_type, res->tp_id); 3850 } 3851 3852 cmdline_parse_token_string_t cmd_vlan_tpid_vlan = 3853 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3854 vlan, "vlan"); 3855 cmdline_parse_token_string_t cmd_vlan_tpid_set = 3856 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3857 set, "set"); 3858 cmdline_parse_token_string_t cmd_vlan_type = 3859 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3860 vlan_type, "inner#outer"); 3861 cmdline_parse_token_string_t cmd_vlan_tpid_what = 3862 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3863 what, "tpid"); 3864 cmdline_parse_token_num_t cmd_vlan_tpid_tpid = 3865 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 3866 tp_id, UINT16); 3867 cmdline_parse_token_num_t cmd_vlan_tpid_portid = 3868 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 3869 port_id, UINT16); 3870 3871 cmdline_parse_inst_t cmd_vlan_tpid = { 3872 .f = cmd_vlan_tpid_parsed, 3873 .data = NULL, 3874 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: " 3875 "Set the VLAN Ether type", 3876 .tokens = { 3877 (void *)&cmd_vlan_tpid_vlan, 3878 (void *)&cmd_vlan_tpid_set, 3879 (void *)&cmd_vlan_type, 3880 (void *)&cmd_vlan_tpid_what, 3881 (void *)&cmd_vlan_tpid_tpid, 3882 (void *)&cmd_vlan_tpid_portid, 3883 NULL, 3884 }, 3885 }; 3886 3887 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 3888 struct cmd_rx_vlan_filter_result { 3889 cmdline_fixed_string_t rx_vlan; 3890 cmdline_fixed_string_t what; 3891 uint16_t vlan_id; 3892 portid_t port_id; 3893 }; 3894 3895 static void 3896 cmd_rx_vlan_filter_parsed(void *parsed_result, 3897 __attribute__((unused)) struct cmdline *cl, 3898 __attribute__((unused)) void *data) 3899 { 3900 struct cmd_rx_vlan_filter_result *res = parsed_result; 3901 3902 if (!strcmp(res->what, "add")) 3903 rx_vft_set(res->port_id, res->vlan_id, 1); 3904 else 3905 rx_vft_set(res->port_id, res->vlan_id, 0); 3906 } 3907 3908 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan = 3909 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 3910 rx_vlan, "rx_vlan"); 3911 cmdline_parse_token_string_t cmd_rx_vlan_filter_what = 3912 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 3913 what, "add#rm"); 3914 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid = 3915 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 3916 vlan_id, UINT16); 3917 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid = 3918 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 3919 port_id, UINT16); 3920 3921 cmdline_parse_inst_t cmd_rx_vlan_filter = { 3922 .f = cmd_rx_vlan_filter_parsed, 3923 .data = NULL, 3924 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: " 3925 "Add/Remove a VLAN identifier to/from the set of VLAN " 3926 "identifiers filtered by a port", 3927 .tokens = { 3928 (void *)&cmd_rx_vlan_filter_rx_vlan, 3929 (void *)&cmd_rx_vlan_filter_what, 3930 (void *)&cmd_rx_vlan_filter_vlanid, 3931 (void *)&cmd_rx_vlan_filter_portid, 3932 NULL, 3933 }, 3934 }; 3935 3936 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 3937 struct cmd_tx_vlan_set_result { 3938 cmdline_fixed_string_t tx_vlan; 3939 cmdline_fixed_string_t set; 3940 portid_t port_id; 3941 uint16_t vlan_id; 3942 }; 3943 3944 static void 3945 cmd_tx_vlan_set_parsed(void *parsed_result, 3946 __attribute__((unused)) struct cmdline *cl, 3947 __attribute__((unused)) void *data) 3948 { 3949 struct cmd_tx_vlan_set_result *res = parsed_result; 3950 3951 if (!port_is_stopped(res->port_id)) { 3952 printf("Please stop port %d first\n", res->port_id); 3953 return; 3954 } 3955 3956 tx_vlan_set(res->port_id, res->vlan_id); 3957 3958 cmd_reconfig_device_queue(res->port_id, 1, 1); 3959 } 3960 3961 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan = 3962 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 3963 tx_vlan, "tx_vlan"); 3964 cmdline_parse_token_string_t cmd_tx_vlan_set_set = 3965 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 3966 set, "set"); 3967 cmdline_parse_token_num_t cmd_tx_vlan_set_portid = 3968 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 3969 port_id, UINT16); 3970 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid = 3971 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 3972 vlan_id, UINT16); 3973 3974 cmdline_parse_inst_t cmd_tx_vlan_set = { 3975 .f = cmd_tx_vlan_set_parsed, 3976 .data = NULL, 3977 .help_str = "tx_vlan set <port_id> <vlan_id>: " 3978 "Enable hardware insertion of a single VLAN header " 3979 "with a given TAG Identifier in packets sent on a port", 3980 .tokens = { 3981 (void *)&cmd_tx_vlan_set_tx_vlan, 3982 (void *)&cmd_tx_vlan_set_set, 3983 (void *)&cmd_tx_vlan_set_portid, 3984 (void *)&cmd_tx_vlan_set_vlanid, 3985 NULL, 3986 }, 3987 }; 3988 3989 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */ 3990 struct cmd_tx_vlan_set_qinq_result { 3991 cmdline_fixed_string_t tx_vlan; 3992 cmdline_fixed_string_t set; 3993 portid_t port_id; 3994 uint16_t vlan_id; 3995 uint16_t vlan_id_outer; 3996 }; 3997 3998 static void 3999 cmd_tx_vlan_set_qinq_parsed(void *parsed_result, 4000 __attribute__((unused)) struct cmdline *cl, 4001 __attribute__((unused)) void *data) 4002 { 4003 struct cmd_tx_vlan_set_qinq_result *res = parsed_result; 4004 4005 if (!port_is_stopped(res->port_id)) { 4006 printf("Please stop port %d first\n", res->port_id); 4007 return; 4008 } 4009 4010 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer); 4011 4012 cmd_reconfig_device_queue(res->port_id, 1, 1); 4013 } 4014 4015 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan = 4016 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4017 tx_vlan, "tx_vlan"); 4018 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set = 4019 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4020 set, "set"); 4021 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid = 4022 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4023 port_id, UINT16); 4024 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid = 4025 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4026 vlan_id, UINT16); 4027 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer = 4028 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4029 vlan_id_outer, UINT16); 4030 4031 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = { 4032 .f = cmd_tx_vlan_set_qinq_parsed, 4033 .data = NULL, 4034 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: " 4035 "Enable hardware insertion of double VLAN header " 4036 "with given TAG Identifiers in packets sent on a port", 4037 .tokens = { 4038 (void *)&cmd_tx_vlan_set_qinq_tx_vlan, 4039 (void *)&cmd_tx_vlan_set_qinq_set, 4040 (void *)&cmd_tx_vlan_set_qinq_portid, 4041 (void *)&cmd_tx_vlan_set_qinq_vlanid, 4042 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer, 4043 NULL, 4044 }, 4045 }; 4046 4047 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */ 4048 struct cmd_tx_vlan_set_pvid_result { 4049 cmdline_fixed_string_t tx_vlan; 4050 cmdline_fixed_string_t set; 4051 cmdline_fixed_string_t pvid; 4052 portid_t port_id; 4053 uint16_t vlan_id; 4054 cmdline_fixed_string_t mode; 4055 }; 4056 4057 static void 4058 cmd_tx_vlan_set_pvid_parsed(void *parsed_result, 4059 __attribute__((unused)) struct cmdline *cl, 4060 __attribute__((unused)) void *data) 4061 { 4062 struct cmd_tx_vlan_set_pvid_result *res = parsed_result; 4063 4064 if (strcmp(res->mode, "on") == 0) 4065 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1); 4066 else 4067 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0); 4068 } 4069 4070 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan = 4071 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4072 tx_vlan, "tx_vlan"); 4073 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set = 4074 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4075 set, "set"); 4076 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid = 4077 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4078 pvid, "pvid"); 4079 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id = 4080 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4081 port_id, UINT16); 4082 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id = 4083 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4084 vlan_id, UINT16); 4085 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode = 4086 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4087 mode, "on#off"); 4088 4089 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = { 4090 .f = cmd_tx_vlan_set_pvid_parsed, 4091 .data = NULL, 4092 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off", 4093 .tokens = { 4094 (void *)&cmd_tx_vlan_set_pvid_tx_vlan, 4095 (void *)&cmd_tx_vlan_set_pvid_set, 4096 (void *)&cmd_tx_vlan_set_pvid_pvid, 4097 (void *)&cmd_tx_vlan_set_pvid_port_id, 4098 (void *)&cmd_tx_vlan_set_pvid_vlan_id, 4099 (void *)&cmd_tx_vlan_set_pvid_mode, 4100 NULL, 4101 }, 4102 }; 4103 4104 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4105 struct cmd_tx_vlan_reset_result { 4106 cmdline_fixed_string_t tx_vlan; 4107 cmdline_fixed_string_t reset; 4108 portid_t port_id; 4109 }; 4110 4111 static void 4112 cmd_tx_vlan_reset_parsed(void *parsed_result, 4113 __attribute__((unused)) struct cmdline *cl, 4114 __attribute__((unused)) void *data) 4115 { 4116 struct cmd_tx_vlan_reset_result *res = parsed_result; 4117 4118 if (!port_is_stopped(res->port_id)) { 4119 printf("Please stop port %d first\n", res->port_id); 4120 return; 4121 } 4122 4123 tx_vlan_reset(res->port_id); 4124 4125 cmd_reconfig_device_queue(res->port_id, 1, 1); 4126 } 4127 4128 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan = 4129 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4130 tx_vlan, "tx_vlan"); 4131 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset = 4132 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4133 reset, "reset"); 4134 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid = 4135 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result, 4136 port_id, UINT16); 4137 4138 cmdline_parse_inst_t cmd_tx_vlan_reset = { 4139 .f = cmd_tx_vlan_reset_parsed, 4140 .data = NULL, 4141 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a " 4142 "VLAN header in packets sent on a port", 4143 .tokens = { 4144 (void *)&cmd_tx_vlan_reset_tx_vlan, 4145 (void *)&cmd_tx_vlan_reset_reset, 4146 (void *)&cmd_tx_vlan_reset_portid, 4147 NULL, 4148 }, 4149 }; 4150 4151 4152 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ 4153 struct cmd_csum_result { 4154 cmdline_fixed_string_t csum; 4155 cmdline_fixed_string_t mode; 4156 cmdline_fixed_string_t proto; 4157 cmdline_fixed_string_t hwsw; 4158 portid_t port_id; 4159 }; 4160 4161 static void 4162 csum_show(int port_id) 4163 { 4164 struct rte_eth_dev_info dev_info; 4165 uint64_t tx_offloads; 4166 4167 tx_offloads = ports[port_id].dev_conf.txmode.offloads; 4168 printf("Parse tunnel is %s\n", 4169 (ports[port_id].parse_tunnel) ? "on" : "off"); 4170 printf("IP checksum offload is %s\n", 4171 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw"); 4172 printf("UDP checksum offload is %s\n", 4173 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); 4174 printf("TCP checksum offload is %s\n", 4175 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); 4176 printf("SCTP checksum offload is %s\n", 4177 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); 4178 printf("Outer-Ip checksum offload is %s\n", 4179 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw"); 4180 4181 /* display warnings if configuration is not supported by the NIC */ 4182 rte_eth_dev_info_get(port_id, &dev_info); 4183 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) && 4184 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { 4185 printf("Warning: hardware IP checksum enabled but not " 4186 "supported by port %d\n", port_id); 4187 } 4188 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) && 4189 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { 4190 printf("Warning: hardware UDP checksum enabled but not " 4191 "supported by port %d\n", port_id); 4192 } 4193 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) && 4194 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { 4195 printf("Warning: hardware TCP checksum enabled but not " 4196 "supported by port %d\n", port_id); 4197 } 4198 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) && 4199 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { 4200 printf("Warning: hardware SCTP checksum enabled but not " 4201 "supported by port %d\n", port_id); 4202 } 4203 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) && 4204 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { 4205 printf("Warning: hardware outer IP checksum enabled but not " 4206 "supported by port %d\n", port_id); 4207 } 4208 } 4209 4210 static void 4211 cmd_csum_parsed(void *parsed_result, 4212 __attribute__((unused)) struct cmdline *cl, 4213 __attribute__((unused)) void *data) 4214 { 4215 struct cmd_csum_result *res = parsed_result; 4216 int hw = 0; 4217 uint64_t csum_offloads = 0; 4218 struct rte_eth_dev_info dev_info; 4219 4220 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) { 4221 printf("invalid port %d\n", res->port_id); 4222 return; 4223 } 4224 if (!port_is_stopped(res->port_id)) { 4225 printf("Please stop port %d first\n", res->port_id); 4226 return; 4227 } 4228 4229 rte_eth_dev_info_get(res->port_id, &dev_info); 4230 if (!strcmp(res->mode, "set")) { 4231 4232 if (!strcmp(res->hwsw, "hw")) 4233 hw = 1; 4234 4235 if (!strcmp(res->proto, "ip")) { 4236 if (hw == 0 || (dev_info.tx_offload_capa & 4237 DEV_TX_OFFLOAD_IPV4_CKSUM)) { 4238 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM; 4239 } else { 4240 printf("IP checksum offload is not supported " 4241 "by port %u\n", res->port_id); 4242 } 4243 } else if (!strcmp(res->proto, "udp")) { 4244 if (hw == 0 || (dev_info.tx_offload_capa & 4245 DEV_TX_OFFLOAD_UDP_CKSUM)) { 4246 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; 4247 } else { 4248 printf("UDP checksum offload is not supported " 4249 "by port %u\n", res->port_id); 4250 } 4251 } else if (!strcmp(res->proto, "tcp")) { 4252 if (hw == 0 || (dev_info.tx_offload_capa & 4253 DEV_TX_OFFLOAD_TCP_CKSUM)) { 4254 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; 4255 } else { 4256 printf("TCP checksum offload is not supported " 4257 "by port %u\n", res->port_id); 4258 } 4259 } else if (!strcmp(res->proto, "sctp")) { 4260 if (hw == 0 || (dev_info.tx_offload_capa & 4261 DEV_TX_OFFLOAD_SCTP_CKSUM)) { 4262 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; 4263 } else { 4264 printf("SCTP checksum offload is not supported " 4265 "by port %u\n", res->port_id); 4266 } 4267 } else if (!strcmp(res->proto, "outer-ip")) { 4268 if (hw == 0 || (dev_info.tx_offload_capa & 4269 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) { 4270 csum_offloads |= 4271 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; 4272 } else { 4273 printf("Outer IP checksum offload is not " 4274 "supported by port %u\n", res->port_id); 4275 } 4276 } 4277 4278 if (hw) { 4279 ports[res->port_id].dev_conf.txmode.offloads |= 4280 csum_offloads; 4281 } else { 4282 ports[res->port_id].dev_conf.txmode.offloads &= 4283 (~csum_offloads); 4284 } 4285 } 4286 csum_show(res->port_id); 4287 4288 cmd_reconfig_device_queue(res->port_id, 1, 1); 4289 } 4290 4291 cmdline_parse_token_string_t cmd_csum_csum = 4292 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4293 csum, "csum"); 4294 cmdline_parse_token_string_t cmd_csum_mode = 4295 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4296 mode, "set"); 4297 cmdline_parse_token_string_t cmd_csum_proto = 4298 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4299 proto, "ip#tcp#udp#sctp#outer-ip"); 4300 cmdline_parse_token_string_t cmd_csum_hwsw = 4301 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4302 hwsw, "hw#sw"); 4303 cmdline_parse_token_num_t cmd_csum_portid = 4304 TOKEN_NUM_INITIALIZER(struct cmd_csum_result, 4305 port_id, UINT16); 4306 4307 cmdline_parse_inst_t cmd_csum_set = { 4308 .f = cmd_csum_parsed, 4309 .data = NULL, 4310 .help_str = "csum set ip|tcp|udp|sctp|outer-ip hw|sw <port_id>: " 4311 "Enable/Disable hardware calculation of L3/L4 checksum when " 4312 "using csum forward engine", 4313 .tokens = { 4314 (void *)&cmd_csum_csum, 4315 (void *)&cmd_csum_mode, 4316 (void *)&cmd_csum_proto, 4317 (void *)&cmd_csum_hwsw, 4318 (void *)&cmd_csum_portid, 4319 NULL, 4320 }, 4321 }; 4322 4323 cmdline_parse_token_string_t cmd_csum_mode_show = 4324 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4325 mode, "show"); 4326 4327 cmdline_parse_inst_t cmd_csum_show = { 4328 .f = cmd_csum_parsed, 4329 .data = NULL, 4330 .help_str = "csum show <port_id>: Show checksum offload configuration", 4331 .tokens = { 4332 (void *)&cmd_csum_csum, 4333 (void *)&cmd_csum_mode_show, 4334 (void *)&cmd_csum_portid, 4335 NULL, 4336 }, 4337 }; 4338 4339 /* Enable/disable tunnel parsing */ 4340 struct cmd_csum_tunnel_result { 4341 cmdline_fixed_string_t csum; 4342 cmdline_fixed_string_t parse; 4343 cmdline_fixed_string_t onoff; 4344 portid_t port_id; 4345 }; 4346 4347 static void 4348 cmd_csum_tunnel_parsed(void *parsed_result, 4349 __attribute__((unused)) struct cmdline *cl, 4350 __attribute__((unused)) void *data) 4351 { 4352 struct cmd_csum_tunnel_result *res = parsed_result; 4353 4354 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4355 return; 4356 4357 if (!strcmp(res->onoff, "on")) 4358 ports[res->port_id].parse_tunnel = 1; 4359 else 4360 ports[res->port_id].parse_tunnel = 0; 4361 4362 csum_show(res->port_id); 4363 } 4364 4365 cmdline_parse_token_string_t cmd_csum_tunnel_csum = 4366 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4367 csum, "csum"); 4368 cmdline_parse_token_string_t cmd_csum_tunnel_parse = 4369 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4370 parse, "parse_tunnel"); 4371 cmdline_parse_token_string_t cmd_csum_tunnel_onoff = 4372 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4373 onoff, "on#off"); 4374 cmdline_parse_token_num_t cmd_csum_tunnel_portid = 4375 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, 4376 port_id, UINT16); 4377 4378 cmdline_parse_inst_t cmd_csum_tunnel = { 4379 .f = cmd_csum_tunnel_parsed, 4380 .data = NULL, 4381 .help_str = "csum parse_tunnel on|off <port_id>: " 4382 "Enable/Disable parsing of tunnels for csum engine", 4383 .tokens = { 4384 (void *)&cmd_csum_tunnel_csum, 4385 (void *)&cmd_csum_tunnel_parse, 4386 (void *)&cmd_csum_tunnel_onoff, 4387 (void *)&cmd_csum_tunnel_portid, 4388 NULL, 4389 }, 4390 }; 4391 4392 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */ 4393 struct cmd_tso_set_result { 4394 cmdline_fixed_string_t tso; 4395 cmdline_fixed_string_t mode; 4396 uint16_t tso_segsz; 4397 portid_t port_id; 4398 }; 4399 4400 static void 4401 cmd_tso_set_parsed(void *parsed_result, 4402 __attribute__((unused)) struct cmdline *cl, 4403 __attribute__((unused)) void *data) 4404 { 4405 struct cmd_tso_set_result *res = parsed_result; 4406 struct rte_eth_dev_info dev_info; 4407 4408 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4409 return; 4410 if (!port_is_stopped(res->port_id)) { 4411 printf("Please stop port %d first\n", res->port_id); 4412 return; 4413 } 4414 4415 if (!strcmp(res->mode, "set")) 4416 ports[res->port_id].tso_segsz = res->tso_segsz; 4417 4418 rte_eth_dev_info_get(res->port_id, &dev_info); 4419 if ((ports[res->port_id].tso_segsz != 0) && 4420 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4421 printf("Error: TSO is not supported by port %d\n", 4422 res->port_id); 4423 return; 4424 } 4425 4426 if (ports[res->port_id].tso_segsz == 0) { 4427 ports[res->port_id].dev_conf.txmode.offloads &= 4428 ~DEV_TX_OFFLOAD_TCP_TSO; 4429 printf("TSO for non-tunneled packets is disabled\n"); 4430 } else { 4431 ports[res->port_id].dev_conf.txmode.offloads |= 4432 DEV_TX_OFFLOAD_TCP_TSO; 4433 printf("TSO segment size for non-tunneled packets is %d\n", 4434 ports[res->port_id].tso_segsz); 4435 } 4436 4437 /* display warnings if configuration is not supported by the NIC */ 4438 rte_eth_dev_info_get(res->port_id, &dev_info); 4439 if ((ports[res->port_id].tso_segsz != 0) && 4440 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4441 printf("Warning: TSO enabled but not " 4442 "supported by port %d\n", res->port_id); 4443 } 4444 4445 cmd_reconfig_device_queue(res->port_id, 1, 1); 4446 } 4447 4448 cmdline_parse_token_string_t cmd_tso_set_tso = 4449 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4450 tso, "tso"); 4451 cmdline_parse_token_string_t cmd_tso_set_mode = 4452 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4453 mode, "set"); 4454 cmdline_parse_token_num_t cmd_tso_set_tso_segsz = 4455 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4456 tso_segsz, UINT16); 4457 cmdline_parse_token_num_t cmd_tso_set_portid = 4458 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4459 port_id, UINT16); 4460 4461 cmdline_parse_inst_t cmd_tso_set = { 4462 .f = cmd_tso_set_parsed, 4463 .data = NULL, 4464 .help_str = "tso set <tso_segsz> <port_id>: " 4465 "Set TSO segment size of non-tunneled packets for csum engine " 4466 "(0 to disable)", 4467 .tokens = { 4468 (void *)&cmd_tso_set_tso, 4469 (void *)&cmd_tso_set_mode, 4470 (void *)&cmd_tso_set_tso_segsz, 4471 (void *)&cmd_tso_set_portid, 4472 NULL, 4473 }, 4474 }; 4475 4476 cmdline_parse_token_string_t cmd_tso_show_mode = 4477 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4478 mode, "show"); 4479 4480 4481 cmdline_parse_inst_t cmd_tso_show = { 4482 .f = cmd_tso_set_parsed, 4483 .data = NULL, 4484 .help_str = "tso show <port_id>: " 4485 "Show TSO segment size of non-tunneled packets for csum engine", 4486 .tokens = { 4487 (void *)&cmd_tso_set_tso, 4488 (void *)&cmd_tso_show_mode, 4489 (void *)&cmd_tso_set_portid, 4490 NULL, 4491 }, 4492 }; 4493 4494 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */ 4495 struct cmd_tunnel_tso_set_result { 4496 cmdline_fixed_string_t tso; 4497 cmdline_fixed_string_t mode; 4498 uint16_t tso_segsz; 4499 portid_t port_id; 4500 }; 4501 4502 static struct rte_eth_dev_info 4503 check_tunnel_tso_nic_support(portid_t port_id) 4504 { 4505 struct rte_eth_dev_info dev_info; 4506 4507 rte_eth_dev_info_get(port_id, &dev_info); 4508 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) 4509 printf("Warning: VXLAN TUNNEL TSO not supported therefore " 4510 "not enabled for port %d\n", port_id); 4511 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO)) 4512 printf("Warning: GRE TUNNEL TSO not supported therefore " 4513 "not enabled for port %d\n", port_id); 4514 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO)) 4515 printf("Warning: IPIP TUNNEL TSO not supported therefore " 4516 "not enabled for port %d\n", port_id); 4517 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO)) 4518 printf("Warning: GENEVE TUNNEL TSO not supported therefore " 4519 "not enabled for port %d\n", port_id); 4520 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO)) 4521 printf("Warning: IP TUNNEL TSO not supported therefore " 4522 "not enabled for port %d\n", port_id); 4523 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO)) 4524 printf("Warning: UDP TUNNEL TSO not supported therefore " 4525 "not enabled for port %d\n", port_id); 4526 return dev_info; 4527 } 4528 4529 static void 4530 cmd_tunnel_tso_set_parsed(void *parsed_result, 4531 __attribute__((unused)) struct cmdline *cl, 4532 __attribute__((unused)) void *data) 4533 { 4534 struct cmd_tunnel_tso_set_result *res = parsed_result; 4535 struct rte_eth_dev_info dev_info; 4536 4537 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4538 return; 4539 if (!port_is_stopped(res->port_id)) { 4540 printf("Please stop port %d first\n", res->port_id); 4541 return; 4542 } 4543 4544 if (!strcmp(res->mode, "set")) 4545 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz; 4546 4547 dev_info = check_tunnel_tso_nic_support(res->port_id); 4548 if (ports[res->port_id].tunnel_tso_segsz == 0) { 4549 ports[res->port_id].dev_conf.txmode.offloads &= 4550 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4551 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4552 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4553 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4554 DEV_TX_OFFLOAD_IP_TNL_TSO | 4555 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4556 printf("TSO for tunneled packets is disabled\n"); 4557 } else { 4558 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4559 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4560 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4561 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4562 DEV_TX_OFFLOAD_IP_TNL_TSO | 4563 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4564 4565 ports[res->port_id].dev_conf.txmode.offloads |= 4566 (tso_offloads & dev_info.tx_offload_capa); 4567 printf("TSO segment size for tunneled packets is %d\n", 4568 ports[res->port_id].tunnel_tso_segsz); 4569 4570 /* Below conditions are needed to make it work: 4571 * (1) tunnel TSO is supported by the NIC; 4572 * (2) "csum parse_tunnel" must be set so that tunneled pkts 4573 * are recognized; 4574 * (3) for tunneled pkts with outer L3 of IPv4, 4575 * "csum set outer-ip" must be set to hw, because after tso, 4576 * total_len of outer IP header is changed, and the checksum 4577 * of outer IP header calculated by sw should be wrong; that 4578 * is not necessary for IPv6 tunneled pkts because there's no 4579 * checksum in IP header anymore. 4580 */ 4581 4582 if (!ports[res->port_id].parse_tunnel) 4583 printf("Warning: csum parse_tunnel must be set " 4584 "so that tunneled packets are recognized\n"); 4585 if (!(ports[res->port_id].dev_conf.txmode.offloads & 4586 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) 4587 printf("Warning: csum set outer-ip must be set to hw " 4588 "if outer L3 is IPv4; not necessary for IPv6\n"); 4589 } 4590 4591 cmd_reconfig_device_queue(res->port_id, 1, 1); 4592 } 4593 4594 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso = 4595 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4596 tso, "tunnel_tso"); 4597 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode = 4598 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4599 mode, "set"); 4600 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz = 4601 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4602 tso_segsz, UINT16); 4603 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid = 4604 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4605 port_id, UINT16); 4606 4607 cmdline_parse_inst_t cmd_tunnel_tso_set = { 4608 .f = cmd_tunnel_tso_set_parsed, 4609 .data = NULL, 4610 .help_str = "tunnel_tso set <tso_segsz> <port_id>: " 4611 "Set TSO segment size of tunneled packets for csum engine " 4612 "(0 to disable)", 4613 .tokens = { 4614 (void *)&cmd_tunnel_tso_set_tso, 4615 (void *)&cmd_tunnel_tso_set_mode, 4616 (void *)&cmd_tunnel_tso_set_tso_segsz, 4617 (void *)&cmd_tunnel_tso_set_portid, 4618 NULL, 4619 }, 4620 }; 4621 4622 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode = 4623 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4624 mode, "show"); 4625 4626 4627 cmdline_parse_inst_t cmd_tunnel_tso_show = { 4628 .f = cmd_tunnel_tso_set_parsed, 4629 .data = NULL, 4630 .help_str = "tunnel_tso show <port_id> " 4631 "Show TSO segment size of tunneled packets for csum engine", 4632 .tokens = { 4633 (void *)&cmd_tunnel_tso_set_tso, 4634 (void *)&cmd_tunnel_tso_show_mode, 4635 (void *)&cmd_tunnel_tso_set_portid, 4636 NULL, 4637 }, 4638 }; 4639 4640 /* *** SET GRO FOR A PORT *** */ 4641 struct cmd_gro_enable_result { 4642 cmdline_fixed_string_t cmd_set; 4643 cmdline_fixed_string_t cmd_port; 4644 cmdline_fixed_string_t cmd_keyword; 4645 cmdline_fixed_string_t cmd_onoff; 4646 portid_t cmd_pid; 4647 }; 4648 4649 static void 4650 cmd_gro_enable_parsed(void *parsed_result, 4651 __attribute__((unused)) struct cmdline *cl, 4652 __attribute__((unused)) void *data) 4653 { 4654 struct cmd_gro_enable_result *res; 4655 4656 res = parsed_result; 4657 if (!strcmp(res->cmd_keyword, "gro")) 4658 setup_gro(res->cmd_onoff, res->cmd_pid); 4659 } 4660 4661 cmdline_parse_token_string_t cmd_gro_enable_set = 4662 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4663 cmd_set, "set"); 4664 cmdline_parse_token_string_t cmd_gro_enable_port = 4665 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4666 cmd_keyword, "port"); 4667 cmdline_parse_token_num_t cmd_gro_enable_pid = 4668 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result, 4669 cmd_pid, UINT16); 4670 cmdline_parse_token_string_t cmd_gro_enable_keyword = 4671 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4672 cmd_keyword, "gro"); 4673 cmdline_parse_token_string_t cmd_gro_enable_onoff = 4674 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4675 cmd_onoff, "on#off"); 4676 4677 cmdline_parse_inst_t cmd_gro_enable = { 4678 .f = cmd_gro_enable_parsed, 4679 .data = NULL, 4680 .help_str = "set port <port_id> gro on|off", 4681 .tokens = { 4682 (void *)&cmd_gro_enable_set, 4683 (void *)&cmd_gro_enable_port, 4684 (void *)&cmd_gro_enable_pid, 4685 (void *)&cmd_gro_enable_keyword, 4686 (void *)&cmd_gro_enable_onoff, 4687 NULL, 4688 }, 4689 }; 4690 4691 /* *** DISPLAY GRO CONFIGURATION *** */ 4692 struct cmd_gro_show_result { 4693 cmdline_fixed_string_t cmd_show; 4694 cmdline_fixed_string_t cmd_port; 4695 cmdline_fixed_string_t cmd_keyword; 4696 portid_t cmd_pid; 4697 }; 4698 4699 static void 4700 cmd_gro_show_parsed(void *parsed_result, 4701 __attribute__((unused)) struct cmdline *cl, 4702 __attribute__((unused)) void *data) 4703 { 4704 struct cmd_gro_show_result *res; 4705 4706 res = parsed_result; 4707 if (!strcmp(res->cmd_keyword, "gro")) 4708 show_gro(res->cmd_pid); 4709 } 4710 4711 cmdline_parse_token_string_t cmd_gro_show_show = 4712 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4713 cmd_show, "show"); 4714 cmdline_parse_token_string_t cmd_gro_show_port = 4715 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4716 cmd_port, "port"); 4717 cmdline_parse_token_num_t cmd_gro_show_pid = 4718 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result, 4719 cmd_pid, UINT16); 4720 cmdline_parse_token_string_t cmd_gro_show_keyword = 4721 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4722 cmd_keyword, "gro"); 4723 4724 cmdline_parse_inst_t cmd_gro_show = { 4725 .f = cmd_gro_show_parsed, 4726 .data = NULL, 4727 .help_str = "show port <port_id> gro", 4728 .tokens = { 4729 (void *)&cmd_gro_show_show, 4730 (void *)&cmd_gro_show_port, 4731 (void *)&cmd_gro_show_pid, 4732 (void *)&cmd_gro_show_keyword, 4733 NULL, 4734 }, 4735 }; 4736 4737 /* *** SET FLUSH CYCLES FOR GRO *** */ 4738 struct cmd_gro_flush_result { 4739 cmdline_fixed_string_t cmd_set; 4740 cmdline_fixed_string_t cmd_keyword; 4741 cmdline_fixed_string_t cmd_flush; 4742 uint8_t cmd_cycles; 4743 }; 4744 4745 static void 4746 cmd_gro_flush_parsed(void *parsed_result, 4747 __attribute__((unused)) struct cmdline *cl, 4748 __attribute__((unused)) void *data) 4749 { 4750 struct cmd_gro_flush_result *res; 4751 4752 res = parsed_result; 4753 if ((!strcmp(res->cmd_keyword, "gro")) && 4754 (!strcmp(res->cmd_flush, "flush"))) 4755 setup_gro_flush_cycles(res->cmd_cycles); 4756 } 4757 4758 cmdline_parse_token_string_t cmd_gro_flush_set = 4759 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4760 cmd_set, "set"); 4761 cmdline_parse_token_string_t cmd_gro_flush_keyword = 4762 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4763 cmd_keyword, "gro"); 4764 cmdline_parse_token_string_t cmd_gro_flush_flush = 4765 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4766 cmd_flush, "flush"); 4767 cmdline_parse_token_num_t cmd_gro_flush_cycles = 4768 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result, 4769 cmd_cycles, UINT8); 4770 4771 cmdline_parse_inst_t cmd_gro_flush = { 4772 .f = cmd_gro_flush_parsed, 4773 .data = NULL, 4774 .help_str = "set gro flush <cycles>", 4775 .tokens = { 4776 (void *)&cmd_gro_flush_set, 4777 (void *)&cmd_gro_flush_keyword, 4778 (void *)&cmd_gro_flush_flush, 4779 (void *)&cmd_gro_flush_cycles, 4780 NULL, 4781 }, 4782 }; 4783 4784 /* *** ENABLE/DISABLE GSO *** */ 4785 struct cmd_gso_enable_result { 4786 cmdline_fixed_string_t cmd_set; 4787 cmdline_fixed_string_t cmd_port; 4788 cmdline_fixed_string_t cmd_keyword; 4789 cmdline_fixed_string_t cmd_mode; 4790 portid_t cmd_pid; 4791 }; 4792 4793 static void 4794 cmd_gso_enable_parsed(void *parsed_result, 4795 __attribute__((unused)) struct cmdline *cl, 4796 __attribute__((unused)) void *data) 4797 { 4798 struct cmd_gso_enable_result *res; 4799 4800 res = parsed_result; 4801 if (!strcmp(res->cmd_keyword, "gso")) 4802 setup_gso(res->cmd_mode, res->cmd_pid); 4803 } 4804 4805 cmdline_parse_token_string_t cmd_gso_enable_set = 4806 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4807 cmd_set, "set"); 4808 cmdline_parse_token_string_t cmd_gso_enable_port = 4809 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4810 cmd_port, "port"); 4811 cmdline_parse_token_string_t cmd_gso_enable_keyword = 4812 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4813 cmd_keyword, "gso"); 4814 cmdline_parse_token_string_t cmd_gso_enable_mode = 4815 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4816 cmd_mode, "on#off"); 4817 cmdline_parse_token_num_t cmd_gso_enable_pid = 4818 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result, 4819 cmd_pid, UINT16); 4820 4821 cmdline_parse_inst_t cmd_gso_enable = { 4822 .f = cmd_gso_enable_parsed, 4823 .data = NULL, 4824 .help_str = "set port <port_id> gso on|off", 4825 .tokens = { 4826 (void *)&cmd_gso_enable_set, 4827 (void *)&cmd_gso_enable_port, 4828 (void *)&cmd_gso_enable_pid, 4829 (void *)&cmd_gso_enable_keyword, 4830 (void *)&cmd_gso_enable_mode, 4831 NULL, 4832 }, 4833 }; 4834 4835 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */ 4836 struct cmd_gso_size_result { 4837 cmdline_fixed_string_t cmd_set; 4838 cmdline_fixed_string_t cmd_keyword; 4839 cmdline_fixed_string_t cmd_segsz; 4840 uint16_t cmd_size; 4841 }; 4842 4843 static void 4844 cmd_gso_size_parsed(void *parsed_result, 4845 __attribute__((unused)) struct cmdline *cl, 4846 __attribute__((unused)) void *data) 4847 { 4848 struct cmd_gso_size_result *res = parsed_result; 4849 4850 if (test_done == 0) { 4851 printf("Before setting GSO segsz, please first" 4852 " stop fowarding\n"); 4853 return; 4854 } 4855 4856 if (!strcmp(res->cmd_keyword, "gso") && 4857 !strcmp(res->cmd_segsz, "segsz")) { 4858 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN) 4859 printf("gso_size should be larger than %zu." 4860 " Please input a legal value\n", 4861 RTE_GSO_SEG_SIZE_MIN); 4862 else 4863 gso_max_segment_size = res->cmd_size; 4864 } 4865 } 4866 4867 cmdline_parse_token_string_t cmd_gso_size_set = 4868 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 4869 cmd_set, "set"); 4870 cmdline_parse_token_string_t cmd_gso_size_keyword = 4871 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 4872 cmd_keyword, "gso"); 4873 cmdline_parse_token_string_t cmd_gso_size_segsz = 4874 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 4875 cmd_segsz, "segsz"); 4876 cmdline_parse_token_num_t cmd_gso_size_size = 4877 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result, 4878 cmd_size, UINT16); 4879 4880 cmdline_parse_inst_t cmd_gso_size = { 4881 .f = cmd_gso_size_parsed, 4882 .data = NULL, 4883 .help_str = "set gso segsz <length>", 4884 .tokens = { 4885 (void *)&cmd_gso_size_set, 4886 (void *)&cmd_gso_size_keyword, 4887 (void *)&cmd_gso_size_segsz, 4888 (void *)&cmd_gso_size_size, 4889 NULL, 4890 }, 4891 }; 4892 4893 /* *** SHOW GSO CONFIGURATION *** */ 4894 struct cmd_gso_show_result { 4895 cmdline_fixed_string_t cmd_show; 4896 cmdline_fixed_string_t cmd_port; 4897 cmdline_fixed_string_t cmd_keyword; 4898 portid_t cmd_pid; 4899 }; 4900 4901 static void 4902 cmd_gso_show_parsed(void *parsed_result, 4903 __attribute__((unused)) struct cmdline *cl, 4904 __attribute__((unused)) void *data) 4905 { 4906 struct cmd_gso_show_result *res = parsed_result; 4907 4908 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 4909 printf("invalid port id %u\n", res->cmd_pid); 4910 return; 4911 } 4912 if (!strcmp(res->cmd_keyword, "gso")) { 4913 if (gso_ports[res->cmd_pid].enable) { 4914 printf("Max GSO'd packet size: %uB\n" 4915 "Supported GSO types: TCP/IPv4, " 4916 "UDP/IPv4, VxLAN with inner " 4917 "TCP/IPv4 packet, GRE with inner " 4918 "TCP/IPv4 packet\n", 4919 gso_max_segment_size); 4920 } else 4921 printf("GSO is not enabled on Port %u\n", res->cmd_pid); 4922 } 4923 } 4924 4925 cmdline_parse_token_string_t cmd_gso_show_show = 4926 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 4927 cmd_show, "show"); 4928 cmdline_parse_token_string_t cmd_gso_show_port = 4929 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 4930 cmd_port, "port"); 4931 cmdline_parse_token_string_t cmd_gso_show_keyword = 4932 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 4933 cmd_keyword, "gso"); 4934 cmdline_parse_token_num_t cmd_gso_show_pid = 4935 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result, 4936 cmd_pid, UINT16); 4937 4938 cmdline_parse_inst_t cmd_gso_show = { 4939 .f = cmd_gso_show_parsed, 4940 .data = NULL, 4941 .help_str = "show port <port_id> gso", 4942 .tokens = { 4943 (void *)&cmd_gso_show_show, 4944 (void *)&cmd_gso_show_port, 4945 (void *)&cmd_gso_show_pid, 4946 (void *)&cmd_gso_show_keyword, 4947 NULL, 4948 }, 4949 }; 4950 4951 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */ 4952 struct cmd_set_flush_rx { 4953 cmdline_fixed_string_t set; 4954 cmdline_fixed_string_t flush_rx; 4955 cmdline_fixed_string_t mode; 4956 }; 4957 4958 static void 4959 cmd_set_flush_rx_parsed(void *parsed_result, 4960 __attribute__((unused)) struct cmdline *cl, 4961 __attribute__((unused)) void *data) 4962 { 4963 struct cmd_set_flush_rx *res = parsed_result; 4964 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 4965 } 4966 4967 cmdline_parse_token_string_t cmd_setflushrx_set = 4968 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 4969 set, "set"); 4970 cmdline_parse_token_string_t cmd_setflushrx_flush_rx = 4971 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 4972 flush_rx, "flush_rx"); 4973 cmdline_parse_token_string_t cmd_setflushrx_mode = 4974 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 4975 mode, "on#off"); 4976 4977 4978 cmdline_parse_inst_t cmd_set_flush_rx = { 4979 .f = cmd_set_flush_rx_parsed, 4980 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams", 4981 .data = NULL, 4982 .tokens = { 4983 (void *)&cmd_setflushrx_set, 4984 (void *)&cmd_setflushrx_flush_rx, 4985 (void *)&cmd_setflushrx_mode, 4986 NULL, 4987 }, 4988 }; 4989 4990 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */ 4991 struct cmd_set_link_check { 4992 cmdline_fixed_string_t set; 4993 cmdline_fixed_string_t link_check; 4994 cmdline_fixed_string_t mode; 4995 }; 4996 4997 static void 4998 cmd_set_link_check_parsed(void *parsed_result, 4999 __attribute__((unused)) struct cmdline *cl, 5000 __attribute__((unused)) void *data) 5001 { 5002 struct cmd_set_link_check *res = parsed_result; 5003 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5004 } 5005 5006 cmdline_parse_token_string_t cmd_setlinkcheck_set = 5007 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5008 set, "set"); 5009 cmdline_parse_token_string_t cmd_setlinkcheck_link_check = 5010 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5011 link_check, "link_check"); 5012 cmdline_parse_token_string_t cmd_setlinkcheck_mode = 5013 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5014 mode, "on#off"); 5015 5016 5017 cmdline_parse_inst_t cmd_set_link_check = { 5018 .f = cmd_set_link_check_parsed, 5019 .help_str = "set link_check on|off: Enable/Disable link status check " 5020 "when starting/stopping a port", 5021 .data = NULL, 5022 .tokens = { 5023 (void *)&cmd_setlinkcheck_set, 5024 (void *)&cmd_setlinkcheck_link_check, 5025 (void *)&cmd_setlinkcheck_mode, 5026 NULL, 5027 }, 5028 }; 5029 5030 /* *** SET NIC BYPASS MODE *** */ 5031 struct cmd_set_bypass_mode_result { 5032 cmdline_fixed_string_t set; 5033 cmdline_fixed_string_t bypass; 5034 cmdline_fixed_string_t mode; 5035 cmdline_fixed_string_t value; 5036 portid_t port_id; 5037 }; 5038 5039 static void 5040 cmd_set_bypass_mode_parsed(void *parsed_result, 5041 __attribute__((unused)) struct cmdline *cl, 5042 __attribute__((unused)) void *data) 5043 { 5044 struct cmd_set_bypass_mode_result *res = parsed_result; 5045 portid_t port_id = res->port_id; 5046 int32_t rc = -EINVAL; 5047 5048 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5049 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5050 5051 if (!strcmp(res->value, "bypass")) 5052 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5053 else if (!strcmp(res->value, "isolate")) 5054 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5055 else 5056 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5057 5058 /* Set the bypass mode for the relevant port. */ 5059 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode); 5060 #endif 5061 if (rc != 0) 5062 printf("\t Failed to set bypass mode for port = %d.\n", port_id); 5063 } 5064 5065 cmdline_parse_token_string_t cmd_setbypass_mode_set = 5066 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5067 set, "set"); 5068 cmdline_parse_token_string_t cmd_setbypass_mode_bypass = 5069 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5070 bypass, "bypass"); 5071 cmdline_parse_token_string_t cmd_setbypass_mode_mode = 5072 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5073 mode, "mode"); 5074 cmdline_parse_token_string_t cmd_setbypass_mode_value = 5075 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5076 value, "normal#bypass#isolate"); 5077 cmdline_parse_token_num_t cmd_setbypass_mode_port = 5078 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result, 5079 port_id, UINT16); 5080 5081 cmdline_parse_inst_t cmd_set_bypass_mode = { 5082 .f = cmd_set_bypass_mode_parsed, 5083 .help_str = "set bypass mode normal|bypass|isolate <port_id>: " 5084 "Set the NIC bypass mode for port_id", 5085 .data = NULL, 5086 .tokens = { 5087 (void *)&cmd_setbypass_mode_set, 5088 (void *)&cmd_setbypass_mode_bypass, 5089 (void *)&cmd_setbypass_mode_mode, 5090 (void *)&cmd_setbypass_mode_value, 5091 (void *)&cmd_setbypass_mode_port, 5092 NULL, 5093 }, 5094 }; 5095 5096 /* *** SET NIC BYPASS EVENT *** */ 5097 struct cmd_set_bypass_event_result { 5098 cmdline_fixed_string_t set; 5099 cmdline_fixed_string_t bypass; 5100 cmdline_fixed_string_t event; 5101 cmdline_fixed_string_t event_value; 5102 cmdline_fixed_string_t mode; 5103 cmdline_fixed_string_t mode_value; 5104 portid_t port_id; 5105 }; 5106 5107 static void 5108 cmd_set_bypass_event_parsed(void *parsed_result, 5109 __attribute__((unused)) struct cmdline *cl, 5110 __attribute__((unused)) void *data) 5111 { 5112 int32_t rc = -EINVAL; 5113 struct cmd_set_bypass_event_result *res = parsed_result; 5114 portid_t port_id = res->port_id; 5115 5116 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5117 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5118 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5119 5120 if (!strcmp(res->event_value, "timeout")) 5121 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT; 5122 else if (!strcmp(res->event_value, "os_on")) 5123 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON; 5124 else if (!strcmp(res->event_value, "os_off")) 5125 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF; 5126 else if (!strcmp(res->event_value, "power_on")) 5127 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON; 5128 else if (!strcmp(res->event_value, "power_off")) 5129 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF; 5130 else 5131 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5132 5133 if (!strcmp(res->mode_value, "bypass")) 5134 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5135 else if (!strcmp(res->mode_value, "isolate")) 5136 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5137 else 5138 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5139 5140 /* Set the watchdog timeout. */ 5141 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) { 5142 5143 rc = -EINVAL; 5144 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) { 5145 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id, 5146 bypass_timeout); 5147 } 5148 if (rc != 0) { 5149 printf("Failed to set timeout value %u " 5150 "for port %d, errto code: %d.\n", 5151 bypass_timeout, port_id, rc); 5152 } 5153 } 5154 5155 /* Set the bypass event to transition to bypass mode. */ 5156 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event, 5157 bypass_mode); 5158 #endif 5159 5160 if (rc != 0) 5161 printf("\t Failed to set bypass event for port = %d.\n", 5162 port_id); 5163 } 5164 5165 cmdline_parse_token_string_t cmd_setbypass_event_set = 5166 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5167 set, "set"); 5168 cmdline_parse_token_string_t cmd_setbypass_event_bypass = 5169 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5170 bypass, "bypass"); 5171 cmdline_parse_token_string_t cmd_setbypass_event_event = 5172 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5173 event, "event"); 5174 cmdline_parse_token_string_t cmd_setbypass_event_event_value = 5175 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5176 event_value, "none#timeout#os_off#os_on#power_on#power_off"); 5177 cmdline_parse_token_string_t cmd_setbypass_event_mode = 5178 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5179 mode, "mode"); 5180 cmdline_parse_token_string_t cmd_setbypass_event_mode_value = 5181 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5182 mode_value, "normal#bypass#isolate"); 5183 cmdline_parse_token_num_t cmd_setbypass_event_port = 5184 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result, 5185 port_id, UINT16); 5186 5187 cmdline_parse_inst_t cmd_set_bypass_event = { 5188 .f = cmd_set_bypass_event_parsed, 5189 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|" 5190 "power_off mode normal|bypass|isolate <port_id>: " 5191 "Set the NIC bypass event mode for port_id", 5192 .data = NULL, 5193 .tokens = { 5194 (void *)&cmd_setbypass_event_set, 5195 (void *)&cmd_setbypass_event_bypass, 5196 (void *)&cmd_setbypass_event_event, 5197 (void *)&cmd_setbypass_event_event_value, 5198 (void *)&cmd_setbypass_event_mode, 5199 (void *)&cmd_setbypass_event_mode_value, 5200 (void *)&cmd_setbypass_event_port, 5201 NULL, 5202 }, 5203 }; 5204 5205 5206 /* *** SET NIC BYPASS TIMEOUT *** */ 5207 struct cmd_set_bypass_timeout_result { 5208 cmdline_fixed_string_t set; 5209 cmdline_fixed_string_t bypass; 5210 cmdline_fixed_string_t timeout; 5211 cmdline_fixed_string_t value; 5212 }; 5213 5214 static void 5215 cmd_set_bypass_timeout_parsed(void *parsed_result, 5216 __attribute__((unused)) struct cmdline *cl, 5217 __attribute__((unused)) void *data) 5218 { 5219 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result; 5220 5221 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5222 if (!strcmp(res->value, "1.5")) 5223 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC; 5224 else if (!strcmp(res->value, "2")) 5225 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC; 5226 else if (!strcmp(res->value, "3")) 5227 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC; 5228 else if (!strcmp(res->value, "4")) 5229 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC; 5230 else if (!strcmp(res->value, "8")) 5231 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC; 5232 else if (!strcmp(res->value, "16")) 5233 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC; 5234 else if (!strcmp(res->value, "32")) 5235 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC; 5236 else 5237 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5238 #endif 5239 } 5240 5241 cmdline_parse_token_string_t cmd_setbypass_timeout_set = 5242 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5243 set, "set"); 5244 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass = 5245 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5246 bypass, "bypass"); 5247 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout = 5248 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5249 timeout, "timeout"); 5250 cmdline_parse_token_string_t cmd_setbypass_timeout_value = 5251 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5252 value, "0#1.5#2#3#4#8#16#32"); 5253 5254 cmdline_parse_inst_t cmd_set_bypass_timeout = { 5255 .f = cmd_set_bypass_timeout_parsed, 5256 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: " 5257 "Set the NIC bypass watchdog timeout in seconds", 5258 .data = NULL, 5259 .tokens = { 5260 (void *)&cmd_setbypass_timeout_set, 5261 (void *)&cmd_setbypass_timeout_bypass, 5262 (void *)&cmd_setbypass_timeout_timeout, 5263 (void *)&cmd_setbypass_timeout_value, 5264 NULL, 5265 }, 5266 }; 5267 5268 /* *** SHOW NIC BYPASS MODE *** */ 5269 struct cmd_show_bypass_config_result { 5270 cmdline_fixed_string_t show; 5271 cmdline_fixed_string_t bypass; 5272 cmdline_fixed_string_t config; 5273 portid_t port_id; 5274 }; 5275 5276 static void 5277 cmd_show_bypass_config_parsed(void *parsed_result, 5278 __attribute__((unused)) struct cmdline *cl, 5279 __attribute__((unused)) void *data) 5280 { 5281 struct cmd_show_bypass_config_result *res = parsed_result; 5282 portid_t port_id = res->port_id; 5283 int rc = -EINVAL; 5284 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5285 uint32_t event_mode; 5286 uint32_t bypass_mode; 5287 uint32_t timeout = bypass_timeout; 5288 int i; 5289 5290 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] = 5291 {"off", "1.5", "2", "3", "4", "8", "16", "32"}; 5292 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] = 5293 {"UNKNOWN", "normal", "bypass", "isolate"}; 5294 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = { 5295 "NONE", 5296 "OS/board on", 5297 "power supply on", 5298 "OS/board off", 5299 "power supply off", 5300 "timeout"}; 5301 int num_events = (sizeof events) / (sizeof events[0]); 5302 5303 /* Display the bypass mode.*/ 5304 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) { 5305 printf("\tFailed to get bypass mode for port = %d\n", port_id); 5306 return; 5307 } 5308 else { 5309 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode)) 5310 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5311 5312 printf("\tbypass mode = %s\n", modes[bypass_mode]); 5313 } 5314 5315 /* Display the bypass timeout.*/ 5316 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout)) 5317 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5318 5319 printf("\tbypass timeout = %s\n", timeouts[timeout]); 5320 5321 /* Display the bypass events and associated modes. */ 5322 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) { 5323 5324 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) { 5325 printf("\tFailed to get bypass mode for event = %s\n", 5326 events[i]); 5327 } else { 5328 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode)) 5329 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5330 5331 printf("\tbypass event: %-16s = %s\n", events[i], 5332 modes[event_mode]); 5333 } 5334 } 5335 #endif 5336 if (rc != 0) 5337 printf("\tFailed to get bypass configuration for port = %d\n", 5338 port_id); 5339 } 5340 5341 cmdline_parse_token_string_t cmd_showbypass_config_show = 5342 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5343 show, "show"); 5344 cmdline_parse_token_string_t cmd_showbypass_config_bypass = 5345 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5346 bypass, "bypass"); 5347 cmdline_parse_token_string_t cmd_showbypass_config_config = 5348 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5349 config, "config"); 5350 cmdline_parse_token_num_t cmd_showbypass_config_port = 5351 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result, 5352 port_id, UINT16); 5353 5354 cmdline_parse_inst_t cmd_show_bypass_config = { 5355 .f = cmd_show_bypass_config_parsed, 5356 .help_str = "show bypass config <port_id>: " 5357 "Show the NIC bypass config for port_id", 5358 .data = NULL, 5359 .tokens = { 5360 (void *)&cmd_showbypass_config_show, 5361 (void *)&cmd_showbypass_config_bypass, 5362 (void *)&cmd_showbypass_config_config, 5363 (void *)&cmd_showbypass_config_port, 5364 NULL, 5365 }, 5366 }; 5367 5368 #ifdef RTE_LIBRTE_PMD_BOND 5369 /* *** SET BONDING MODE *** */ 5370 struct cmd_set_bonding_mode_result { 5371 cmdline_fixed_string_t set; 5372 cmdline_fixed_string_t bonding; 5373 cmdline_fixed_string_t mode; 5374 uint8_t value; 5375 portid_t port_id; 5376 }; 5377 5378 static void cmd_set_bonding_mode_parsed(void *parsed_result, 5379 __attribute__((unused)) struct cmdline *cl, 5380 __attribute__((unused)) void *data) 5381 { 5382 struct cmd_set_bonding_mode_result *res = parsed_result; 5383 portid_t port_id = res->port_id; 5384 5385 /* Set the bonding mode for the relevant port. */ 5386 if (0 != rte_eth_bond_mode_set(port_id, res->value)) 5387 printf("\t Failed to set bonding mode for port = %d.\n", port_id); 5388 } 5389 5390 cmdline_parse_token_string_t cmd_setbonding_mode_set = 5391 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5392 set, "set"); 5393 cmdline_parse_token_string_t cmd_setbonding_mode_bonding = 5394 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5395 bonding, "bonding"); 5396 cmdline_parse_token_string_t cmd_setbonding_mode_mode = 5397 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5398 mode, "mode"); 5399 cmdline_parse_token_num_t cmd_setbonding_mode_value = 5400 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5401 value, UINT8); 5402 cmdline_parse_token_num_t cmd_setbonding_mode_port = 5403 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5404 port_id, UINT16); 5405 5406 cmdline_parse_inst_t cmd_set_bonding_mode = { 5407 .f = cmd_set_bonding_mode_parsed, 5408 .help_str = "set bonding mode <mode_value> <port_id>: " 5409 "Set the bonding mode for port_id", 5410 .data = NULL, 5411 .tokens = { 5412 (void *) &cmd_setbonding_mode_set, 5413 (void *) &cmd_setbonding_mode_bonding, 5414 (void *) &cmd_setbonding_mode_mode, 5415 (void *) &cmd_setbonding_mode_value, 5416 (void *) &cmd_setbonding_mode_port, 5417 NULL 5418 } 5419 }; 5420 5421 /* *** SET BONDING SLOW_QUEUE SW/HW *** */ 5422 struct cmd_set_bonding_lacp_dedicated_queues_result { 5423 cmdline_fixed_string_t set; 5424 cmdline_fixed_string_t bonding; 5425 cmdline_fixed_string_t lacp; 5426 cmdline_fixed_string_t dedicated_queues; 5427 portid_t port_id; 5428 cmdline_fixed_string_t mode; 5429 }; 5430 5431 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result, 5432 __attribute__((unused)) struct cmdline *cl, 5433 __attribute__((unused)) void *data) 5434 { 5435 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result; 5436 portid_t port_id = res->port_id; 5437 struct rte_port *port; 5438 5439 port = &ports[port_id]; 5440 5441 /** Check if the port is not started **/ 5442 if (port->port_status != RTE_PORT_STOPPED) { 5443 printf("Please stop port %d first\n", port_id); 5444 return; 5445 } 5446 5447 if (!strcmp(res->mode, "enable")) { 5448 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0) 5449 printf("Dedicate queues for LACP control packets" 5450 " enabled\n"); 5451 else 5452 printf("Enabling dedicate queues for LACP control " 5453 "packets on port %d failed\n", port_id); 5454 } else if (!strcmp(res->mode, "disable")) { 5455 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0) 5456 printf("Dedicated queues for LACP control packets " 5457 "disabled\n"); 5458 else 5459 printf("Disabling dedicated queues for LACP control " 5460 "traffic on port %d failed\n", port_id); 5461 } 5462 } 5463 5464 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set = 5465 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5466 set, "set"); 5467 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding = 5468 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5469 bonding, "bonding"); 5470 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp = 5471 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5472 lacp, "lacp"); 5473 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues = 5474 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5475 dedicated_queues, "dedicated_queues"); 5476 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id = 5477 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5478 port_id, UINT16); 5479 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode = 5480 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5481 mode, "enable#disable"); 5482 5483 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = { 5484 .f = cmd_set_bonding_lacp_dedicated_queues_parsed, 5485 .help_str = "set bonding lacp dedicated_queues <port_id> " 5486 "enable|disable: " 5487 "Enable/disable dedicated queues for LACP control traffic for port_id", 5488 .data = NULL, 5489 .tokens = { 5490 (void *)&cmd_setbonding_lacp_dedicated_queues_set, 5491 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding, 5492 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp, 5493 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues, 5494 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id, 5495 (void *)&cmd_setbonding_lacp_dedicated_queues_mode, 5496 NULL 5497 } 5498 }; 5499 5500 /* *** SET BALANCE XMIT POLICY *** */ 5501 struct cmd_set_bonding_balance_xmit_policy_result { 5502 cmdline_fixed_string_t set; 5503 cmdline_fixed_string_t bonding; 5504 cmdline_fixed_string_t balance_xmit_policy; 5505 portid_t port_id; 5506 cmdline_fixed_string_t policy; 5507 }; 5508 5509 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result, 5510 __attribute__((unused)) struct cmdline *cl, 5511 __attribute__((unused)) void *data) 5512 { 5513 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; 5514 portid_t port_id = res->port_id; 5515 uint8_t policy; 5516 5517 if (!strcmp(res->policy, "l2")) { 5518 policy = BALANCE_XMIT_POLICY_LAYER2; 5519 } else if (!strcmp(res->policy, "l23")) { 5520 policy = BALANCE_XMIT_POLICY_LAYER23; 5521 } else if (!strcmp(res->policy, "l34")) { 5522 policy = BALANCE_XMIT_POLICY_LAYER34; 5523 } else { 5524 printf("\t Invalid xmit policy selection"); 5525 return; 5526 } 5527 5528 /* Set the bonding mode for the relevant port. */ 5529 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) { 5530 printf("\t Failed to set bonding balance xmit policy for port = %d.\n", 5531 port_id); 5532 } 5533 } 5534 5535 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = 5536 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5537 set, "set"); 5538 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = 5539 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5540 bonding, "bonding"); 5541 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = 5542 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5543 balance_xmit_policy, "balance_xmit_policy"); 5544 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = 5545 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5546 port_id, UINT16); 5547 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = 5548 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5549 policy, "l2#l23#l34"); 5550 5551 cmdline_parse_inst_t cmd_set_balance_xmit_policy = { 5552 .f = cmd_set_bonding_balance_xmit_policy_parsed, 5553 .help_str = "set bonding balance_xmit_policy <port_id> " 5554 "l2|l23|l34: " 5555 "Set the bonding balance_xmit_policy for port_id", 5556 .data = NULL, 5557 .tokens = { 5558 (void *)&cmd_setbonding_balance_xmit_policy_set, 5559 (void *)&cmd_setbonding_balance_xmit_policy_bonding, 5560 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, 5561 (void *)&cmd_setbonding_balance_xmit_policy_port, 5562 (void *)&cmd_setbonding_balance_xmit_policy_policy, 5563 NULL 5564 } 5565 }; 5566 5567 /* *** SHOW NIC BONDING CONFIGURATION *** */ 5568 struct cmd_show_bonding_config_result { 5569 cmdline_fixed_string_t show; 5570 cmdline_fixed_string_t bonding; 5571 cmdline_fixed_string_t config; 5572 portid_t port_id; 5573 }; 5574 5575 static void cmd_show_bonding_config_parsed(void *parsed_result, 5576 __attribute__((unused)) struct cmdline *cl, 5577 __attribute__((unused)) void *data) 5578 { 5579 struct cmd_show_bonding_config_result *res = parsed_result; 5580 int bonding_mode, agg_mode; 5581 portid_t slaves[RTE_MAX_ETHPORTS]; 5582 int num_slaves, num_active_slaves; 5583 int primary_id; 5584 int i; 5585 portid_t port_id = res->port_id; 5586 5587 /* Display the bonding mode.*/ 5588 bonding_mode = rte_eth_bond_mode_get(port_id); 5589 if (bonding_mode < 0) { 5590 printf("\tFailed to get bonding mode for port = %d\n", port_id); 5591 return; 5592 } else 5593 printf("\tBonding mode: %d\n", bonding_mode); 5594 5595 if (bonding_mode == BONDING_MODE_BALANCE) { 5596 int balance_xmit_policy; 5597 5598 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id); 5599 if (balance_xmit_policy < 0) { 5600 printf("\tFailed to get balance xmit policy for port = %d\n", 5601 port_id); 5602 return; 5603 } else { 5604 printf("\tBalance Xmit Policy: "); 5605 5606 switch (balance_xmit_policy) { 5607 case BALANCE_XMIT_POLICY_LAYER2: 5608 printf("BALANCE_XMIT_POLICY_LAYER2"); 5609 break; 5610 case BALANCE_XMIT_POLICY_LAYER23: 5611 printf("BALANCE_XMIT_POLICY_LAYER23"); 5612 break; 5613 case BALANCE_XMIT_POLICY_LAYER34: 5614 printf("BALANCE_XMIT_POLICY_LAYER34"); 5615 break; 5616 } 5617 printf("\n"); 5618 } 5619 } 5620 5621 if (bonding_mode == BONDING_MODE_8023AD) { 5622 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id); 5623 printf("\tIEEE802.3AD Aggregator Mode: "); 5624 switch (agg_mode) { 5625 case AGG_BANDWIDTH: 5626 printf("bandwidth"); 5627 break; 5628 case AGG_STABLE: 5629 printf("stable"); 5630 break; 5631 case AGG_COUNT: 5632 printf("count"); 5633 break; 5634 } 5635 printf("\n"); 5636 } 5637 5638 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS); 5639 5640 if (num_slaves < 0) { 5641 printf("\tFailed to get slave list for port = %d\n", port_id); 5642 return; 5643 } 5644 if (num_slaves > 0) { 5645 printf("\tSlaves (%d): [", num_slaves); 5646 for (i = 0; i < num_slaves - 1; i++) 5647 printf("%d ", slaves[i]); 5648 5649 printf("%d]\n", slaves[num_slaves - 1]); 5650 } else { 5651 printf("\tSlaves: []\n"); 5652 5653 } 5654 5655 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, 5656 RTE_MAX_ETHPORTS); 5657 5658 if (num_active_slaves < 0) { 5659 printf("\tFailed to get active slave list for port = %d\n", port_id); 5660 return; 5661 } 5662 if (num_active_slaves > 0) { 5663 printf("\tActive Slaves (%d): [", num_active_slaves); 5664 for (i = 0; i < num_active_slaves - 1; i++) 5665 printf("%d ", slaves[i]); 5666 5667 printf("%d]\n", slaves[num_active_slaves - 1]); 5668 5669 } else { 5670 printf("\tActive Slaves: []\n"); 5671 5672 } 5673 5674 primary_id = rte_eth_bond_primary_get(port_id); 5675 if (primary_id < 0) { 5676 printf("\tFailed to get primary slave for port = %d\n", port_id); 5677 return; 5678 } else 5679 printf("\tPrimary: [%d]\n", primary_id); 5680 5681 } 5682 5683 cmdline_parse_token_string_t cmd_showbonding_config_show = 5684 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5685 show, "show"); 5686 cmdline_parse_token_string_t cmd_showbonding_config_bonding = 5687 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5688 bonding, "bonding"); 5689 cmdline_parse_token_string_t cmd_showbonding_config_config = 5690 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5691 config, "config"); 5692 cmdline_parse_token_num_t cmd_showbonding_config_port = 5693 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, 5694 port_id, UINT16); 5695 5696 cmdline_parse_inst_t cmd_show_bonding_config = { 5697 .f = cmd_show_bonding_config_parsed, 5698 .help_str = "show bonding config <port_id>: " 5699 "Show the bonding config for port_id", 5700 .data = NULL, 5701 .tokens = { 5702 (void *)&cmd_showbonding_config_show, 5703 (void *)&cmd_showbonding_config_bonding, 5704 (void *)&cmd_showbonding_config_config, 5705 (void *)&cmd_showbonding_config_port, 5706 NULL 5707 } 5708 }; 5709 5710 /* *** SET BONDING PRIMARY *** */ 5711 struct cmd_set_bonding_primary_result { 5712 cmdline_fixed_string_t set; 5713 cmdline_fixed_string_t bonding; 5714 cmdline_fixed_string_t primary; 5715 portid_t slave_id; 5716 portid_t port_id; 5717 }; 5718 5719 static void cmd_set_bonding_primary_parsed(void *parsed_result, 5720 __attribute__((unused)) struct cmdline *cl, 5721 __attribute__((unused)) void *data) 5722 { 5723 struct cmd_set_bonding_primary_result *res = parsed_result; 5724 portid_t master_port_id = res->port_id; 5725 portid_t slave_port_id = res->slave_id; 5726 5727 /* Set the primary slave for a bonded device. */ 5728 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) { 5729 printf("\t Failed to set primary slave for port = %d.\n", 5730 master_port_id); 5731 return; 5732 } 5733 init_port_config(); 5734 } 5735 5736 cmdline_parse_token_string_t cmd_setbonding_primary_set = 5737 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5738 set, "set"); 5739 cmdline_parse_token_string_t cmd_setbonding_primary_bonding = 5740 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5741 bonding, "bonding"); 5742 cmdline_parse_token_string_t cmd_setbonding_primary_primary = 5743 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5744 primary, "primary"); 5745 cmdline_parse_token_num_t cmd_setbonding_primary_slave = 5746 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 5747 slave_id, UINT16); 5748 cmdline_parse_token_num_t cmd_setbonding_primary_port = 5749 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 5750 port_id, UINT16); 5751 5752 cmdline_parse_inst_t cmd_set_bonding_primary = { 5753 .f = cmd_set_bonding_primary_parsed, 5754 .help_str = "set bonding primary <slave_id> <port_id>: " 5755 "Set the primary slave for port_id", 5756 .data = NULL, 5757 .tokens = { 5758 (void *)&cmd_setbonding_primary_set, 5759 (void *)&cmd_setbonding_primary_bonding, 5760 (void *)&cmd_setbonding_primary_primary, 5761 (void *)&cmd_setbonding_primary_slave, 5762 (void *)&cmd_setbonding_primary_port, 5763 NULL 5764 } 5765 }; 5766 5767 /* *** ADD SLAVE *** */ 5768 struct cmd_add_bonding_slave_result { 5769 cmdline_fixed_string_t add; 5770 cmdline_fixed_string_t bonding; 5771 cmdline_fixed_string_t slave; 5772 portid_t slave_id; 5773 portid_t port_id; 5774 }; 5775 5776 static void cmd_add_bonding_slave_parsed(void *parsed_result, 5777 __attribute__((unused)) struct cmdline *cl, 5778 __attribute__((unused)) void *data) 5779 { 5780 struct cmd_add_bonding_slave_result *res = parsed_result; 5781 portid_t master_port_id = res->port_id; 5782 portid_t slave_port_id = res->slave_id; 5783 5784 /* add the slave for a bonded device. */ 5785 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) { 5786 printf("\t Failed to add slave %d to master port = %d.\n", 5787 slave_port_id, master_port_id); 5788 return; 5789 } 5790 init_port_config(); 5791 set_port_slave_flag(slave_port_id); 5792 } 5793 5794 cmdline_parse_token_string_t cmd_addbonding_slave_add = 5795 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5796 add, "add"); 5797 cmdline_parse_token_string_t cmd_addbonding_slave_bonding = 5798 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5799 bonding, "bonding"); 5800 cmdline_parse_token_string_t cmd_addbonding_slave_slave = 5801 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5802 slave, "slave"); 5803 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = 5804 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 5805 slave_id, UINT16); 5806 cmdline_parse_token_num_t cmd_addbonding_slave_port = 5807 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 5808 port_id, UINT16); 5809 5810 cmdline_parse_inst_t cmd_add_bonding_slave = { 5811 .f = cmd_add_bonding_slave_parsed, 5812 .help_str = "add bonding slave <slave_id> <port_id>: " 5813 "Add a slave device to a bonded device", 5814 .data = NULL, 5815 .tokens = { 5816 (void *)&cmd_addbonding_slave_add, 5817 (void *)&cmd_addbonding_slave_bonding, 5818 (void *)&cmd_addbonding_slave_slave, 5819 (void *)&cmd_addbonding_slave_slaveid, 5820 (void *)&cmd_addbonding_slave_port, 5821 NULL 5822 } 5823 }; 5824 5825 /* *** REMOVE SLAVE *** */ 5826 struct cmd_remove_bonding_slave_result { 5827 cmdline_fixed_string_t remove; 5828 cmdline_fixed_string_t bonding; 5829 cmdline_fixed_string_t slave; 5830 portid_t slave_id; 5831 portid_t port_id; 5832 }; 5833 5834 static void cmd_remove_bonding_slave_parsed(void *parsed_result, 5835 __attribute__((unused)) struct cmdline *cl, 5836 __attribute__((unused)) void *data) 5837 { 5838 struct cmd_remove_bonding_slave_result *res = parsed_result; 5839 portid_t master_port_id = res->port_id; 5840 portid_t slave_port_id = res->slave_id; 5841 5842 /* remove the slave from a bonded device. */ 5843 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) { 5844 printf("\t Failed to remove slave %d from master port = %d.\n", 5845 slave_port_id, master_port_id); 5846 return; 5847 } 5848 init_port_config(); 5849 clear_port_slave_flag(slave_port_id); 5850 } 5851 5852 cmdline_parse_token_string_t cmd_removebonding_slave_remove = 5853 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 5854 remove, "remove"); 5855 cmdline_parse_token_string_t cmd_removebonding_slave_bonding = 5856 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 5857 bonding, "bonding"); 5858 cmdline_parse_token_string_t cmd_removebonding_slave_slave = 5859 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 5860 slave, "slave"); 5861 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = 5862 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 5863 slave_id, UINT16); 5864 cmdline_parse_token_num_t cmd_removebonding_slave_port = 5865 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 5866 port_id, UINT16); 5867 5868 cmdline_parse_inst_t cmd_remove_bonding_slave = { 5869 .f = cmd_remove_bonding_slave_parsed, 5870 .help_str = "remove bonding slave <slave_id> <port_id>: " 5871 "Remove a slave device from a bonded device", 5872 .data = NULL, 5873 .tokens = { 5874 (void *)&cmd_removebonding_slave_remove, 5875 (void *)&cmd_removebonding_slave_bonding, 5876 (void *)&cmd_removebonding_slave_slave, 5877 (void *)&cmd_removebonding_slave_slaveid, 5878 (void *)&cmd_removebonding_slave_port, 5879 NULL 5880 } 5881 }; 5882 5883 /* *** CREATE BONDED DEVICE *** */ 5884 struct cmd_create_bonded_device_result { 5885 cmdline_fixed_string_t create; 5886 cmdline_fixed_string_t bonded; 5887 cmdline_fixed_string_t device; 5888 uint8_t mode; 5889 uint8_t socket; 5890 }; 5891 5892 static int bond_dev_num = 0; 5893 5894 static void cmd_create_bonded_device_parsed(void *parsed_result, 5895 __attribute__((unused)) struct cmdline *cl, 5896 __attribute__((unused)) void *data) 5897 { 5898 struct cmd_create_bonded_device_result *res = parsed_result; 5899 char ethdev_name[RTE_ETH_NAME_MAX_LEN]; 5900 int port_id; 5901 5902 if (test_done == 0) { 5903 printf("Please stop forwarding first\n"); 5904 return; 5905 } 5906 5907 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d", 5908 bond_dev_num++); 5909 5910 /* Create a new bonded device. */ 5911 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket); 5912 if (port_id < 0) { 5913 printf("\t Failed to create bonded device.\n"); 5914 return; 5915 } else { 5916 printf("Created new bonded device %s on (port %d).\n", ethdev_name, 5917 port_id); 5918 5919 /* Update number of ports */ 5920 nb_ports = rte_eth_dev_count_avail(); 5921 reconfig(port_id, res->socket); 5922 rte_eth_promiscuous_enable(port_id); 5923 } 5924 5925 } 5926 5927 cmdline_parse_token_string_t cmd_createbonded_device_create = 5928 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 5929 create, "create"); 5930 cmdline_parse_token_string_t cmd_createbonded_device_bonded = 5931 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 5932 bonded, "bonded"); 5933 cmdline_parse_token_string_t cmd_createbonded_device_device = 5934 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 5935 device, "device"); 5936 cmdline_parse_token_num_t cmd_createbonded_device_mode = 5937 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 5938 mode, UINT8); 5939 cmdline_parse_token_num_t cmd_createbonded_device_socket = 5940 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 5941 socket, UINT8); 5942 5943 cmdline_parse_inst_t cmd_create_bonded_device = { 5944 .f = cmd_create_bonded_device_parsed, 5945 .help_str = "create bonded device <mode> <socket>: " 5946 "Create a new bonded device with specific bonding mode and socket", 5947 .data = NULL, 5948 .tokens = { 5949 (void *)&cmd_createbonded_device_create, 5950 (void *)&cmd_createbonded_device_bonded, 5951 (void *)&cmd_createbonded_device_device, 5952 (void *)&cmd_createbonded_device_mode, 5953 (void *)&cmd_createbonded_device_socket, 5954 NULL 5955 } 5956 }; 5957 5958 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */ 5959 struct cmd_set_bond_mac_addr_result { 5960 cmdline_fixed_string_t set; 5961 cmdline_fixed_string_t bonding; 5962 cmdline_fixed_string_t mac_addr; 5963 uint16_t port_num; 5964 struct ether_addr address; 5965 }; 5966 5967 static void cmd_set_bond_mac_addr_parsed(void *parsed_result, 5968 __attribute__((unused)) struct cmdline *cl, 5969 __attribute__((unused)) void *data) 5970 { 5971 struct cmd_set_bond_mac_addr_result *res = parsed_result; 5972 int ret; 5973 5974 if (port_id_is_invalid(res->port_num, ENABLED_WARN)) 5975 return; 5976 5977 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address); 5978 5979 /* check the return value and print it if is < 0 */ 5980 if (ret < 0) 5981 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 5982 } 5983 5984 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set = 5985 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); 5986 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = 5987 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, 5988 "bonding"); 5989 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = 5990 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, 5991 "mac_addr"); 5992 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = 5993 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, 5994 port_num, UINT16); 5995 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = 5996 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); 5997 5998 cmdline_parse_inst_t cmd_set_bond_mac_addr = { 5999 .f = cmd_set_bond_mac_addr_parsed, 6000 .data = (void *) 0, 6001 .help_str = "set bonding mac_addr <port_id> <mac_addr>", 6002 .tokens = { 6003 (void *)&cmd_set_bond_mac_addr_set, 6004 (void *)&cmd_set_bond_mac_addr_bonding, 6005 (void *)&cmd_set_bond_mac_addr_mac, 6006 (void *)&cmd_set_bond_mac_addr_portnum, 6007 (void *)&cmd_set_bond_mac_addr_addr, 6008 NULL 6009 } 6010 }; 6011 6012 6013 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */ 6014 struct cmd_set_bond_mon_period_result { 6015 cmdline_fixed_string_t set; 6016 cmdline_fixed_string_t bonding; 6017 cmdline_fixed_string_t mon_period; 6018 uint16_t port_num; 6019 uint32_t period_ms; 6020 }; 6021 6022 static void cmd_set_bond_mon_period_parsed(void *parsed_result, 6023 __attribute__((unused)) struct cmdline *cl, 6024 __attribute__((unused)) void *data) 6025 { 6026 struct cmd_set_bond_mon_period_result *res = parsed_result; 6027 int ret; 6028 6029 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms); 6030 6031 /* check the return value and print it if is < 0 */ 6032 if (ret < 0) 6033 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6034 } 6035 6036 cmdline_parse_token_string_t cmd_set_bond_mon_period_set = 6037 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6038 set, "set"); 6039 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding = 6040 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6041 bonding, "bonding"); 6042 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period = 6043 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6044 mon_period, "mon_period"); 6045 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum = 6046 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6047 port_num, UINT16); 6048 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms = 6049 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6050 period_ms, UINT32); 6051 6052 cmdline_parse_inst_t cmd_set_bond_mon_period = { 6053 .f = cmd_set_bond_mon_period_parsed, 6054 .data = (void *) 0, 6055 .help_str = "set bonding mon_period <port_id> <period_ms>", 6056 .tokens = { 6057 (void *)&cmd_set_bond_mon_period_set, 6058 (void *)&cmd_set_bond_mon_period_bonding, 6059 (void *)&cmd_set_bond_mon_period_mon_period, 6060 (void *)&cmd_set_bond_mon_period_portnum, 6061 (void *)&cmd_set_bond_mon_period_period_ms, 6062 NULL 6063 } 6064 }; 6065 6066 6067 6068 struct cmd_set_bonding_agg_mode_policy_result { 6069 cmdline_fixed_string_t set; 6070 cmdline_fixed_string_t bonding; 6071 cmdline_fixed_string_t agg_mode; 6072 uint16_t port_num; 6073 cmdline_fixed_string_t policy; 6074 }; 6075 6076 6077 static void 6078 cmd_set_bonding_agg_mode(void *parsed_result, 6079 __attribute__((unused)) struct cmdline *cl, 6080 __attribute__((unused)) void *data) 6081 { 6082 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result; 6083 uint8_t policy = AGG_BANDWIDTH; 6084 6085 if (!strcmp(res->policy, "bandwidth")) 6086 policy = AGG_BANDWIDTH; 6087 else if (!strcmp(res->policy, "stable")) 6088 policy = AGG_STABLE; 6089 else if (!strcmp(res->policy, "count")) 6090 policy = AGG_COUNT; 6091 6092 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy); 6093 } 6094 6095 6096 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set = 6097 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6098 set, "set"); 6099 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding = 6100 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6101 bonding, "bonding"); 6102 6103 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode = 6104 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6105 agg_mode, "agg_mode"); 6106 6107 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum = 6108 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6109 port_num, UINT16); 6110 6111 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string = 6112 TOKEN_STRING_INITIALIZER( 6113 struct cmd_set_bonding_balance_xmit_policy_result, 6114 policy, "stable#bandwidth#count"); 6115 6116 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = { 6117 .f = cmd_set_bonding_agg_mode, 6118 .data = (void *) 0, 6119 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>", 6120 .tokens = { 6121 (void *)&cmd_set_bonding_agg_mode_set, 6122 (void *)&cmd_set_bonding_agg_mode_bonding, 6123 (void *)&cmd_set_bonding_agg_mode_agg_mode, 6124 (void *)&cmd_set_bonding_agg_mode_portnum, 6125 (void *)&cmd_set_bonding_agg_mode_policy_string, 6126 NULL 6127 } 6128 }; 6129 6130 6131 #endif /* RTE_LIBRTE_PMD_BOND */ 6132 6133 /* *** SET FORWARDING MODE *** */ 6134 struct cmd_set_fwd_mode_result { 6135 cmdline_fixed_string_t set; 6136 cmdline_fixed_string_t fwd; 6137 cmdline_fixed_string_t mode; 6138 }; 6139 6140 static void cmd_set_fwd_mode_parsed(void *parsed_result, 6141 __attribute__((unused)) struct cmdline *cl, 6142 __attribute__((unused)) void *data) 6143 { 6144 struct cmd_set_fwd_mode_result *res = parsed_result; 6145 6146 retry_enabled = 0; 6147 set_pkt_forwarding_mode(res->mode); 6148 } 6149 6150 cmdline_parse_token_string_t cmd_setfwd_set = 6151 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set"); 6152 cmdline_parse_token_string_t cmd_setfwd_fwd = 6153 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd"); 6154 cmdline_parse_token_string_t cmd_setfwd_mode = 6155 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode, 6156 "" /* defined at init */); 6157 6158 cmdline_parse_inst_t cmd_set_fwd_mode = { 6159 .f = cmd_set_fwd_mode_parsed, 6160 .data = NULL, 6161 .help_str = NULL, /* defined at init */ 6162 .tokens = { 6163 (void *)&cmd_setfwd_set, 6164 (void *)&cmd_setfwd_fwd, 6165 (void *)&cmd_setfwd_mode, 6166 NULL, 6167 }, 6168 }; 6169 6170 static void cmd_set_fwd_mode_init(void) 6171 { 6172 char *modes, *c; 6173 static char token[128]; 6174 static char help[256]; 6175 cmdline_parse_token_string_t *token_struct; 6176 6177 modes = list_pkt_forwarding_modes(); 6178 snprintf(help, sizeof(help), "set fwd %s: " 6179 "Set packet forwarding mode", modes); 6180 cmd_set_fwd_mode.help_str = help; 6181 6182 /* string token separator is # */ 6183 for (c = token; *modes != '\0'; modes++) 6184 if (*modes == '|') 6185 *c++ = '#'; 6186 else 6187 *c++ = *modes; 6188 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2]; 6189 token_struct->string_data.str = token; 6190 } 6191 6192 /* *** SET RETRY FORWARDING MODE *** */ 6193 struct cmd_set_fwd_retry_mode_result { 6194 cmdline_fixed_string_t set; 6195 cmdline_fixed_string_t fwd; 6196 cmdline_fixed_string_t mode; 6197 cmdline_fixed_string_t retry; 6198 }; 6199 6200 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result, 6201 __attribute__((unused)) struct cmdline *cl, 6202 __attribute__((unused)) void *data) 6203 { 6204 struct cmd_set_fwd_retry_mode_result *res = parsed_result; 6205 6206 retry_enabled = 1; 6207 set_pkt_forwarding_mode(res->mode); 6208 } 6209 6210 cmdline_parse_token_string_t cmd_setfwd_retry_set = 6211 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6212 set, "set"); 6213 cmdline_parse_token_string_t cmd_setfwd_retry_fwd = 6214 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6215 fwd, "fwd"); 6216 cmdline_parse_token_string_t cmd_setfwd_retry_mode = 6217 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6218 mode, 6219 "" /* defined at init */); 6220 cmdline_parse_token_string_t cmd_setfwd_retry_retry = 6221 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6222 retry, "retry"); 6223 6224 cmdline_parse_inst_t cmd_set_fwd_retry_mode = { 6225 .f = cmd_set_fwd_retry_mode_parsed, 6226 .data = NULL, 6227 .help_str = NULL, /* defined at init */ 6228 .tokens = { 6229 (void *)&cmd_setfwd_retry_set, 6230 (void *)&cmd_setfwd_retry_fwd, 6231 (void *)&cmd_setfwd_retry_mode, 6232 (void *)&cmd_setfwd_retry_retry, 6233 NULL, 6234 }, 6235 }; 6236 6237 static void cmd_set_fwd_retry_mode_init(void) 6238 { 6239 char *modes, *c; 6240 static char token[128]; 6241 static char help[256]; 6242 cmdline_parse_token_string_t *token_struct; 6243 6244 modes = list_pkt_forwarding_retry_modes(); 6245 snprintf(help, sizeof(help), "set fwd %s retry: " 6246 "Set packet forwarding mode with retry", modes); 6247 cmd_set_fwd_retry_mode.help_str = help; 6248 6249 /* string token separator is # */ 6250 for (c = token; *modes != '\0'; modes++) 6251 if (*modes == '|') 6252 *c++ = '#'; 6253 else 6254 *c++ = *modes; 6255 token_struct = (cmdline_parse_token_string_t *) 6256 cmd_set_fwd_retry_mode.tokens[2]; 6257 token_struct->string_data.str = token; 6258 } 6259 6260 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */ 6261 struct cmd_set_burst_tx_retry_result { 6262 cmdline_fixed_string_t set; 6263 cmdline_fixed_string_t burst; 6264 cmdline_fixed_string_t tx; 6265 cmdline_fixed_string_t delay; 6266 uint32_t time; 6267 cmdline_fixed_string_t retry; 6268 uint32_t retry_num; 6269 }; 6270 6271 static void cmd_set_burst_tx_retry_parsed(void *parsed_result, 6272 __attribute__((unused)) struct cmdline *cl, 6273 __attribute__((unused)) void *data) 6274 { 6275 struct cmd_set_burst_tx_retry_result *res = parsed_result; 6276 6277 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst") 6278 && !strcmp(res->tx, "tx")) { 6279 if (!strcmp(res->delay, "delay")) 6280 burst_tx_delay_time = res->time; 6281 if (!strcmp(res->retry, "retry")) 6282 burst_tx_retry_num = res->retry_num; 6283 } 6284 6285 } 6286 6287 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set = 6288 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set"); 6289 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst = 6290 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst, 6291 "burst"); 6292 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx = 6293 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx"); 6294 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay = 6295 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay"); 6296 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time = 6297 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32); 6298 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry = 6299 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry"); 6300 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num = 6301 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32); 6302 6303 cmdline_parse_inst_t cmd_set_burst_tx_retry = { 6304 .f = cmd_set_burst_tx_retry_parsed, 6305 .help_str = "set burst tx delay <delay_usec> retry <num_retry>", 6306 .tokens = { 6307 (void *)&cmd_set_burst_tx_retry_set, 6308 (void *)&cmd_set_burst_tx_retry_burst, 6309 (void *)&cmd_set_burst_tx_retry_tx, 6310 (void *)&cmd_set_burst_tx_retry_delay, 6311 (void *)&cmd_set_burst_tx_retry_time, 6312 (void *)&cmd_set_burst_tx_retry_retry, 6313 (void *)&cmd_set_burst_tx_retry_retry_num, 6314 NULL, 6315 }, 6316 }; 6317 6318 /* *** SET PROMISC MODE *** */ 6319 struct cmd_set_promisc_mode_result { 6320 cmdline_fixed_string_t set; 6321 cmdline_fixed_string_t promisc; 6322 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6323 uint16_t port_num; /* valid if "allports" argument == 0 */ 6324 cmdline_fixed_string_t mode; 6325 }; 6326 6327 static void cmd_set_promisc_mode_parsed(void *parsed_result, 6328 __attribute__((unused)) struct cmdline *cl, 6329 void *allports) 6330 { 6331 struct cmd_set_promisc_mode_result *res = parsed_result; 6332 int enable; 6333 portid_t i; 6334 6335 if (!strcmp(res->mode, "on")) 6336 enable = 1; 6337 else 6338 enable = 0; 6339 6340 /* all ports */ 6341 if (allports) { 6342 RTE_ETH_FOREACH_DEV(i) { 6343 if (enable) 6344 rte_eth_promiscuous_enable(i); 6345 else 6346 rte_eth_promiscuous_disable(i); 6347 } 6348 } 6349 else { 6350 if (enable) 6351 rte_eth_promiscuous_enable(res->port_num); 6352 else 6353 rte_eth_promiscuous_disable(res->port_num); 6354 } 6355 } 6356 6357 cmdline_parse_token_string_t cmd_setpromisc_set = 6358 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set"); 6359 cmdline_parse_token_string_t cmd_setpromisc_promisc = 6360 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc, 6361 "promisc"); 6362 cmdline_parse_token_string_t cmd_setpromisc_portall = 6363 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all, 6364 "all"); 6365 cmdline_parse_token_num_t cmd_setpromisc_portnum = 6366 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num, 6367 UINT16); 6368 cmdline_parse_token_string_t cmd_setpromisc_mode = 6369 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode, 6370 "on#off"); 6371 6372 cmdline_parse_inst_t cmd_set_promisc_mode_all = { 6373 .f = cmd_set_promisc_mode_parsed, 6374 .data = (void *)1, 6375 .help_str = "set promisc all on|off: Set promisc mode for all ports", 6376 .tokens = { 6377 (void *)&cmd_setpromisc_set, 6378 (void *)&cmd_setpromisc_promisc, 6379 (void *)&cmd_setpromisc_portall, 6380 (void *)&cmd_setpromisc_mode, 6381 NULL, 6382 }, 6383 }; 6384 6385 cmdline_parse_inst_t cmd_set_promisc_mode_one = { 6386 .f = cmd_set_promisc_mode_parsed, 6387 .data = (void *)0, 6388 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id", 6389 .tokens = { 6390 (void *)&cmd_setpromisc_set, 6391 (void *)&cmd_setpromisc_promisc, 6392 (void *)&cmd_setpromisc_portnum, 6393 (void *)&cmd_setpromisc_mode, 6394 NULL, 6395 }, 6396 }; 6397 6398 /* *** SET ALLMULTI MODE *** */ 6399 struct cmd_set_allmulti_mode_result { 6400 cmdline_fixed_string_t set; 6401 cmdline_fixed_string_t allmulti; 6402 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6403 uint16_t port_num; /* valid if "allports" argument == 0 */ 6404 cmdline_fixed_string_t mode; 6405 }; 6406 6407 static void cmd_set_allmulti_mode_parsed(void *parsed_result, 6408 __attribute__((unused)) struct cmdline *cl, 6409 void *allports) 6410 { 6411 struct cmd_set_allmulti_mode_result *res = parsed_result; 6412 int enable; 6413 portid_t i; 6414 6415 if (!strcmp(res->mode, "on")) 6416 enable = 1; 6417 else 6418 enable = 0; 6419 6420 /* all ports */ 6421 if (allports) { 6422 RTE_ETH_FOREACH_DEV(i) { 6423 if (enable) 6424 rte_eth_allmulticast_enable(i); 6425 else 6426 rte_eth_allmulticast_disable(i); 6427 } 6428 } 6429 else { 6430 if (enable) 6431 rte_eth_allmulticast_enable(res->port_num); 6432 else 6433 rte_eth_allmulticast_disable(res->port_num); 6434 } 6435 } 6436 6437 cmdline_parse_token_string_t cmd_setallmulti_set = 6438 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set"); 6439 cmdline_parse_token_string_t cmd_setallmulti_allmulti = 6440 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti, 6441 "allmulti"); 6442 cmdline_parse_token_string_t cmd_setallmulti_portall = 6443 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all, 6444 "all"); 6445 cmdline_parse_token_num_t cmd_setallmulti_portnum = 6446 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num, 6447 UINT16); 6448 cmdline_parse_token_string_t cmd_setallmulti_mode = 6449 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode, 6450 "on#off"); 6451 6452 cmdline_parse_inst_t cmd_set_allmulti_mode_all = { 6453 .f = cmd_set_allmulti_mode_parsed, 6454 .data = (void *)1, 6455 .help_str = "set allmulti all on|off: Set allmulti mode for all ports", 6456 .tokens = { 6457 (void *)&cmd_setallmulti_set, 6458 (void *)&cmd_setallmulti_allmulti, 6459 (void *)&cmd_setallmulti_portall, 6460 (void *)&cmd_setallmulti_mode, 6461 NULL, 6462 }, 6463 }; 6464 6465 cmdline_parse_inst_t cmd_set_allmulti_mode_one = { 6466 .f = cmd_set_allmulti_mode_parsed, 6467 .data = (void *)0, 6468 .help_str = "set allmulti <port_id> on|off: " 6469 "Set allmulti mode on port_id", 6470 .tokens = { 6471 (void *)&cmd_setallmulti_set, 6472 (void *)&cmd_setallmulti_allmulti, 6473 (void *)&cmd_setallmulti_portnum, 6474 (void *)&cmd_setallmulti_mode, 6475 NULL, 6476 }, 6477 }; 6478 6479 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */ 6480 struct cmd_link_flow_ctrl_set_result { 6481 cmdline_fixed_string_t set; 6482 cmdline_fixed_string_t flow_ctrl; 6483 cmdline_fixed_string_t rx; 6484 cmdline_fixed_string_t rx_lfc_mode; 6485 cmdline_fixed_string_t tx; 6486 cmdline_fixed_string_t tx_lfc_mode; 6487 cmdline_fixed_string_t mac_ctrl_frame_fwd; 6488 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode; 6489 cmdline_fixed_string_t autoneg_str; 6490 cmdline_fixed_string_t autoneg; 6491 cmdline_fixed_string_t hw_str; 6492 uint32_t high_water; 6493 cmdline_fixed_string_t lw_str; 6494 uint32_t low_water; 6495 cmdline_fixed_string_t pt_str; 6496 uint16_t pause_time; 6497 cmdline_fixed_string_t xon_str; 6498 uint16_t send_xon; 6499 portid_t port_id; 6500 }; 6501 6502 cmdline_parse_token_string_t cmd_lfc_set_set = 6503 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6504 set, "set"); 6505 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl = 6506 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6507 flow_ctrl, "flow_ctrl"); 6508 cmdline_parse_token_string_t cmd_lfc_set_rx = 6509 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6510 rx, "rx"); 6511 cmdline_parse_token_string_t cmd_lfc_set_rx_mode = 6512 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6513 rx_lfc_mode, "on#off"); 6514 cmdline_parse_token_string_t cmd_lfc_set_tx = 6515 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6516 tx, "tx"); 6517 cmdline_parse_token_string_t cmd_lfc_set_tx_mode = 6518 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6519 tx_lfc_mode, "on#off"); 6520 cmdline_parse_token_string_t cmd_lfc_set_high_water_str = 6521 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6522 hw_str, "high_water"); 6523 cmdline_parse_token_num_t cmd_lfc_set_high_water = 6524 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6525 high_water, UINT32); 6526 cmdline_parse_token_string_t cmd_lfc_set_low_water_str = 6527 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6528 lw_str, "low_water"); 6529 cmdline_parse_token_num_t cmd_lfc_set_low_water = 6530 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6531 low_water, UINT32); 6532 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str = 6533 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6534 pt_str, "pause_time"); 6535 cmdline_parse_token_num_t cmd_lfc_set_pause_time = 6536 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6537 pause_time, UINT16); 6538 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str = 6539 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6540 xon_str, "send_xon"); 6541 cmdline_parse_token_num_t cmd_lfc_set_send_xon = 6542 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6543 send_xon, UINT16); 6544 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode = 6545 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6546 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd"); 6547 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd = 6548 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6549 mac_ctrl_frame_fwd_mode, "on#off"); 6550 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str = 6551 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6552 autoneg_str, "autoneg"); 6553 cmdline_parse_token_string_t cmd_lfc_set_autoneg = 6554 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6555 autoneg, "on#off"); 6556 cmdline_parse_token_num_t cmd_lfc_set_portid = 6557 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6558 port_id, UINT16); 6559 6560 /* forward declaration */ 6561 static void 6562 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl, 6563 void *data); 6564 6565 cmdline_parse_inst_t cmd_link_flow_control_set = { 6566 .f = cmd_link_flow_ctrl_set_parsed, 6567 .data = NULL, 6568 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> " 6569 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off " 6570 "autoneg on|off <port_id>: Configure the Ethernet flow control", 6571 .tokens = { 6572 (void *)&cmd_lfc_set_set, 6573 (void *)&cmd_lfc_set_flow_ctrl, 6574 (void *)&cmd_lfc_set_rx, 6575 (void *)&cmd_lfc_set_rx_mode, 6576 (void *)&cmd_lfc_set_tx, 6577 (void *)&cmd_lfc_set_tx_mode, 6578 (void *)&cmd_lfc_set_high_water, 6579 (void *)&cmd_lfc_set_low_water, 6580 (void *)&cmd_lfc_set_pause_time, 6581 (void *)&cmd_lfc_set_send_xon, 6582 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6583 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6584 (void *)&cmd_lfc_set_autoneg_str, 6585 (void *)&cmd_lfc_set_autoneg, 6586 (void *)&cmd_lfc_set_portid, 6587 NULL, 6588 }, 6589 }; 6590 6591 cmdline_parse_inst_t cmd_link_flow_control_set_rx = { 6592 .f = cmd_link_flow_ctrl_set_parsed, 6593 .data = (void *)&cmd_link_flow_control_set_rx, 6594 .help_str = "set flow_ctrl rx on|off <port_id>: " 6595 "Change rx flow control parameter", 6596 .tokens = { 6597 (void *)&cmd_lfc_set_set, 6598 (void *)&cmd_lfc_set_flow_ctrl, 6599 (void *)&cmd_lfc_set_rx, 6600 (void *)&cmd_lfc_set_rx_mode, 6601 (void *)&cmd_lfc_set_portid, 6602 NULL, 6603 }, 6604 }; 6605 6606 cmdline_parse_inst_t cmd_link_flow_control_set_tx = { 6607 .f = cmd_link_flow_ctrl_set_parsed, 6608 .data = (void *)&cmd_link_flow_control_set_tx, 6609 .help_str = "set flow_ctrl tx on|off <port_id>: " 6610 "Change tx flow control parameter", 6611 .tokens = { 6612 (void *)&cmd_lfc_set_set, 6613 (void *)&cmd_lfc_set_flow_ctrl, 6614 (void *)&cmd_lfc_set_tx, 6615 (void *)&cmd_lfc_set_tx_mode, 6616 (void *)&cmd_lfc_set_portid, 6617 NULL, 6618 }, 6619 }; 6620 6621 cmdline_parse_inst_t cmd_link_flow_control_set_hw = { 6622 .f = cmd_link_flow_ctrl_set_parsed, 6623 .data = (void *)&cmd_link_flow_control_set_hw, 6624 .help_str = "set flow_ctrl high_water <value> <port_id>: " 6625 "Change high water flow control parameter", 6626 .tokens = { 6627 (void *)&cmd_lfc_set_set, 6628 (void *)&cmd_lfc_set_flow_ctrl, 6629 (void *)&cmd_lfc_set_high_water_str, 6630 (void *)&cmd_lfc_set_high_water, 6631 (void *)&cmd_lfc_set_portid, 6632 NULL, 6633 }, 6634 }; 6635 6636 cmdline_parse_inst_t cmd_link_flow_control_set_lw = { 6637 .f = cmd_link_flow_ctrl_set_parsed, 6638 .data = (void *)&cmd_link_flow_control_set_lw, 6639 .help_str = "set flow_ctrl low_water <value> <port_id>: " 6640 "Change low water flow control parameter", 6641 .tokens = { 6642 (void *)&cmd_lfc_set_set, 6643 (void *)&cmd_lfc_set_flow_ctrl, 6644 (void *)&cmd_lfc_set_low_water_str, 6645 (void *)&cmd_lfc_set_low_water, 6646 (void *)&cmd_lfc_set_portid, 6647 NULL, 6648 }, 6649 }; 6650 6651 cmdline_parse_inst_t cmd_link_flow_control_set_pt = { 6652 .f = cmd_link_flow_ctrl_set_parsed, 6653 .data = (void *)&cmd_link_flow_control_set_pt, 6654 .help_str = "set flow_ctrl pause_time <value> <port_id>: " 6655 "Change pause time flow control parameter", 6656 .tokens = { 6657 (void *)&cmd_lfc_set_set, 6658 (void *)&cmd_lfc_set_flow_ctrl, 6659 (void *)&cmd_lfc_set_pause_time_str, 6660 (void *)&cmd_lfc_set_pause_time, 6661 (void *)&cmd_lfc_set_portid, 6662 NULL, 6663 }, 6664 }; 6665 6666 cmdline_parse_inst_t cmd_link_flow_control_set_xon = { 6667 .f = cmd_link_flow_ctrl_set_parsed, 6668 .data = (void *)&cmd_link_flow_control_set_xon, 6669 .help_str = "set flow_ctrl send_xon <value> <port_id>: " 6670 "Change send_xon flow control parameter", 6671 .tokens = { 6672 (void *)&cmd_lfc_set_set, 6673 (void *)&cmd_lfc_set_flow_ctrl, 6674 (void *)&cmd_lfc_set_send_xon_str, 6675 (void *)&cmd_lfc_set_send_xon, 6676 (void *)&cmd_lfc_set_portid, 6677 NULL, 6678 }, 6679 }; 6680 6681 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = { 6682 .f = cmd_link_flow_ctrl_set_parsed, 6683 .data = (void *)&cmd_link_flow_control_set_macfwd, 6684 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: " 6685 "Change mac ctrl fwd flow control parameter", 6686 .tokens = { 6687 (void *)&cmd_lfc_set_set, 6688 (void *)&cmd_lfc_set_flow_ctrl, 6689 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6690 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6691 (void *)&cmd_lfc_set_portid, 6692 NULL, 6693 }, 6694 }; 6695 6696 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = { 6697 .f = cmd_link_flow_ctrl_set_parsed, 6698 .data = (void *)&cmd_link_flow_control_set_autoneg, 6699 .help_str = "set flow_ctrl autoneg on|off <port_id>: " 6700 "Change autoneg flow control parameter", 6701 .tokens = { 6702 (void *)&cmd_lfc_set_set, 6703 (void *)&cmd_lfc_set_flow_ctrl, 6704 (void *)&cmd_lfc_set_autoneg_str, 6705 (void *)&cmd_lfc_set_autoneg, 6706 (void *)&cmd_lfc_set_portid, 6707 NULL, 6708 }, 6709 }; 6710 6711 static void 6712 cmd_link_flow_ctrl_set_parsed(void *parsed_result, 6713 __attribute__((unused)) struct cmdline *cl, 6714 void *data) 6715 { 6716 struct cmd_link_flow_ctrl_set_result *res = parsed_result; 6717 cmdline_parse_inst_t *cmd = data; 6718 struct rte_eth_fc_conf fc_conf; 6719 int rx_fc_en = 0; 6720 int tx_fc_en = 0; 6721 int ret; 6722 6723 /* 6724 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6725 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6726 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6727 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6728 */ 6729 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = { 6730 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 6731 }; 6732 6733 /* Partial command line, retrieve current configuration */ 6734 if (cmd) { 6735 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 6736 if (ret != 0) { 6737 printf("cannot get current flow ctrl parameters, return" 6738 "code = %d\n", ret); 6739 return; 6740 } 6741 6742 if ((fc_conf.mode == RTE_FC_RX_PAUSE) || 6743 (fc_conf.mode == RTE_FC_FULL)) 6744 rx_fc_en = 1; 6745 if ((fc_conf.mode == RTE_FC_TX_PAUSE) || 6746 (fc_conf.mode == RTE_FC_FULL)) 6747 tx_fc_en = 1; 6748 } 6749 6750 if (!cmd || cmd == &cmd_link_flow_control_set_rx) 6751 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0; 6752 6753 if (!cmd || cmd == &cmd_link_flow_control_set_tx) 6754 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0; 6755 6756 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en]; 6757 6758 if (!cmd || cmd == &cmd_link_flow_control_set_hw) 6759 fc_conf.high_water = res->high_water; 6760 6761 if (!cmd || cmd == &cmd_link_flow_control_set_lw) 6762 fc_conf.low_water = res->low_water; 6763 6764 if (!cmd || cmd == &cmd_link_flow_control_set_pt) 6765 fc_conf.pause_time = res->pause_time; 6766 6767 if (!cmd || cmd == &cmd_link_flow_control_set_xon) 6768 fc_conf.send_xon = res->send_xon; 6769 6770 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) { 6771 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) 6772 fc_conf.mac_ctrl_frame_fwd = 1; 6773 else 6774 fc_conf.mac_ctrl_frame_fwd = 0; 6775 } 6776 6777 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg) 6778 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0; 6779 6780 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf); 6781 if (ret != 0) 6782 printf("bad flow contrl parameter, return code = %d \n", ret); 6783 } 6784 6785 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */ 6786 struct cmd_priority_flow_ctrl_set_result { 6787 cmdline_fixed_string_t set; 6788 cmdline_fixed_string_t pfc_ctrl; 6789 cmdline_fixed_string_t rx; 6790 cmdline_fixed_string_t rx_pfc_mode; 6791 cmdline_fixed_string_t tx; 6792 cmdline_fixed_string_t tx_pfc_mode; 6793 uint32_t high_water; 6794 uint32_t low_water; 6795 uint16_t pause_time; 6796 uint8_t priority; 6797 portid_t port_id; 6798 }; 6799 6800 static void 6801 cmd_priority_flow_ctrl_set_parsed(void *parsed_result, 6802 __attribute__((unused)) struct cmdline *cl, 6803 __attribute__((unused)) void *data) 6804 { 6805 struct cmd_priority_flow_ctrl_set_result *res = parsed_result; 6806 struct rte_eth_pfc_conf pfc_conf; 6807 int rx_fc_enable, tx_fc_enable; 6808 int ret; 6809 6810 /* 6811 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6812 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6813 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6814 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6815 */ 6816 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = { 6817 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL} 6818 }; 6819 6820 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; 6821 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; 6822 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; 6823 pfc_conf.fc.high_water = res->high_water; 6824 pfc_conf.fc.low_water = res->low_water; 6825 pfc_conf.fc.pause_time = res->pause_time; 6826 pfc_conf.priority = res->priority; 6827 6828 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf); 6829 if (ret != 0) 6830 printf("bad priority flow contrl parameter, return code = %d \n", ret); 6831 } 6832 6833 cmdline_parse_token_string_t cmd_pfc_set_set = 6834 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6835 set, "set"); 6836 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl = 6837 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6838 pfc_ctrl, "pfc_ctrl"); 6839 cmdline_parse_token_string_t cmd_pfc_set_rx = 6840 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6841 rx, "rx"); 6842 cmdline_parse_token_string_t cmd_pfc_set_rx_mode = 6843 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6844 rx_pfc_mode, "on#off"); 6845 cmdline_parse_token_string_t cmd_pfc_set_tx = 6846 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6847 tx, "tx"); 6848 cmdline_parse_token_string_t cmd_pfc_set_tx_mode = 6849 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6850 tx_pfc_mode, "on#off"); 6851 cmdline_parse_token_num_t cmd_pfc_set_high_water = 6852 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6853 high_water, UINT32); 6854 cmdline_parse_token_num_t cmd_pfc_set_low_water = 6855 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6856 low_water, UINT32); 6857 cmdline_parse_token_num_t cmd_pfc_set_pause_time = 6858 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6859 pause_time, UINT16); 6860 cmdline_parse_token_num_t cmd_pfc_set_priority = 6861 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6862 priority, UINT8); 6863 cmdline_parse_token_num_t cmd_pfc_set_portid = 6864 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6865 port_id, UINT16); 6866 6867 cmdline_parse_inst_t cmd_priority_flow_control_set = { 6868 .f = cmd_priority_flow_ctrl_set_parsed, 6869 .data = NULL, 6870 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> " 6871 "<pause_time> <priority> <port_id>: " 6872 "Configure the Ethernet priority flow control", 6873 .tokens = { 6874 (void *)&cmd_pfc_set_set, 6875 (void *)&cmd_pfc_set_flow_ctrl, 6876 (void *)&cmd_pfc_set_rx, 6877 (void *)&cmd_pfc_set_rx_mode, 6878 (void *)&cmd_pfc_set_tx, 6879 (void *)&cmd_pfc_set_tx_mode, 6880 (void *)&cmd_pfc_set_high_water, 6881 (void *)&cmd_pfc_set_low_water, 6882 (void *)&cmd_pfc_set_pause_time, 6883 (void *)&cmd_pfc_set_priority, 6884 (void *)&cmd_pfc_set_portid, 6885 NULL, 6886 }, 6887 }; 6888 6889 /* *** RESET CONFIGURATION *** */ 6890 struct cmd_reset_result { 6891 cmdline_fixed_string_t reset; 6892 cmdline_fixed_string_t def; 6893 }; 6894 6895 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result, 6896 struct cmdline *cl, 6897 __attribute__((unused)) void *data) 6898 { 6899 cmdline_printf(cl, "Reset to default forwarding configuration...\n"); 6900 set_def_fwd_config(); 6901 } 6902 6903 cmdline_parse_token_string_t cmd_reset_set = 6904 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set"); 6905 cmdline_parse_token_string_t cmd_reset_def = 6906 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def, 6907 "default"); 6908 6909 cmdline_parse_inst_t cmd_reset = { 6910 .f = cmd_reset_parsed, 6911 .data = NULL, 6912 .help_str = "set default: Reset default forwarding configuration", 6913 .tokens = { 6914 (void *)&cmd_reset_set, 6915 (void *)&cmd_reset_def, 6916 NULL, 6917 }, 6918 }; 6919 6920 /* *** START FORWARDING *** */ 6921 struct cmd_start_result { 6922 cmdline_fixed_string_t start; 6923 }; 6924 6925 cmdline_parse_token_string_t cmd_start_start = 6926 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start"); 6927 6928 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result, 6929 __attribute__((unused)) struct cmdline *cl, 6930 __attribute__((unused)) void *data) 6931 { 6932 start_packet_forwarding(0); 6933 } 6934 6935 cmdline_parse_inst_t cmd_start = { 6936 .f = cmd_start_parsed, 6937 .data = NULL, 6938 .help_str = "start: Start packet forwarding", 6939 .tokens = { 6940 (void *)&cmd_start_start, 6941 NULL, 6942 }, 6943 }; 6944 6945 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */ 6946 struct cmd_start_tx_first_result { 6947 cmdline_fixed_string_t start; 6948 cmdline_fixed_string_t tx_first; 6949 }; 6950 6951 static void 6952 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result, 6953 __attribute__((unused)) struct cmdline *cl, 6954 __attribute__((unused)) void *data) 6955 { 6956 start_packet_forwarding(1); 6957 } 6958 6959 cmdline_parse_token_string_t cmd_start_tx_first_start = 6960 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start, 6961 "start"); 6962 cmdline_parse_token_string_t cmd_start_tx_first_tx_first = 6963 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, 6964 tx_first, "tx_first"); 6965 6966 cmdline_parse_inst_t cmd_start_tx_first = { 6967 .f = cmd_start_tx_first_parsed, 6968 .data = NULL, 6969 .help_str = "start tx_first: Start packet forwarding, " 6970 "after sending 1 burst of packets", 6971 .tokens = { 6972 (void *)&cmd_start_tx_first_start, 6973 (void *)&cmd_start_tx_first_tx_first, 6974 NULL, 6975 }, 6976 }; 6977 6978 /* *** START FORWARDING WITH N TX BURST FIRST *** */ 6979 struct cmd_start_tx_first_n_result { 6980 cmdline_fixed_string_t start; 6981 cmdline_fixed_string_t tx_first; 6982 uint32_t tx_num; 6983 }; 6984 6985 static void 6986 cmd_start_tx_first_n_parsed(void *parsed_result, 6987 __attribute__((unused)) struct cmdline *cl, 6988 __attribute__((unused)) void *data) 6989 { 6990 struct cmd_start_tx_first_n_result *res = parsed_result; 6991 6992 start_packet_forwarding(res->tx_num); 6993 } 6994 6995 cmdline_parse_token_string_t cmd_start_tx_first_n_start = 6996 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 6997 start, "start"); 6998 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first = 6999 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7000 tx_first, "tx_first"); 7001 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num = 7002 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result, 7003 tx_num, UINT32); 7004 7005 cmdline_parse_inst_t cmd_start_tx_first_n = { 7006 .f = cmd_start_tx_first_n_parsed, 7007 .data = NULL, 7008 .help_str = "start tx_first <num>: " 7009 "packet forwarding, after sending <num> bursts of packets", 7010 .tokens = { 7011 (void *)&cmd_start_tx_first_n_start, 7012 (void *)&cmd_start_tx_first_n_tx_first, 7013 (void *)&cmd_start_tx_first_n_tx_num, 7014 NULL, 7015 }, 7016 }; 7017 7018 /* *** SET LINK UP *** */ 7019 struct cmd_set_link_up_result { 7020 cmdline_fixed_string_t set; 7021 cmdline_fixed_string_t link_up; 7022 cmdline_fixed_string_t port; 7023 portid_t port_id; 7024 }; 7025 7026 cmdline_parse_token_string_t cmd_set_link_up_set = 7027 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set"); 7028 cmdline_parse_token_string_t cmd_set_link_up_link_up = 7029 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up, 7030 "link-up"); 7031 cmdline_parse_token_string_t cmd_set_link_up_port = 7032 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port"); 7033 cmdline_parse_token_num_t cmd_set_link_up_port_id = 7034 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16); 7035 7036 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result, 7037 __attribute__((unused)) struct cmdline *cl, 7038 __attribute__((unused)) void *data) 7039 { 7040 struct cmd_set_link_up_result *res = parsed_result; 7041 dev_set_link_up(res->port_id); 7042 } 7043 7044 cmdline_parse_inst_t cmd_set_link_up = { 7045 .f = cmd_set_link_up_parsed, 7046 .data = NULL, 7047 .help_str = "set link-up port <port id>", 7048 .tokens = { 7049 (void *)&cmd_set_link_up_set, 7050 (void *)&cmd_set_link_up_link_up, 7051 (void *)&cmd_set_link_up_port, 7052 (void *)&cmd_set_link_up_port_id, 7053 NULL, 7054 }, 7055 }; 7056 7057 /* *** SET LINK DOWN *** */ 7058 struct cmd_set_link_down_result { 7059 cmdline_fixed_string_t set; 7060 cmdline_fixed_string_t link_down; 7061 cmdline_fixed_string_t port; 7062 portid_t port_id; 7063 }; 7064 7065 cmdline_parse_token_string_t cmd_set_link_down_set = 7066 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set"); 7067 cmdline_parse_token_string_t cmd_set_link_down_link_down = 7068 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down, 7069 "link-down"); 7070 cmdline_parse_token_string_t cmd_set_link_down_port = 7071 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port"); 7072 cmdline_parse_token_num_t cmd_set_link_down_port_id = 7073 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16); 7074 7075 static void cmd_set_link_down_parsed( 7076 __attribute__((unused)) void *parsed_result, 7077 __attribute__((unused)) struct cmdline *cl, 7078 __attribute__((unused)) void *data) 7079 { 7080 struct cmd_set_link_down_result *res = parsed_result; 7081 dev_set_link_down(res->port_id); 7082 } 7083 7084 cmdline_parse_inst_t cmd_set_link_down = { 7085 .f = cmd_set_link_down_parsed, 7086 .data = NULL, 7087 .help_str = "set link-down port <port id>", 7088 .tokens = { 7089 (void *)&cmd_set_link_down_set, 7090 (void *)&cmd_set_link_down_link_down, 7091 (void *)&cmd_set_link_down_port, 7092 (void *)&cmd_set_link_down_port_id, 7093 NULL, 7094 }, 7095 }; 7096 7097 /* *** SHOW CFG *** */ 7098 struct cmd_showcfg_result { 7099 cmdline_fixed_string_t show; 7100 cmdline_fixed_string_t cfg; 7101 cmdline_fixed_string_t what; 7102 }; 7103 7104 static void cmd_showcfg_parsed(void *parsed_result, 7105 __attribute__((unused)) struct cmdline *cl, 7106 __attribute__((unused)) void *data) 7107 { 7108 struct cmd_showcfg_result *res = parsed_result; 7109 if (!strcmp(res->what, "rxtx")) 7110 rxtx_config_display(); 7111 else if (!strcmp(res->what, "cores")) 7112 fwd_lcores_config_display(); 7113 else if (!strcmp(res->what, "fwd")) 7114 pkt_fwd_config_display(&cur_fwd_config); 7115 else if (!strcmp(res->what, "txpkts")) 7116 show_tx_pkt_segments(); 7117 } 7118 7119 cmdline_parse_token_string_t cmd_showcfg_show = 7120 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show"); 7121 cmdline_parse_token_string_t cmd_showcfg_port = 7122 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); 7123 cmdline_parse_token_string_t cmd_showcfg_what = 7124 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, 7125 "rxtx#cores#fwd#txpkts"); 7126 7127 cmdline_parse_inst_t cmd_showcfg = { 7128 .f = cmd_showcfg_parsed, 7129 .data = NULL, 7130 .help_str = "show config rxtx|cores|fwd|txpkts", 7131 .tokens = { 7132 (void *)&cmd_showcfg_show, 7133 (void *)&cmd_showcfg_port, 7134 (void *)&cmd_showcfg_what, 7135 NULL, 7136 }, 7137 }; 7138 7139 /* *** SHOW ALL PORT INFO *** */ 7140 struct cmd_showportall_result { 7141 cmdline_fixed_string_t show; 7142 cmdline_fixed_string_t port; 7143 cmdline_fixed_string_t what; 7144 cmdline_fixed_string_t all; 7145 }; 7146 7147 static void cmd_showportall_parsed(void *parsed_result, 7148 __attribute__((unused)) struct cmdline *cl, 7149 __attribute__((unused)) void *data) 7150 { 7151 portid_t i; 7152 7153 struct cmd_showportall_result *res = parsed_result; 7154 if (!strcmp(res->show, "clear")) { 7155 if (!strcmp(res->what, "stats")) 7156 RTE_ETH_FOREACH_DEV(i) 7157 nic_stats_clear(i); 7158 else if (!strcmp(res->what, "xstats")) 7159 RTE_ETH_FOREACH_DEV(i) 7160 nic_xstats_clear(i); 7161 } else if (!strcmp(res->what, "info")) 7162 RTE_ETH_FOREACH_DEV(i) 7163 port_infos_display(i); 7164 else if (!strcmp(res->what, "stats")) 7165 RTE_ETH_FOREACH_DEV(i) 7166 nic_stats_display(i); 7167 else if (!strcmp(res->what, "xstats")) 7168 RTE_ETH_FOREACH_DEV(i) 7169 nic_xstats_display(i); 7170 else if (!strcmp(res->what, "fdir")) 7171 RTE_ETH_FOREACH_DEV(i) 7172 fdir_get_infos(i); 7173 else if (!strcmp(res->what, "stat_qmap")) 7174 RTE_ETH_FOREACH_DEV(i) 7175 nic_stats_mapping_display(i); 7176 else if (!strcmp(res->what, "dcb_tc")) 7177 RTE_ETH_FOREACH_DEV(i) 7178 port_dcb_info_display(i); 7179 else if (!strcmp(res->what, "cap")) 7180 RTE_ETH_FOREACH_DEV(i) 7181 port_offload_cap_display(i); 7182 } 7183 7184 cmdline_parse_token_string_t cmd_showportall_show = 7185 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show, 7186 "show#clear"); 7187 cmdline_parse_token_string_t cmd_showportall_port = 7188 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); 7189 cmdline_parse_token_string_t cmd_showportall_what = 7190 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, 7191 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7192 cmdline_parse_token_string_t cmd_showportall_all = 7193 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); 7194 cmdline_parse_inst_t cmd_showportall = { 7195 .f = cmd_showportall_parsed, 7196 .data = NULL, 7197 .help_str = "show|clear port " 7198 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap all", 7199 .tokens = { 7200 (void *)&cmd_showportall_show, 7201 (void *)&cmd_showportall_port, 7202 (void *)&cmd_showportall_what, 7203 (void *)&cmd_showportall_all, 7204 NULL, 7205 }, 7206 }; 7207 7208 /* *** SHOW PORT INFO *** */ 7209 struct cmd_showport_result { 7210 cmdline_fixed_string_t show; 7211 cmdline_fixed_string_t port; 7212 cmdline_fixed_string_t what; 7213 uint16_t portnum; 7214 }; 7215 7216 static void cmd_showport_parsed(void *parsed_result, 7217 __attribute__((unused)) struct cmdline *cl, 7218 __attribute__((unused)) void *data) 7219 { 7220 struct cmd_showport_result *res = parsed_result; 7221 if (!strcmp(res->show, "clear")) { 7222 if (!strcmp(res->what, "stats")) 7223 nic_stats_clear(res->portnum); 7224 else if (!strcmp(res->what, "xstats")) 7225 nic_xstats_clear(res->portnum); 7226 } else if (!strcmp(res->what, "info")) 7227 port_infos_display(res->portnum); 7228 else if (!strcmp(res->what, "stats")) 7229 nic_stats_display(res->portnum); 7230 else if (!strcmp(res->what, "xstats")) 7231 nic_xstats_display(res->portnum); 7232 else if (!strcmp(res->what, "fdir")) 7233 fdir_get_infos(res->portnum); 7234 else if (!strcmp(res->what, "stat_qmap")) 7235 nic_stats_mapping_display(res->portnum); 7236 else if (!strcmp(res->what, "dcb_tc")) 7237 port_dcb_info_display(res->portnum); 7238 else if (!strcmp(res->what, "cap")) 7239 port_offload_cap_display(res->portnum); 7240 } 7241 7242 cmdline_parse_token_string_t cmd_showport_show = 7243 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show, 7244 "show#clear"); 7245 cmdline_parse_token_string_t cmd_showport_port = 7246 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); 7247 cmdline_parse_token_string_t cmd_showport_what = 7248 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, 7249 "info#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7250 cmdline_parse_token_num_t cmd_showport_portnum = 7251 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16); 7252 7253 cmdline_parse_inst_t cmd_showport = { 7254 .f = cmd_showport_parsed, 7255 .data = NULL, 7256 .help_str = "show|clear port " 7257 "info|stats|xstats|fdir|stat_qmap|dcb_tc|cap " 7258 "<port_id>", 7259 .tokens = { 7260 (void *)&cmd_showport_show, 7261 (void *)&cmd_showport_port, 7262 (void *)&cmd_showport_what, 7263 (void *)&cmd_showport_portnum, 7264 NULL, 7265 }, 7266 }; 7267 7268 /* *** SHOW QUEUE INFO *** */ 7269 struct cmd_showqueue_result { 7270 cmdline_fixed_string_t show; 7271 cmdline_fixed_string_t type; 7272 cmdline_fixed_string_t what; 7273 uint16_t portnum; 7274 uint16_t queuenum; 7275 }; 7276 7277 static void 7278 cmd_showqueue_parsed(void *parsed_result, 7279 __attribute__((unused)) struct cmdline *cl, 7280 __attribute__((unused)) void *data) 7281 { 7282 struct cmd_showqueue_result *res = parsed_result; 7283 7284 if (!strcmp(res->type, "rxq")) 7285 rx_queue_infos_display(res->portnum, res->queuenum); 7286 else if (!strcmp(res->type, "txq")) 7287 tx_queue_infos_display(res->portnum, res->queuenum); 7288 } 7289 7290 cmdline_parse_token_string_t cmd_showqueue_show = 7291 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show"); 7292 cmdline_parse_token_string_t cmd_showqueue_type = 7293 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq"); 7294 cmdline_parse_token_string_t cmd_showqueue_what = 7295 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info"); 7296 cmdline_parse_token_num_t cmd_showqueue_portnum = 7297 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16); 7298 cmdline_parse_token_num_t cmd_showqueue_queuenum = 7299 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16); 7300 7301 cmdline_parse_inst_t cmd_showqueue = { 7302 .f = cmd_showqueue_parsed, 7303 .data = NULL, 7304 .help_str = "show rxq|txq info <port_id> <queue_id>", 7305 .tokens = { 7306 (void *)&cmd_showqueue_show, 7307 (void *)&cmd_showqueue_type, 7308 (void *)&cmd_showqueue_what, 7309 (void *)&cmd_showqueue_portnum, 7310 (void *)&cmd_showqueue_queuenum, 7311 NULL, 7312 }, 7313 }; 7314 7315 /* *** READ PORT REGISTER *** */ 7316 struct cmd_read_reg_result { 7317 cmdline_fixed_string_t read; 7318 cmdline_fixed_string_t reg; 7319 portid_t port_id; 7320 uint32_t reg_off; 7321 }; 7322 7323 static void 7324 cmd_read_reg_parsed(void *parsed_result, 7325 __attribute__((unused)) struct cmdline *cl, 7326 __attribute__((unused)) void *data) 7327 { 7328 struct cmd_read_reg_result *res = parsed_result; 7329 port_reg_display(res->port_id, res->reg_off); 7330 } 7331 7332 cmdline_parse_token_string_t cmd_read_reg_read = 7333 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read"); 7334 cmdline_parse_token_string_t cmd_read_reg_reg = 7335 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg"); 7336 cmdline_parse_token_num_t cmd_read_reg_port_id = 7337 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16); 7338 cmdline_parse_token_num_t cmd_read_reg_reg_off = 7339 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32); 7340 7341 cmdline_parse_inst_t cmd_read_reg = { 7342 .f = cmd_read_reg_parsed, 7343 .data = NULL, 7344 .help_str = "read reg <port_id> <reg_off>", 7345 .tokens = { 7346 (void *)&cmd_read_reg_read, 7347 (void *)&cmd_read_reg_reg, 7348 (void *)&cmd_read_reg_port_id, 7349 (void *)&cmd_read_reg_reg_off, 7350 NULL, 7351 }, 7352 }; 7353 7354 /* *** READ PORT REGISTER BIT FIELD *** */ 7355 struct cmd_read_reg_bit_field_result { 7356 cmdline_fixed_string_t read; 7357 cmdline_fixed_string_t regfield; 7358 portid_t port_id; 7359 uint32_t reg_off; 7360 uint8_t bit1_pos; 7361 uint8_t bit2_pos; 7362 }; 7363 7364 static void 7365 cmd_read_reg_bit_field_parsed(void *parsed_result, 7366 __attribute__((unused)) struct cmdline *cl, 7367 __attribute__((unused)) void *data) 7368 { 7369 struct cmd_read_reg_bit_field_result *res = parsed_result; 7370 port_reg_bit_field_display(res->port_id, res->reg_off, 7371 res->bit1_pos, res->bit2_pos); 7372 } 7373 7374 cmdline_parse_token_string_t cmd_read_reg_bit_field_read = 7375 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read, 7376 "read"); 7377 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield = 7378 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, 7379 regfield, "regfield"); 7380 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id = 7381 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id, 7382 UINT16); 7383 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off = 7384 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off, 7385 UINT32); 7386 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos = 7387 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos, 7388 UINT8); 7389 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos = 7390 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos, 7391 UINT8); 7392 7393 cmdline_parse_inst_t cmd_read_reg_bit_field = { 7394 .f = cmd_read_reg_bit_field_parsed, 7395 .data = NULL, 7396 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: " 7397 "Read register bit field between bit_x and bit_y included", 7398 .tokens = { 7399 (void *)&cmd_read_reg_bit_field_read, 7400 (void *)&cmd_read_reg_bit_field_regfield, 7401 (void *)&cmd_read_reg_bit_field_port_id, 7402 (void *)&cmd_read_reg_bit_field_reg_off, 7403 (void *)&cmd_read_reg_bit_field_bit1_pos, 7404 (void *)&cmd_read_reg_bit_field_bit2_pos, 7405 NULL, 7406 }, 7407 }; 7408 7409 /* *** READ PORT REGISTER BIT *** */ 7410 struct cmd_read_reg_bit_result { 7411 cmdline_fixed_string_t read; 7412 cmdline_fixed_string_t regbit; 7413 portid_t port_id; 7414 uint32_t reg_off; 7415 uint8_t bit_pos; 7416 }; 7417 7418 static void 7419 cmd_read_reg_bit_parsed(void *parsed_result, 7420 __attribute__((unused)) struct cmdline *cl, 7421 __attribute__((unused)) void *data) 7422 { 7423 struct cmd_read_reg_bit_result *res = parsed_result; 7424 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos); 7425 } 7426 7427 cmdline_parse_token_string_t cmd_read_reg_bit_read = 7428 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read"); 7429 cmdline_parse_token_string_t cmd_read_reg_bit_regbit = 7430 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, 7431 regbit, "regbit"); 7432 cmdline_parse_token_num_t cmd_read_reg_bit_port_id = 7433 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16); 7434 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off = 7435 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32); 7436 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos = 7437 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8); 7438 7439 cmdline_parse_inst_t cmd_read_reg_bit = { 7440 .f = cmd_read_reg_bit_parsed, 7441 .data = NULL, 7442 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31", 7443 .tokens = { 7444 (void *)&cmd_read_reg_bit_read, 7445 (void *)&cmd_read_reg_bit_regbit, 7446 (void *)&cmd_read_reg_bit_port_id, 7447 (void *)&cmd_read_reg_bit_reg_off, 7448 (void *)&cmd_read_reg_bit_bit_pos, 7449 NULL, 7450 }, 7451 }; 7452 7453 /* *** WRITE PORT REGISTER *** */ 7454 struct cmd_write_reg_result { 7455 cmdline_fixed_string_t write; 7456 cmdline_fixed_string_t reg; 7457 portid_t port_id; 7458 uint32_t reg_off; 7459 uint32_t value; 7460 }; 7461 7462 static void 7463 cmd_write_reg_parsed(void *parsed_result, 7464 __attribute__((unused)) struct cmdline *cl, 7465 __attribute__((unused)) void *data) 7466 { 7467 struct cmd_write_reg_result *res = parsed_result; 7468 port_reg_set(res->port_id, res->reg_off, res->value); 7469 } 7470 7471 cmdline_parse_token_string_t cmd_write_reg_write = 7472 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write"); 7473 cmdline_parse_token_string_t cmd_write_reg_reg = 7474 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg"); 7475 cmdline_parse_token_num_t cmd_write_reg_port_id = 7476 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16); 7477 cmdline_parse_token_num_t cmd_write_reg_reg_off = 7478 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32); 7479 cmdline_parse_token_num_t cmd_write_reg_value = 7480 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32); 7481 7482 cmdline_parse_inst_t cmd_write_reg = { 7483 .f = cmd_write_reg_parsed, 7484 .data = NULL, 7485 .help_str = "write reg <port_id> <reg_off> <reg_value>", 7486 .tokens = { 7487 (void *)&cmd_write_reg_write, 7488 (void *)&cmd_write_reg_reg, 7489 (void *)&cmd_write_reg_port_id, 7490 (void *)&cmd_write_reg_reg_off, 7491 (void *)&cmd_write_reg_value, 7492 NULL, 7493 }, 7494 }; 7495 7496 /* *** WRITE PORT REGISTER BIT FIELD *** */ 7497 struct cmd_write_reg_bit_field_result { 7498 cmdline_fixed_string_t write; 7499 cmdline_fixed_string_t regfield; 7500 portid_t port_id; 7501 uint32_t reg_off; 7502 uint8_t bit1_pos; 7503 uint8_t bit2_pos; 7504 uint32_t value; 7505 }; 7506 7507 static void 7508 cmd_write_reg_bit_field_parsed(void *parsed_result, 7509 __attribute__((unused)) struct cmdline *cl, 7510 __attribute__((unused)) void *data) 7511 { 7512 struct cmd_write_reg_bit_field_result *res = parsed_result; 7513 port_reg_bit_field_set(res->port_id, res->reg_off, 7514 res->bit1_pos, res->bit2_pos, res->value); 7515 } 7516 7517 cmdline_parse_token_string_t cmd_write_reg_bit_field_write = 7518 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write, 7519 "write"); 7520 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield = 7521 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, 7522 regfield, "regfield"); 7523 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id = 7524 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id, 7525 UINT16); 7526 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off = 7527 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off, 7528 UINT32); 7529 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos = 7530 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos, 7531 UINT8); 7532 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos = 7533 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos, 7534 UINT8); 7535 cmdline_parse_token_num_t cmd_write_reg_bit_field_value = 7536 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value, 7537 UINT32); 7538 7539 cmdline_parse_inst_t cmd_write_reg_bit_field = { 7540 .f = cmd_write_reg_bit_field_parsed, 7541 .data = NULL, 7542 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> " 7543 "<reg_value>: " 7544 "Set register bit field between bit_x and bit_y included", 7545 .tokens = { 7546 (void *)&cmd_write_reg_bit_field_write, 7547 (void *)&cmd_write_reg_bit_field_regfield, 7548 (void *)&cmd_write_reg_bit_field_port_id, 7549 (void *)&cmd_write_reg_bit_field_reg_off, 7550 (void *)&cmd_write_reg_bit_field_bit1_pos, 7551 (void *)&cmd_write_reg_bit_field_bit2_pos, 7552 (void *)&cmd_write_reg_bit_field_value, 7553 NULL, 7554 }, 7555 }; 7556 7557 /* *** WRITE PORT REGISTER BIT *** */ 7558 struct cmd_write_reg_bit_result { 7559 cmdline_fixed_string_t write; 7560 cmdline_fixed_string_t regbit; 7561 portid_t port_id; 7562 uint32_t reg_off; 7563 uint8_t bit_pos; 7564 uint8_t value; 7565 }; 7566 7567 static void 7568 cmd_write_reg_bit_parsed(void *parsed_result, 7569 __attribute__((unused)) struct cmdline *cl, 7570 __attribute__((unused)) void *data) 7571 { 7572 struct cmd_write_reg_bit_result *res = parsed_result; 7573 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value); 7574 } 7575 7576 cmdline_parse_token_string_t cmd_write_reg_bit_write = 7577 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write, 7578 "write"); 7579 cmdline_parse_token_string_t cmd_write_reg_bit_regbit = 7580 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, 7581 regbit, "regbit"); 7582 cmdline_parse_token_num_t cmd_write_reg_bit_port_id = 7583 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16); 7584 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off = 7585 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32); 7586 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos = 7587 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8); 7588 cmdline_parse_token_num_t cmd_write_reg_bit_value = 7589 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8); 7590 7591 cmdline_parse_inst_t cmd_write_reg_bit = { 7592 .f = cmd_write_reg_bit_parsed, 7593 .data = NULL, 7594 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: " 7595 "0 <= bit_x <= 31", 7596 .tokens = { 7597 (void *)&cmd_write_reg_bit_write, 7598 (void *)&cmd_write_reg_bit_regbit, 7599 (void *)&cmd_write_reg_bit_port_id, 7600 (void *)&cmd_write_reg_bit_reg_off, 7601 (void *)&cmd_write_reg_bit_bit_pos, 7602 (void *)&cmd_write_reg_bit_value, 7603 NULL, 7604 }, 7605 }; 7606 7607 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */ 7608 struct cmd_read_rxd_txd_result { 7609 cmdline_fixed_string_t read; 7610 cmdline_fixed_string_t rxd_txd; 7611 portid_t port_id; 7612 uint16_t queue_id; 7613 uint16_t desc_id; 7614 }; 7615 7616 static void 7617 cmd_read_rxd_txd_parsed(void *parsed_result, 7618 __attribute__((unused)) struct cmdline *cl, 7619 __attribute__((unused)) void *data) 7620 { 7621 struct cmd_read_rxd_txd_result *res = parsed_result; 7622 7623 if (!strcmp(res->rxd_txd, "rxd")) 7624 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7625 else if (!strcmp(res->rxd_txd, "txd")) 7626 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7627 } 7628 7629 cmdline_parse_token_string_t cmd_read_rxd_txd_read = 7630 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read"); 7631 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd = 7632 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd, 7633 "rxd#txd"); 7634 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id = 7635 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16); 7636 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id = 7637 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16); 7638 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id = 7639 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16); 7640 7641 cmdline_parse_inst_t cmd_read_rxd_txd = { 7642 .f = cmd_read_rxd_txd_parsed, 7643 .data = NULL, 7644 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>", 7645 .tokens = { 7646 (void *)&cmd_read_rxd_txd_read, 7647 (void *)&cmd_read_rxd_txd_rxd_txd, 7648 (void *)&cmd_read_rxd_txd_port_id, 7649 (void *)&cmd_read_rxd_txd_queue_id, 7650 (void *)&cmd_read_rxd_txd_desc_id, 7651 NULL, 7652 }, 7653 }; 7654 7655 /* *** QUIT *** */ 7656 struct cmd_quit_result { 7657 cmdline_fixed_string_t quit; 7658 }; 7659 7660 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result, 7661 struct cmdline *cl, 7662 __attribute__((unused)) void *data) 7663 { 7664 pmd_test_exit(); 7665 cmdline_quit(cl); 7666 } 7667 7668 cmdline_parse_token_string_t cmd_quit_quit = 7669 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit"); 7670 7671 cmdline_parse_inst_t cmd_quit = { 7672 .f = cmd_quit_parsed, 7673 .data = NULL, 7674 .help_str = "quit: Exit application", 7675 .tokens = { 7676 (void *)&cmd_quit_quit, 7677 NULL, 7678 }, 7679 }; 7680 7681 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */ 7682 struct cmd_mac_addr_result { 7683 cmdline_fixed_string_t mac_addr_cmd; 7684 cmdline_fixed_string_t what; 7685 uint16_t port_num; 7686 struct ether_addr address; 7687 }; 7688 7689 static void cmd_mac_addr_parsed(void *parsed_result, 7690 __attribute__((unused)) struct cmdline *cl, 7691 __attribute__((unused)) void *data) 7692 { 7693 struct cmd_mac_addr_result *res = parsed_result; 7694 int ret; 7695 7696 if (strcmp(res->what, "add") == 0) 7697 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0); 7698 else if (strcmp(res->what, "set") == 0) 7699 ret = rte_eth_dev_default_mac_addr_set(res->port_num, 7700 &res->address); 7701 else 7702 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address); 7703 7704 /* check the return value and print it if is < 0 */ 7705 if(ret < 0) 7706 printf("mac_addr_cmd error: (%s)\n", strerror(-ret)); 7707 7708 } 7709 7710 cmdline_parse_token_string_t cmd_mac_addr_cmd = 7711 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd, 7712 "mac_addr"); 7713 cmdline_parse_token_string_t cmd_mac_addr_what = 7714 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what, 7715 "add#remove#set"); 7716 cmdline_parse_token_num_t cmd_mac_addr_portnum = 7717 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, 7718 UINT16); 7719 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr = 7720 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 7721 7722 cmdline_parse_inst_t cmd_mac_addr = { 7723 .f = cmd_mac_addr_parsed, 7724 .data = (void *)0, 7725 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: " 7726 "Add/Remove/Set MAC address on port_id", 7727 .tokens = { 7728 (void *)&cmd_mac_addr_cmd, 7729 (void *)&cmd_mac_addr_what, 7730 (void *)&cmd_mac_addr_portnum, 7731 (void *)&cmd_mac_addr_addr, 7732 NULL, 7733 }, 7734 }; 7735 7736 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */ 7737 struct cmd_eth_peer_result { 7738 cmdline_fixed_string_t set; 7739 cmdline_fixed_string_t eth_peer; 7740 portid_t port_id; 7741 cmdline_fixed_string_t peer_addr; 7742 }; 7743 7744 static void cmd_set_eth_peer_parsed(void *parsed_result, 7745 __attribute__((unused)) struct cmdline *cl, 7746 __attribute__((unused)) void *data) 7747 { 7748 struct cmd_eth_peer_result *res = parsed_result; 7749 7750 if (test_done == 0) { 7751 printf("Please stop forwarding first\n"); 7752 return; 7753 } 7754 if (!strcmp(res->eth_peer, "eth-peer")) { 7755 set_fwd_eth_peer(res->port_id, res->peer_addr); 7756 fwd_config_setup(); 7757 } 7758 } 7759 cmdline_parse_token_string_t cmd_eth_peer_set = 7760 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set"); 7761 cmdline_parse_token_string_t cmd_eth_peer = 7762 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer"); 7763 cmdline_parse_token_num_t cmd_eth_peer_port_id = 7764 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16); 7765 cmdline_parse_token_string_t cmd_eth_peer_addr = 7766 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL); 7767 7768 cmdline_parse_inst_t cmd_set_fwd_eth_peer = { 7769 .f = cmd_set_eth_peer_parsed, 7770 .data = NULL, 7771 .help_str = "set eth-peer <port_id> <peer_mac>", 7772 .tokens = { 7773 (void *)&cmd_eth_peer_set, 7774 (void *)&cmd_eth_peer, 7775 (void *)&cmd_eth_peer_port_id, 7776 (void *)&cmd_eth_peer_addr, 7777 NULL, 7778 }, 7779 }; 7780 7781 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ 7782 struct cmd_set_qmap_result { 7783 cmdline_fixed_string_t set; 7784 cmdline_fixed_string_t qmap; 7785 cmdline_fixed_string_t what; 7786 portid_t port_id; 7787 uint16_t queue_id; 7788 uint8_t map_value; 7789 }; 7790 7791 static void 7792 cmd_set_qmap_parsed(void *parsed_result, 7793 __attribute__((unused)) struct cmdline *cl, 7794 __attribute__((unused)) void *data) 7795 { 7796 struct cmd_set_qmap_result *res = parsed_result; 7797 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1; 7798 7799 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value); 7800 } 7801 7802 cmdline_parse_token_string_t cmd_setqmap_set = 7803 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7804 set, "set"); 7805 cmdline_parse_token_string_t cmd_setqmap_qmap = 7806 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7807 qmap, "stat_qmap"); 7808 cmdline_parse_token_string_t cmd_setqmap_what = 7809 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7810 what, "tx#rx"); 7811 cmdline_parse_token_num_t cmd_setqmap_portid = 7812 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7813 port_id, UINT16); 7814 cmdline_parse_token_num_t cmd_setqmap_queueid = 7815 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7816 queue_id, UINT16); 7817 cmdline_parse_token_num_t cmd_setqmap_mapvalue = 7818 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7819 map_value, UINT8); 7820 7821 cmdline_parse_inst_t cmd_set_qmap = { 7822 .f = cmd_set_qmap_parsed, 7823 .data = NULL, 7824 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: " 7825 "Set statistics mapping value on tx|rx queue_id of port_id", 7826 .tokens = { 7827 (void *)&cmd_setqmap_set, 7828 (void *)&cmd_setqmap_qmap, 7829 (void *)&cmd_setqmap_what, 7830 (void *)&cmd_setqmap_portid, 7831 (void *)&cmd_setqmap_queueid, 7832 (void *)&cmd_setqmap_mapvalue, 7833 NULL, 7834 }, 7835 }; 7836 7837 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */ 7838 struct cmd_set_xstats_hide_zero_result { 7839 cmdline_fixed_string_t keyword; 7840 cmdline_fixed_string_t name; 7841 cmdline_fixed_string_t on_off; 7842 }; 7843 7844 static void 7845 cmd_set_xstats_hide_zero_parsed(void *parsed_result, 7846 __attribute__((unused)) struct cmdline *cl, 7847 __attribute__((unused)) void *data) 7848 { 7849 struct cmd_set_xstats_hide_zero_result *res; 7850 uint16_t on_off = 0; 7851 7852 res = parsed_result; 7853 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 7854 set_xstats_hide_zero(on_off); 7855 } 7856 7857 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword = 7858 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 7859 keyword, "set"); 7860 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name = 7861 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 7862 name, "xstats-hide-zero"); 7863 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off = 7864 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 7865 on_off, "on#off"); 7866 7867 cmdline_parse_inst_t cmd_set_xstats_hide_zero = { 7868 .f = cmd_set_xstats_hide_zero_parsed, 7869 .data = NULL, 7870 .help_str = "set xstats-hide-zero on|off", 7871 .tokens = { 7872 (void *)&cmd_set_xstats_hide_zero_keyword, 7873 (void *)&cmd_set_xstats_hide_zero_name, 7874 (void *)&cmd_set_xstats_hide_zero_on_off, 7875 NULL, 7876 }, 7877 }; 7878 7879 /* *** CONFIGURE UNICAST HASH TABLE *** */ 7880 struct cmd_set_uc_hash_table { 7881 cmdline_fixed_string_t set; 7882 cmdline_fixed_string_t port; 7883 portid_t port_id; 7884 cmdline_fixed_string_t what; 7885 struct ether_addr address; 7886 cmdline_fixed_string_t mode; 7887 }; 7888 7889 static void 7890 cmd_set_uc_hash_parsed(void *parsed_result, 7891 __attribute__((unused)) struct cmdline *cl, 7892 __attribute__((unused)) void *data) 7893 { 7894 int ret=0; 7895 struct cmd_set_uc_hash_table *res = parsed_result; 7896 7897 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 7898 7899 if (strcmp(res->what, "uta") == 0) 7900 ret = rte_eth_dev_uc_hash_table_set(res->port_id, 7901 &res->address,(uint8_t)is_on); 7902 if (ret < 0) 7903 printf("bad unicast hash table parameter, return code = %d \n", ret); 7904 7905 } 7906 7907 cmdline_parse_token_string_t cmd_set_uc_hash_set = 7908 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 7909 set, "set"); 7910 cmdline_parse_token_string_t cmd_set_uc_hash_port = 7911 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 7912 port, "port"); 7913 cmdline_parse_token_num_t cmd_set_uc_hash_portid = 7914 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table, 7915 port_id, UINT16); 7916 cmdline_parse_token_string_t cmd_set_uc_hash_what = 7917 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 7918 what, "uta"); 7919 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac = 7920 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table, 7921 address); 7922 cmdline_parse_token_string_t cmd_set_uc_hash_mode = 7923 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 7924 mode, "on#off"); 7925 7926 cmdline_parse_inst_t cmd_set_uc_hash_filter = { 7927 .f = cmd_set_uc_hash_parsed, 7928 .data = NULL, 7929 .help_str = "set port <port_id> uta <mac_addr> on|off)", 7930 .tokens = { 7931 (void *)&cmd_set_uc_hash_set, 7932 (void *)&cmd_set_uc_hash_port, 7933 (void *)&cmd_set_uc_hash_portid, 7934 (void *)&cmd_set_uc_hash_what, 7935 (void *)&cmd_set_uc_hash_mac, 7936 (void *)&cmd_set_uc_hash_mode, 7937 NULL, 7938 }, 7939 }; 7940 7941 struct cmd_set_uc_all_hash_table { 7942 cmdline_fixed_string_t set; 7943 cmdline_fixed_string_t port; 7944 portid_t port_id; 7945 cmdline_fixed_string_t what; 7946 cmdline_fixed_string_t value; 7947 cmdline_fixed_string_t mode; 7948 }; 7949 7950 static void 7951 cmd_set_uc_all_hash_parsed(void *parsed_result, 7952 __attribute__((unused)) struct cmdline *cl, 7953 __attribute__((unused)) void *data) 7954 { 7955 int ret=0; 7956 struct cmd_set_uc_all_hash_table *res = parsed_result; 7957 7958 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 7959 7960 if ((strcmp(res->what, "uta") == 0) && 7961 (strcmp(res->value, "all") == 0)) 7962 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on); 7963 if (ret < 0) 7964 printf("bad unicast hash table parameter," 7965 "return code = %d \n", ret); 7966 } 7967 7968 cmdline_parse_token_string_t cmd_set_uc_all_hash_set = 7969 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7970 set, "set"); 7971 cmdline_parse_token_string_t cmd_set_uc_all_hash_port = 7972 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7973 port, "port"); 7974 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid = 7975 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table, 7976 port_id, UINT16); 7977 cmdline_parse_token_string_t cmd_set_uc_all_hash_what = 7978 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7979 what, "uta"); 7980 cmdline_parse_token_string_t cmd_set_uc_all_hash_value = 7981 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7982 value,"all"); 7983 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode = 7984 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 7985 mode, "on#off"); 7986 7987 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = { 7988 .f = cmd_set_uc_all_hash_parsed, 7989 .data = NULL, 7990 .help_str = "set port <port_id> uta all on|off", 7991 .tokens = { 7992 (void *)&cmd_set_uc_all_hash_set, 7993 (void *)&cmd_set_uc_all_hash_port, 7994 (void *)&cmd_set_uc_all_hash_portid, 7995 (void *)&cmd_set_uc_all_hash_what, 7996 (void *)&cmd_set_uc_all_hash_value, 7997 (void *)&cmd_set_uc_all_hash_mode, 7998 NULL, 7999 }, 8000 }; 8001 8002 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */ 8003 struct cmd_set_vf_macvlan_filter { 8004 cmdline_fixed_string_t set; 8005 cmdline_fixed_string_t port; 8006 portid_t port_id; 8007 cmdline_fixed_string_t vf; 8008 uint8_t vf_id; 8009 struct ether_addr address; 8010 cmdline_fixed_string_t filter_type; 8011 cmdline_fixed_string_t mode; 8012 }; 8013 8014 static void 8015 cmd_set_vf_macvlan_parsed(void *parsed_result, 8016 __attribute__((unused)) struct cmdline *cl, 8017 __attribute__((unused)) void *data) 8018 { 8019 int is_on, ret = 0; 8020 struct cmd_set_vf_macvlan_filter *res = parsed_result; 8021 struct rte_eth_mac_filter filter; 8022 8023 memset(&filter, 0, sizeof(struct rte_eth_mac_filter)); 8024 8025 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN); 8026 8027 /* set VF MAC filter */ 8028 filter.is_vf = 1; 8029 8030 /* set VF ID */ 8031 filter.dst_id = res->vf_id; 8032 8033 if (!strcmp(res->filter_type, "exact-mac")) 8034 filter.filter_type = RTE_MAC_PERFECT_MATCH; 8035 else if (!strcmp(res->filter_type, "exact-mac-vlan")) 8036 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH; 8037 else if (!strcmp(res->filter_type, "hashmac")) 8038 filter.filter_type = RTE_MAC_HASH_MATCH; 8039 else if (!strcmp(res->filter_type, "hashmac-vlan")) 8040 filter.filter_type = RTE_MACVLAN_HASH_MATCH; 8041 8042 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8043 8044 if (is_on) 8045 ret = rte_eth_dev_filter_ctrl(res->port_id, 8046 RTE_ETH_FILTER_MACVLAN, 8047 RTE_ETH_FILTER_ADD, 8048 &filter); 8049 else 8050 ret = rte_eth_dev_filter_ctrl(res->port_id, 8051 RTE_ETH_FILTER_MACVLAN, 8052 RTE_ETH_FILTER_DELETE, 8053 &filter); 8054 8055 if (ret < 0) 8056 printf("bad set MAC hash parameter, return code = %d\n", ret); 8057 8058 } 8059 8060 cmdline_parse_token_string_t cmd_set_vf_macvlan_set = 8061 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8062 set, "set"); 8063 cmdline_parse_token_string_t cmd_set_vf_macvlan_port = 8064 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8065 port, "port"); 8066 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid = 8067 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8068 port_id, UINT16); 8069 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf = 8070 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8071 vf, "vf"); 8072 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id = 8073 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8074 vf_id, UINT8); 8075 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac = 8076 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8077 address); 8078 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type = 8079 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8080 filter_type, "exact-mac#exact-mac-vlan" 8081 "#hashmac#hashmac-vlan"); 8082 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode = 8083 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8084 mode, "on#off"); 8085 8086 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = { 8087 .f = cmd_set_vf_macvlan_parsed, 8088 .data = NULL, 8089 .help_str = "set port <port_id> vf <vf_id> <mac_addr> " 8090 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: " 8091 "Exact match rule: exact match of MAC or MAC and VLAN; " 8092 "hash match rule: hash match of MAC and exact match of VLAN", 8093 .tokens = { 8094 (void *)&cmd_set_vf_macvlan_set, 8095 (void *)&cmd_set_vf_macvlan_port, 8096 (void *)&cmd_set_vf_macvlan_portid, 8097 (void *)&cmd_set_vf_macvlan_vf, 8098 (void *)&cmd_set_vf_macvlan_vf_id, 8099 (void *)&cmd_set_vf_macvlan_mac, 8100 (void *)&cmd_set_vf_macvlan_filter_type, 8101 (void *)&cmd_set_vf_macvlan_mode, 8102 NULL, 8103 }, 8104 }; 8105 8106 /* *** CONFIGURE VF TRAFFIC CONTROL *** */ 8107 struct cmd_set_vf_traffic { 8108 cmdline_fixed_string_t set; 8109 cmdline_fixed_string_t port; 8110 portid_t port_id; 8111 cmdline_fixed_string_t vf; 8112 uint8_t vf_id; 8113 cmdline_fixed_string_t what; 8114 cmdline_fixed_string_t mode; 8115 }; 8116 8117 static void 8118 cmd_set_vf_traffic_parsed(void *parsed_result, 8119 __attribute__((unused)) struct cmdline *cl, 8120 __attribute__((unused)) void *data) 8121 { 8122 struct cmd_set_vf_traffic *res = parsed_result; 8123 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0; 8124 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8125 8126 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on); 8127 } 8128 8129 cmdline_parse_token_string_t cmd_setvf_traffic_set = 8130 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8131 set, "set"); 8132 cmdline_parse_token_string_t cmd_setvf_traffic_port = 8133 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8134 port, "port"); 8135 cmdline_parse_token_num_t cmd_setvf_traffic_portid = 8136 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8137 port_id, UINT16); 8138 cmdline_parse_token_string_t cmd_setvf_traffic_vf = 8139 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8140 vf, "vf"); 8141 cmdline_parse_token_num_t cmd_setvf_traffic_vfid = 8142 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8143 vf_id, UINT8); 8144 cmdline_parse_token_string_t cmd_setvf_traffic_what = 8145 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8146 what, "tx#rx"); 8147 cmdline_parse_token_string_t cmd_setvf_traffic_mode = 8148 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8149 mode, "on#off"); 8150 8151 cmdline_parse_inst_t cmd_set_vf_traffic = { 8152 .f = cmd_set_vf_traffic_parsed, 8153 .data = NULL, 8154 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off", 8155 .tokens = { 8156 (void *)&cmd_setvf_traffic_set, 8157 (void *)&cmd_setvf_traffic_port, 8158 (void *)&cmd_setvf_traffic_portid, 8159 (void *)&cmd_setvf_traffic_vf, 8160 (void *)&cmd_setvf_traffic_vfid, 8161 (void *)&cmd_setvf_traffic_what, 8162 (void *)&cmd_setvf_traffic_mode, 8163 NULL, 8164 }, 8165 }; 8166 8167 /* *** CONFIGURE VF RECEIVE MODE *** */ 8168 struct cmd_set_vf_rxmode { 8169 cmdline_fixed_string_t set; 8170 cmdline_fixed_string_t port; 8171 portid_t port_id; 8172 cmdline_fixed_string_t vf; 8173 uint8_t vf_id; 8174 cmdline_fixed_string_t what; 8175 cmdline_fixed_string_t mode; 8176 cmdline_fixed_string_t on; 8177 }; 8178 8179 static void 8180 cmd_set_vf_rxmode_parsed(void *parsed_result, 8181 __attribute__((unused)) struct cmdline *cl, 8182 __attribute__((unused)) void *data) 8183 { 8184 int ret = -ENOTSUP; 8185 uint16_t rx_mode = 0; 8186 struct cmd_set_vf_rxmode *res = parsed_result; 8187 8188 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0; 8189 if (!strcmp(res->what,"rxmode")) { 8190 if (!strcmp(res->mode, "AUPE")) 8191 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG; 8192 else if (!strcmp(res->mode, "ROPE")) 8193 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC; 8194 else if (!strcmp(res->mode, "BAM")) 8195 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST; 8196 else if (!strncmp(res->mode, "MPE",3)) 8197 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST; 8198 } 8199 8200 RTE_SET_USED(is_on); 8201 8202 #ifdef RTE_LIBRTE_IXGBE_PMD 8203 if (ret == -ENOTSUP) 8204 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, 8205 rx_mode, (uint8_t)is_on); 8206 #endif 8207 #ifdef RTE_LIBRTE_BNXT_PMD 8208 if (ret == -ENOTSUP) 8209 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id, 8210 rx_mode, (uint8_t)is_on); 8211 #endif 8212 if (ret < 0) 8213 printf("bad VF receive mode parameter, return code = %d \n", 8214 ret); 8215 } 8216 8217 cmdline_parse_token_string_t cmd_set_vf_rxmode_set = 8218 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8219 set, "set"); 8220 cmdline_parse_token_string_t cmd_set_vf_rxmode_port = 8221 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8222 port, "port"); 8223 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid = 8224 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8225 port_id, UINT16); 8226 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf = 8227 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8228 vf, "vf"); 8229 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid = 8230 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8231 vf_id, UINT8); 8232 cmdline_parse_token_string_t cmd_set_vf_rxmode_what = 8233 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8234 what, "rxmode"); 8235 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode = 8236 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8237 mode, "AUPE#ROPE#BAM#MPE"); 8238 cmdline_parse_token_string_t cmd_set_vf_rxmode_on = 8239 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8240 on, "on#off"); 8241 8242 cmdline_parse_inst_t cmd_set_vf_rxmode = { 8243 .f = cmd_set_vf_rxmode_parsed, 8244 .data = NULL, 8245 .help_str = "set port <port_id> vf <vf_id> rxmode " 8246 "AUPE|ROPE|BAM|MPE on|off", 8247 .tokens = { 8248 (void *)&cmd_set_vf_rxmode_set, 8249 (void *)&cmd_set_vf_rxmode_port, 8250 (void *)&cmd_set_vf_rxmode_portid, 8251 (void *)&cmd_set_vf_rxmode_vf, 8252 (void *)&cmd_set_vf_rxmode_vfid, 8253 (void *)&cmd_set_vf_rxmode_what, 8254 (void *)&cmd_set_vf_rxmode_mode, 8255 (void *)&cmd_set_vf_rxmode_on, 8256 NULL, 8257 }, 8258 }; 8259 8260 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */ 8261 struct cmd_vf_mac_addr_result { 8262 cmdline_fixed_string_t mac_addr_cmd; 8263 cmdline_fixed_string_t what; 8264 cmdline_fixed_string_t port; 8265 uint16_t port_num; 8266 cmdline_fixed_string_t vf; 8267 uint8_t vf_num; 8268 struct ether_addr address; 8269 }; 8270 8271 static void cmd_vf_mac_addr_parsed(void *parsed_result, 8272 __attribute__((unused)) struct cmdline *cl, 8273 __attribute__((unused)) void *data) 8274 { 8275 struct cmd_vf_mac_addr_result *res = parsed_result; 8276 int ret = -ENOTSUP; 8277 8278 if (strcmp(res->what, "add") != 0) 8279 return; 8280 8281 #ifdef RTE_LIBRTE_I40E_PMD 8282 if (ret == -ENOTSUP) 8283 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num, 8284 &res->address); 8285 #endif 8286 #ifdef RTE_LIBRTE_BNXT_PMD 8287 if (ret == -ENOTSUP) 8288 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address, 8289 res->vf_num); 8290 #endif 8291 8292 if(ret < 0) 8293 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret)); 8294 8295 } 8296 8297 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd = 8298 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8299 mac_addr_cmd,"mac_addr"); 8300 cmdline_parse_token_string_t cmd_vf_mac_addr_what = 8301 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8302 what,"add"); 8303 cmdline_parse_token_string_t cmd_vf_mac_addr_port = 8304 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8305 port,"port"); 8306 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum = 8307 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8308 port_num, UINT16); 8309 cmdline_parse_token_string_t cmd_vf_mac_addr_vf = 8310 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8311 vf,"vf"); 8312 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum = 8313 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8314 vf_num, UINT8); 8315 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr = 8316 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result, 8317 address); 8318 8319 cmdline_parse_inst_t cmd_vf_mac_addr_filter = { 8320 .f = cmd_vf_mac_addr_parsed, 8321 .data = (void *)0, 8322 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: " 8323 "Add MAC address filtering for a VF on port_id", 8324 .tokens = { 8325 (void *)&cmd_vf_mac_addr_cmd, 8326 (void *)&cmd_vf_mac_addr_what, 8327 (void *)&cmd_vf_mac_addr_port, 8328 (void *)&cmd_vf_mac_addr_portnum, 8329 (void *)&cmd_vf_mac_addr_vf, 8330 (void *)&cmd_vf_mac_addr_vfnum, 8331 (void *)&cmd_vf_mac_addr_addr, 8332 NULL, 8333 }, 8334 }; 8335 8336 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 8337 struct cmd_vf_rx_vlan_filter { 8338 cmdline_fixed_string_t rx_vlan; 8339 cmdline_fixed_string_t what; 8340 uint16_t vlan_id; 8341 cmdline_fixed_string_t port; 8342 portid_t port_id; 8343 cmdline_fixed_string_t vf; 8344 uint64_t vf_mask; 8345 }; 8346 8347 static void 8348 cmd_vf_rx_vlan_filter_parsed(void *parsed_result, 8349 __attribute__((unused)) struct cmdline *cl, 8350 __attribute__((unused)) void *data) 8351 { 8352 struct cmd_vf_rx_vlan_filter *res = parsed_result; 8353 int ret = -ENOTSUP; 8354 8355 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0; 8356 8357 #ifdef RTE_LIBRTE_IXGBE_PMD 8358 if (ret == -ENOTSUP) 8359 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id, 8360 res->vlan_id, res->vf_mask, is_add); 8361 #endif 8362 #ifdef RTE_LIBRTE_I40E_PMD 8363 if (ret == -ENOTSUP) 8364 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id, 8365 res->vlan_id, res->vf_mask, is_add); 8366 #endif 8367 #ifdef RTE_LIBRTE_BNXT_PMD 8368 if (ret == -ENOTSUP) 8369 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id, 8370 res->vlan_id, res->vf_mask, is_add); 8371 #endif 8372 8373 switch (ret) { 8374 case 0: 8375 break; 8376 case -EINVAL: 8377 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n", 8378 res->vlan_id, res->vf_mask); 8379 break; 8380 case -ENODEV: 8381 printf("invalid port_id %d\n", res->port_id); 8382 break; 8383 case -ENOTSUP: 8384 printf("function not implemented or supported\n"); 8385 break; 8386 default: 8387 printf("programming error: (%s)\n", strerror(-ret)); 8388 } 8389 } 8390 8391 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan = 8392 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8393 rx_vlan, "rx_vlan"); 8394 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what = 8395 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8396 what, "add#rm"); 8397 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid = 8398 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8399 vlan_id, UINT16); 8400 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port = 8401 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8402 port, "port"); 8403 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid = 8404 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8405 port_id, UINT16); 8406 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf = 8407 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8408 vf, "vf"); 8409 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask = 8410 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8411 vf_mask, UINT64); 8412 8413 cmdline_parse_inst_t cmd_vf_rxvlan_filter = { 8414 .f = cmd_vf_rx_vlan_filter_parsed, 8415 .data = NULL, 8416 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: " 8417 "(vf_mask = hexadecimal VF mask)", 8418 .tokens = { 8419 (void *)&cmd_vf_rx_vlan_filter_rx_vlan, 8420 (void *)&cmd_vf_rx_vlan_filter_what, 8421 (void *)&cmd_vf_rx_vlan_filter_vlanid, 8422 (void *)&cmd_vf_rx_vlan_filter_port, 8423 (void *)&cmd_vf_rx_vlan_filter_portid, 8424 (void *)&cmd_vf_rx_vlan_filter_vf, 8425 (void *)&cmd_vf_rx_vlan_filter_vf_mask, 8426 NULL, 8427 }, 8428 }; 8429 8430 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */ 8431 struct cmd_queue_rate_limit_result { 8432 cmdline_fixed_string_t set; 8433 cmdline_fixed_string_t port; 8434 uint16_t port_num; 8435 cmdline_fixed_string_t queue; 8436 uint8_t queue_num; 8437 cmdline_fixed_string_t rate; 8438 uint16_t rate_num; 8439 }; 8440 8441 static void cmd_queue_rate_limit_parsed(void *parsed_result, 8442 __attribute__((unused)) struct cmdline *cl, 8443 __attribute__((unused)) void *data) 8444 { 8445 struct cmd_queue_rate_limit_result *res = parsed_result; 8446 int ret = 0; 8447 8448 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8449 && (strcmp(res->queue, "queue") == 0) 8450 && (strcmp(res->rate, "rate") == 0)) 8451 ret = set_queue_rate_limit(res->port_num, res->queue_num, 8452 res->rate_num); 8453 if (ret < 0) 8454 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8455 8456 } 8457 8458 cmdline_parse_token_string_t cmd_queue_rate_limit_set = 8459 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8460 set, "set"); 8461 cmdline_parse_token_string_t cmd_queue_rate_limit_port = 8462 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8463 port, "port"); 8464 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum = 8465 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8466 port_num, UINT16); 8467 cmdline_parse_token_string_t cmd_queue_rate_limit_queue = 8468 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8469 queue, "queue"); 8470 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum = 8471 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8472 queue_num, UINT8); 8473 cmdline_parse_token_string_t cmd_queue_rate_limit_rate = 8474 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8475 rate, "rate"); 8476 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum = 8477 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8478 rate_num, UINT16); 8479 8480 cmdline_parse_inst_t cmd_queue_rate_limit = { 8481 .f = cmd_queue_rate_limit_parsed, 8482 .data = (void *)0, 8483 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: " 8484 "Set rate limit for a queue on port_id", 8485 .tokens = { 8486 (void *)&cmd_queue_rate_limit_set, 8487 (void *)&cmd_queue_rate_limit_port, 8488 (void *)&cmd_queue_rate_limit_portnum, 8489 (void *)&cmd_queue_rate_limit_queue, 8490 (void *)&cmd_queue_rate_limit_queuenum, 8491 (void *)&cmd_queue_rate_limit_rate, 8492 (void *)&cmd_queue_rate_limit_ratenum, 8493 NULL, 8494 }, 8495 }; 8496 8497 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */ 8498 struct cmd_vf_rate_limit_result { 8499 cmdline_fixed_string_t set; 8500 cmdline_fixed_string_t port; 8501 uint16_t port_num; 8502 cmdline_fixed_string_t vf; 8503 uint8_t vf_num; 8504 cmdline_fixed_string_t rate; 8505 uint16_t rate_num; 8506 cmdline_fixed_string_t q_msk; 8507 uint64_t q_msk_val; 8508 }; 8509 8510 static void cmd_vf_rate_limit_parsed(void *parsed_result, 8511 __attribute__((unused)) struct cmdline *cl, 8512 __attribute__((unused)) void *data) 8513 { 8514 struct cmd_vf_rate_limit_result *res = parsed_result; 8515 int ret = 0; 8516 8517 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8518 && (strcmp(res->vf, "vf") == 0) 8519 && (strcmp(res->rate, "rate") == 0) 8520 && (strcmp(res->q_msk, "queue_mask") == 0)) 8521 ret = set_vf_rate_limit(res->port_num, res->vf_num, 8522 res->rate_num, res->q_msk_val); 8523 if (ret < 0) 8524 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8525 8526 } 8527 8528 cmdline_parse_token_string_t cmd_vf_rate_limit_set = 8529 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8530 set, "set"); 8531 cmdline_parse_token_string_t cmd_vf_rate_limit_port = 8532 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8533 port, "port"); 8534 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum = 8535 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8536 port_num, UINT16); 8537 cmdline_parse_token_string_t cmd_vf_rate_limit_vf = 8538 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8539 vf, "vf"); 8540 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum = 8541 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8542 vf_num, UINT8); 8543 cmdline_parse_token_string_t cmd_vf_rate_limit_rate = 8544 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8545 rate, "rate"); 8546 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum = 8547 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8548 rate_num, UINT16); 8549 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk = 8550 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8551 q_msk, "queue_mask"); 8552 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val = 8553 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8554 q_msk_val, UINT64); 8555 8556 cmdline_parse_inst_t cmd_vf_rate_limit = { 8557 .f = cmd_vf_rate_limit_parsed, 8558 .data = (void *)0, 8559 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> " 8560 "queue_mask <queue_mask_value>: " 8561 "Set rate limit for queues of VF on port_id", 8562 .tokens = { 8563 (void *)&cmd_vf_rate_limit_set, 8564 (void *)&cmd_vf_rate_limit_port, 8565 (void *)&cmd_vf_rate_limit_portnum, 8566 (void *)&cmd_vf_rate_limit_vf, 8567 (void *)&cmd_vf_rate_limit_vfnum, 8568 (void *)&cmd_vf_rate_limit_rate, 8569 (void *)&cmd_vf_rate_limit_ratenum, 8570 (void *)&cmd_vf_rate_limit_q_msk, 8571 (void *)&cmd_vf_rate_limit_q_msk_val, 8572 NULL, 8573 }, 8574 }; 8575 8576 /* *** ADD TUNNEL FILTER OF A PORT *** */ 8577 struct cmd_tunnel_filter_result { 8578 cmdline_fixed_string_t cmd; 8579 cmdline_fixed_string_t what; 8580 portid_t port_id; 8581 struct ether_addr outer_mac; 8582 struct ether_addr inner_mac; 8583 cmdline_ipaddr_t ip_value; 8584 uint16_t inner_vlan; 8585 cmdline_fixed_string_t tunnel_type; 8586 cmdline_fixed_string_t filter_type; 8587 uint32_t tenant_id; 8588 uint16_t queue_num; 8589 }; 8590 8591 static void 8592 cmd_tunnel_filter_parsed(void *parsed_result, 8593 __attribute__((unused)) struct cmdline *cl, 8594 __attribute__((unused)) void *data) 8595 { 8596 struct cmd_tunnel_filter_result *res = parsed_result; 8597 struct rte_eth_tunnel_filter_conf tunnel_filter_conf; 8598 int ret = 0; 8599 8600 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf)); 8601 8602 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac); 8603 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac); 8604 tunnel_filter_conf.inner_vlan = res->inner_vlan; 8605 8606 if (res->ip_value.family == AF_INET) { 8607 tunnel_filter_conf.ip_addr.ipv4_addr = 8608 res->ip_value.addr.ipv4.s_addr; 8609 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4; 8610 } else { 8611 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr), 8612 &(res->ip_value.addr.ipv6), 8613 sizeof(struct in6_addr)); 8614 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6; 8615 } 8616 8617 if (!strcmp(res->filter_type, "imac-ivlan")) 8618 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN; 8619 else if (!strcmp(res->filter_type, "imac-ivlan-tenid")) 8620 tunnel_filter_conf.filter_type = 8621 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID; 8622 else if (!strcmp(res->filter_type, "imac-tenid")) 8623 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID; 8624 else if (!strcmp(res->filter_type, "imac")) 8625 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC; 8626 else if (!strcmp(res->filter_type, "omac-imac-tenid")) 8627 tunnel_filter_conf.filter_type = 8628 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC; 8629 else if (!strcmp(res->filter_type, "oip")) 8630 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP; 8631 else if (!strcmp(res->filter_type, "iip")) 8632 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP; 8633 else { 8634 printf("The filter type is not supported"); 8635 return; 8636 } 8637 8638 if (!strcmp(res->tunnel_type, "vxlan")) 8639 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN; 8640 else if (!strcmp(res->tunnel_type, "nvgre")) 8641 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE; 8642 else if (!strcmp(res->tunnel_type, "ipingre")) 8643 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE; 8644 else { 8645 printf("The tunnel type %s not supported.\n", res->tunnel_type); 8646 return; 8647 } 8648 8649 tunnel_filter_conf.tenant_id = res->tenant_id; 8650 tunnel_filter_conf.queue_id = res->queue_num; 8651 if (!strcmp(res->what, "add")) 8652 ret = rte_eth_dev_filter_ctrl(res->port_id, 8653 RTE_ETH_FILTER_TUNNEL, 8654 RTE_ETH_FILTER_ADD, 8655 &tunnel_filter_conf); 8656 else 8657 ret = rte_eth_dev_filter_ctrl(res->port_id, 8658 RTE_ETH_FILTER_TUNNEL, 8659 RTE_ETH_FILTER_DELETE, 8660 &tunnel_filter_conf); 8661 if (ret < 0) 8662 printf("cmd_tunnel_filter_parsed error: (%s)\n", 8663 strerror(-ret)); 8664 8665 } 8666 cmdline_parse_token_string_t cmd_tunnel_filter_cmd = 8667 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8668 cmd, "tunnel_filter"); 8669 cmdline_parse_token_string_t cmd_tunnel_filter_what = 8670 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8671 what, "add#rm"); 8672 cmdline_parse_token_num_t cmd_tunnel_filter_port_id = 8673 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8674 port_id, UINT16); 8675 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac = 8676 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8677 outer_mac); 8678 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac = 8679 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8680 inner_mac); 8681 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan = 8682 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8683 inner_vlan, UINT16); 8684 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value = 8685 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8686 ip_value); 8687 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type = 8688 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8689 tunnel_type, "vxlan#nvgre#ipingre"); 8690 8691 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type = 8692 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8693 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#" 8694 "imac#omac-imac-tenid"); 8695 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id = 8696 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8697 tenant_id, UINT32); 8698 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num = 8699 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8700 queue_num, UINT16); 8701 8702 cmdline_parse_inst_t cmd_tunnel_filter = { 8703 .f = cmd_tunnel_filter_parsed, 8704 .data = (void *)0, 8705 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> " 8706 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|" 8707 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> " 8708 "<queue_id>: Add/Rm tunnel filter of a port", 8709 .tokens = { 8710 (void *)&cmd_tunnel_filter_cmd, 8711 (void *)&cmd_tunnel_filter_what, 8712 (void *)&cmd_tunnel_filter_port_id, 8713 (void *)&cmd_tunnel_filter_outer_mac, 8714 (void *)&cmd_tunnel_filter_inner_mac, 8715 (void *)&cmd_tunnel_filter_ip_value, 8716 (void *)&cmd_tunnel_filter_innner_vlan, 8717 (void *)&cmd_tunnel_filter_tunnel_type, 8718 (void *)&cmd_tunnel_filter_filter_type, 8719 (void *)&cmd_tunnel_filter_tenant_id, 8720 (void *)&cmd_tunnel_filter_queue_num, 8721 NULL, 8722 }, 8723 }; 8724 8725 /* *** CONFIGURE TUNNEL UDP PORT *** */ 8726 struct cmd_tunnel_udp_config { 8727 cmdline_fixed_string_t cmd; 8728 cmdline_fixed_string_t what; 8729 uint16_t udp_port; 8730 portid_t port_id; 8731 }; 8732 8733 static void 8734 cmd_tunnel_udp_config_parsed(void *parsed_result, 8735 __attribute__((unused)) struct cmdline *cl, 8736 __attribute__((unused)) void *data) 8737 { 8738 struct cmd_tunnel_udp_config *res = parsed_result; 8739 struct rte_eth_udp_tunnel tunnel_udp; 8740 int ret; 8741 8742 tunnel_udp.udp_port = res->udp_port; 8743 8744 if (!strcmp(res->cmd, "rx_vxlan_port")) 8745 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 8746 8747 if (!strcmp(res->what, "add")) 8748 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 8749 &tunnel_udp); 8750 else 8751 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 8752 &tunnel_udp); 8753 8754 if (ret < 0) 8755 printf("udp tunneling add error: (%s)\n", strerror(-ret)); 8756 } 8757 8758 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd = 8759 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 8760 cmd, "rx_vxlan_port"); 8761 cmdline_parse_token_string_t cmd_tunnel_udp_config_what = 8762 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 8763 what, "add#rm"); 8764 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port = 8765 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 8766 udp_port, UINT16); 8767 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id = 8768 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 8769 port_id, UINT16); 8770 8771 cmdline_parse_inst_t cmd_tunnel_udp_config = { 8772 .f = cmd_tunnel_udp_config_parsed, 8773 .data = (void *)0, 8774 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: " 8775 "Add/Remove a tunneling UDP port filter", 8776 .tokens = { 8777 (void *)&cmd_tunnel_udp_config_cmd, 8778 (void *)&cmd_tunnel_udp_config_what, 8779 (void *)&cmd_tunnel_udp_config_udp_port, 8780 (void *)&cmd_tunnel_udp_config_port_id, 8781 NULL, 8782 }, 8783 }; 8784 8785 struct cmd_config_tunnel_udp_port { 8786 cmdline_fixed_string_t port; 8787 cmdline_fixed_string_t config; 8788 portid_t port_id; 8789 cmdline_fixed_string_t udp_tunnel_port; 8790 cmdline_fixed_string_t action; 8791 cmdline_fixed_string_t tunnel_type; 8792 uint16_t udp_port; 8793 }; 8794 8795 static void 8796 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result, 8797 __attribute__((unused)) struct cmdline *cl, 8798 __attribute__((unused)) void *data) 8799 { 8800 struct cmd_config_tunnel_udp_port *res = parsed_result; 8801 struct rte_eth_udp_tunnel tunnel_udp; 8802 int ret = 0; 8803 8804 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 8805 return; 8806 8807 tunnel_udp.udp_port = res->udp_port; 8808 8809 if (!strcmp(res->tunnel_type, "vxlan")) { 8810 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 8811 } else if (!strcmp(res->tunnel_type, "geneve")) { 8812 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE; 8813 } else { 8814 printf("Invalid tunnel type\n"); 8815 return; 8816 } 8817 8818 if (!strcmp(res->action, "add")) 8819 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 8820 &tunnel_udp); 8821 else 8822 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 8823 &tunnel_udp); 8824 8825 if (ret < 0) 8826 printf("udp tunneling port add error: (%s)\n", strerror(-ret)); 8827 } 8828 8829 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port = 8830 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port, 8831 "port"); 8832 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config = 8833 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config, 8834 "config"); 8835 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id = 8836 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id, 8837 UINT16); 8838 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port = 8839 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, 8840 udp_tunnel_port, 8841 "udp_tunnel_port"); 8842 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action = 8843 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action, 8844 "add#rm"); 8845 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type = 8846 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type, 8847 "vxlan#geneve"); 8848 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value = 8849 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port, 8850 UINT16); 8851 8852 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = { 8853 .f = cmd_cfg_tunnel_udp_port_parsed, 8854 .data = NULL, 8855 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>", 8856 .tokens = { 8857 (void *)&cmd_config_tunnel_udp_port_port, 8858 (void *)&cmd_config_tunnel_udp_port_config, 8859 (void *)&cmd_config_tunnel_udp_port_port_id, 8860 (void *)&cmd_config_tunnel_udp_port_tunnel_port, 8861 (void *)&cmd_config_tunnel_udp_port_action, 8862 (void *)&cmd_config_tunnel_udp_port_tunnel_type, 8863 (void *)&cmd_config_tunnel_udp_port_value, 8864 NULL, 8865 }, 8866 }; 8867 8868 /* *** GLOBAL CONFIG *** */ 8869 struct cmd_global_config_result { 8870 cmdline_fixed_string_t cmd; 8871 portid_t port_id; 8872 cmdline_fixed_string_t cfg_type; 8873 uint8_t len; 8874 }; 8875 8876 static void 8877 cmd_global_config_parsed(void *parsed_result, 8878 __attribute__((unused)) struct cmdline *cl, 8879 __attribute__((unused)) void *data) 8880 { 8881 struct cmd_global_config_result *res = parsed_result; 8882 struct rte_eth_global_cfg conf; 8883 int ret; 8884 8885 memset(&conf, 0, sizeof(conf)); 8886 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN; 8887 conf.cfg.gre_key_len = res->len; 8888 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE, 8889 RTE_ETH_FILTER_SET, &conf); 8890 if (ret != 0) 8891 printf("Global config error\n"); 8892 } 8893 8894 cmdline_parse_token_string_t cmd_global_config_cmd = 8895 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd, 8896 "global_config"); 8897 cmdline_parse_token_num_t cmd_global_config_port_id = 8898 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, 8899 UINT16); 8900 cmdline_parse_token_string_t cmd_global_config_type = 8901 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, 8902 cfg_type, "gre-key-len"); 8903 cmdline_parse_token_num_t cmd_global_config_gre_key_len = 8904 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, 8905 len, UINT8); 8906 8907 cmdline_parse_inst_t cmd_global_config = { 8908 .f = cmd_global_config_parsed, 8909 .data = (void *)NULL, 8910 .help_str = "global_config <port_id> gre-key-len <key_len>", 8911 .tokens = { 8912 (void *)&cmd_global_config_cmd, 8913 (void *)&cmd_global_config_port_id, 8914 (void *)&cmd_global_config_type, 8915 (void *)&cmd_global_config_gre_key_len, 8916 NULL, 8917 }, 8918 }; 8919 8920 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */ 8921 struct cmd_set_mirror_mask_result { 8922 cmdline_fixed_string_t set; 8923 cmdline_fixed_string_t port; 8924 portid_t port_id; 8925 cmdline_fixed_string_t mirror; 8926 uint8_t rule_id; 8927 cmdline_fixed_string_t what; 8928 cmdline_fixed_string_t value; 8929 cmdline_fixed_string_t dstpool; 8930 uint8_t dstpool_id; 8931 cmdline_fixed_string_t on; 8932 }; 8933 8934 cmdline_parse_token_string_t cmd_mirror_mask_set = 8935 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8936 set, "set"); 8937 cmdline_parse_token_string_t cmd_mirror_mask_port = 8938 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8939 port, "port"); 8940 cmdline_parse_token_num_t cmd_mirror_mask_portid = 8941 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 8942 port_id, UINT16); 8943 cmdline_parse_token_string_t cmd_mirror_mask_mirror = 8944 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8945 mirror, "mirror-rule"); 8946 cmdline_parse_token_num_t cmd_mirror_mask_ruleid = 8947 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 8948 rule_id, UINT8); 8949 cmdline_parse_token_string_t cmd_mirror_mask_what = 8950 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8951 what, "pool-mirror-up#pool-mirror-down" 8952 "#vlan-mirror"); 8953 cmdline_parse_token_string_t cmd_mirror_mask_value = 8954 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8955 value, NULL); 8956 cmdline_parse_token_string_t cmd_mirror_mask_dstpool = 8957 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8958 dstpool, "dst-pool"); 8959 cmdline_parse_token_num_t cmd_mirror_mask_poolid = 8960 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 8961 dstpool_id, UINT8); 8962 cmdline_parse_token_string_t cmd_mirror_mask_on = 8963 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 8964 on, "on#off"); 8965 8966 static void 8967 cmd_set_mirror_mask_parsed(void *parsed_result, 8968 __attribute__((unused)) struct cmdline *cl, 8969 __attribute__((unused)) void *data) 8970 { 8971 int ret,nb_item,i; 8972 struct cmd_set_mirror_mask_result *res = parsed_result; 8973 struct rte_eth_mirror_conf mr_conf; 8974 8975 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 8976 8977 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS]; 8978 8979 mr_conf.dst_pool = res->dstpool_id; 8980 8981 if (!strcmp(res->what, "pool-mirror-up")) { 8982 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 8983 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP; 8984 } else if (!strcmp(res->what, "pool-mirror-down")) { 8985 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 8986 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN; 8987 } else if (!strcmp(res->what, "vlan-mirror")) { 8988 mr_conf.rule_type = ETH_MIRROR_VLAN; 8989 nb_item = parse_item_list(res->value, "vlan", 8990 ETH_MIRROR_MAX_VLANS, vlan_list, 1); 8991 if (nb_item <= 0) 8992 return; 8993 8994 for (i = 0; i < nb_item; i++) { 8995 if (vlan_list[i] > ETHER_MAX_VLAN_ID) { 8996 printf("Invalid vlan_id: must be < 4096\n"); 8997 return; 8998 } 8999 9000 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i]; 9001 mr_conf.vlan.vlan_mask |= 1ULL << i; 9002 } 9003 } 9004 9005 if (!strcmp(res->on, "on")) 9006 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9007 res->rule_id, 1); 9008 else 9009 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9010 res->rule_id, 0); 9011 if (ret < 0) 9012 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9013 } 9014 9015 cmdline_parse_inst_t cmd_set_mirror_mask = { 9016 .f = cmd_set_mirror_mask_parsed, 9017 .data = NULL, 9018 .help_str = "set port <port_id> mirror-rule <rule_id> " 9019 "pool-mirror-up|pool-mirror-down|vlan-mirror " 9020 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off", 9021 .tokens = { 9022 (void *)&cmd_mirror_mask_set, 9023 (void *)&cmd_mirror_mask_port, 9024 (void *)&cmd_mirror_mask_portid, 9025 (void *)&cmd_mirror_mask_mirror, 9026 (void *)&cmd_mirror_mask_ruleid, 9027 (void *)&cmd_mirror_mask_what, 9028 (void *)&cmd_mirror_mask_value, 9029 (void *)&cmd_mirror_mask_dstpool, 9030 (void *)&cmd_mirror_mask_poolid, 9031 (void *)&cmd_mirror_mask_on, 9032 NULL, 9033 }, 9034 }; 9035 9036 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */ 9037 struct cmd_set_mirror_link_result { 9038 cmdline_fixed_string_t set; 9039 cmdline_fixed_string_t port; 9040 portid_t port_id; 9041 cmdline_fixed_string_t mirror; 9042 uint8_t rule_id; 9043 cmdline_fixed_string_t what; 9044 cmdline_fixed_string_t dstpool; 9045 uint8_t dstpool_id; 9046 cmdline_fixed_string_t on; 9047 }; 9048 9049 cmdline_parse_token_string_t cmd_mirror_link_set = 9050 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9051 set, "set"); 9052 cmdline_parse_token_string_t cmd_mirror_link_port = 9053 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9054 port, "port"); 9055 cmdline_parse_token_num_t cmd_mirror_link_portid = 9056 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9057 port_id, UINT16); 9058 cmdline_parse_token_string_t cmd_mirror_link_mirror = 9059 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9060 mirror, "mirror-rule"); 9061 cmdline_parse_token_num_t cmd_mirror_link_ruleid = 9062 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9063 rule_id, UINT8); 9064 cmdline_parse_token_string_t cmd_mirror_link_what = 9065 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9066 what, "uplink-mirror#downlink-mirror"); 9067 cmdline_parse_token_string_t cmd_mirror_link_dstpool = 9068 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9069 dstpool, "dst-pool"); 9070 cmdline_parse_token_num_t cmd_mirror_link_poolid = 9071 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9072 dstpool_id, UINT8); 9073 cmdline_parse_token_string_t cmd_mirror_link_on = 9074 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9075 on, "on#off"); 9076 9077 static void 9078 cmd_set_mirror_link_parsed(void *parsed_result, 9079 __attribute__((unused)) struct cmdline *cl, 9080 __attribute__((unused)) void *data) 9081 { 9082 int ret; 9083 struct cmd_set_mirror_link_result *res = parsed_result; 9084 struct rte_eth_mirror_conf mr_conf; 9085 9086 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9087 if (!strcmp(res->what, "uplink-mirror")) 9088 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT; 9089 else 9090 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT; 9091 9092 mr_conf.dst_pool = res->dstpool_id; 9093 9094 if (!strcmp(res->on, "on")) 9095 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9096 res->rule_id, 1); 9097 else 9098 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9099 res->rule_id, 0); 9100 9101 /* check the return value and print it if is < 0 */ 9102 if (ret < 0) 9103 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9104 9105 } 9106 9107 cmdline_parse_inst_t cmd_set_mirror_link = { 9108 .f = cmd_set_mirror_link_parsed, 9109 .data = NULL, 9110 .help_str = "set port <port_id> mirror-rule <rule_id> " 9111 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off", 9112 .tokens = { 9113 (void *)&cmd_mirror_link_set, 9114 (void *)&cmd_mirror_link_port, 9115 (void *)&cmd_mirror_link_portid, 9116 (void *)&cmd_mirror_link_mirror, 9117 (void *)&cmd_mirror_link_ruleid, 9118 (void *)&cmd_mirror_link_what, 9119 (void *)&cmd_mirror_link_dstpool, 9120 (void *)&cmd_mirror_link_poolid, 9121 (void *)&cmd_mirror_link_on, 9122 NULL, 9123 }, 9124 }; 9125 9126 /* *** RESET VM MIRROR RULE *** */ 9127 struct cmd_rm_mirror_rule_result { 9128 cmdline_fixed_string_t reset; 9129 cmdline_fixed_string_t port; 9130 portid_t port_id; 9131 cmdline_fixed_string_t mirror; 9132 uint8_t rule_id; 9133 }; 9134 9135 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset = 9136 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9137 reset, "reset"); 9138 cmdline_parse_token_string_t cmd_rm_mirror_rule_port = 9139 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9140 port, "port"); 9141 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid = 9142 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9143 port_id, UINT16); 9144 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror = 9145 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9146 mirror, "mirror-rule"); 9147 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid = 9148 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9149 rule_id, UINT8); 9150 9151 static void 9152 cmd_reset_mirror_rule_parsed(void *parsed_result, 9153 __attribute__((unused)) struct cmdline *cl, 9154 __attribute__((unused)) void *data) 9155 { 9156 int ret; 9157 struct cmd_set_mirror_link_result *res = parsed_result; 9158 /* check rule_id */ 9159 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id); 9160 if(ret < 0) 9161 printf("mirror rule remove error: (%s)\n", strerror(-ret)); 9162 } 9163 9164 cmdline_parse_inst_t cmd_reset_mirror_rule = { 9165 .f = cmd_reset_mirror_rule_parsed, 9166 .data = NULL, 9167 .help_str = "reset port <port_id> mirror-rule <rule_id>", 9168 .tokens = { 9169 (void *)&cmd_rm_mirror_rule_reset, 9170 (void *)&cmd_rm_mirror_rule_port, 9171 (void *)&cmd_rm_mirror_rule_portid, 9172 (void *)&cmd_rm_mirror_rule_mirror, 9173 (void *)&cmd_rm_mirror_rule_ruleid, 9174 NULL, 9175 }, 9176 }; 9177 9178 /* ******************************************************************************** */ 9179 9180 struct cmd_dump_result { 9181 cmdline_fixed_string_t dump; 9182 }; 9183 9184 static void 9185 dump_struct_sizes(void) 9186 { 9187 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t)); 9188 DUMP_SIZE(struct rte_mbuf); 9189 DUMP_SIZE(struct rte_mempool); 9190 DUMP_SIZE(struct rte_ring); 9191 #undef DUMP_SIZE 9192 } 9193 9194 static void cmd_dump_parsed(void *parsed_result, 9195 __attribute__((unused)) struct cmdline *cl, 9196 __attribute__((unused)) void *data) 9197 { 9198 struct cmd_dump_result *res = parsed_result; 9199 9200 if (!strcmp(res->dump, "dump_physmem")) 9201 rte_dump_physmem_layout(stdout); 9202 else if (!strcmp(res->dump, "dump_memzone")) 9203 rte_memzone_dump(stdout); 9204 else if (!strcmp(res->dump, "dump_struct_sizes")) 9205 dump_struct_sizes(); 9206 else if (!strcmp(res->dump, "dump_ring")) 9207 rte_ring_list_dump(stdout); 9208 else if (!strcmp(res->dump, "dump_mempool")) 9209 rte_mempool_list_dump(stdout); 9210 else if (!strcmp(res->dump, "dump_devargs")) 9211 rte_devargs_dump(stdout); 9212 else if (!strcmp(res->dump, "dump_log_types")) 9213 rte_log_dump(stdout); 9214 } 9215 9216 cmdline_parse_token_string_t cmd_dump_dump = 9217 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, 9218 "dump_physmem#" 9219 "dump_memzone#" 9220 "dump_struct_sizes#" 9221 "dump_ring#" 9222 "dump_mempool#" 9223 "dump_devargs#" 9224 "dump_log_types"); 9225 9226 cmdline_parse_inst_t cmd_dump = { 9227 .f = cmd_dump_parsed, /* function to call */ 9228 .data = NULL, /* 2nd arg of func */ 9229 .help_str = "Dump status", 9230 .tokens = { /* token list, NULL terminated */ 9231 (void *)&cmd_dump_dump, 9232 NULL, 9233 }, 9234 }; 9235 9236 /* ******************************************************************************** */ 9237 9238 struct cmd_dump_one_result { 9239 cmdline_fixed_string_t dump; 9240 cmdline_fixed_string_t name; 9241 }; 9242 9243 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, 9244 __attribute__((unused)) void *data) 9245 { 9246 struct cmd_dump_one_result *res = parsed_result; 9247 9248 if (!strcmp(res->dump, "dump_ring")) { 9249 struct rte_ring *r; 9250 r = rte_ring_lookup(res->name); 9251 if (r == NULL) { 9252 cmdline_printf(cl, "Cannot find ring\n"); 9253 return; 9254 } 9255 rte_ring_dump(stdout, r); 9256 } else if (!strcmp(res->dump, "dump_mempool")) { 9257 struct rte_mempool *mp; 9258 mp = rte_mempool_lookup(res->name); 9259 if (mp == NULL) { 9260 cmdline_printf(cl, "Cannot find mempool\n"); 9261 return; 9262 } 9263 rte_mempool_dump(stdout, mp); 9264 } 9265 } 9266 9267 cmdline_parse_token_string_t cmd_dump_one_dump = 9268 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump, 9269 "dump_ring#dump_mempool"); 9270 9271 cmdline_parse_token_string_t cmd_dump_one_name = 9272 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL); 9273 9274 cmdline_parse_inst_t cmd_dump_one = { 9275 .f = cmd_dump_one_parsed, /* function to call */ 9276 .data = NULL, /* 2nd arg of func */ 9277 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool", 9278 .tokens = { /* token list, NULL terminated */ 9279 (void *)&cmd_dump_one_dump, 9280 (void *)&cmd_dump_one_name, 9281 NULL, 9282 }, 9283 }; 9284 9285 /* *** Add/Del syn filter *** */ 9286 struct cmd_syn_filter_result { 9287 cmdline_fixed_string_t filter; 9288 portid_t port_id; 9289 cmdline_fixed_string_t ops; 9290 cmdline_fixed_string_t priority; 9291 cmdline_fixed_string_t high; 9292 cmdline_fixed_string_t queue; 9293 uint16_t queue_id; 9294 }; 9295 9296 static void 9297 cmd_syn_filter_parsed(void *parsed_result, 9298 __attribute__((unused)) struct cmdline *cl, 9299 __attribute__((unused)) void *data) 9300 { 9301 struct cmd_syn_filter_result *res = parsed_result; 9302 struct rte_eth_syn_filter syn_filter; 9303 int ret = 0; 9304 9305 ret = rte_eth_dev_filter_supported(res->port_id, 9306 RTE_ETH_FILTER_SYN); 9307 if (ret < 0) { 9308 printf("syn filter is not supported on port %u.\n", 9309 res->port_id); 9310 return; 9311 } 9312 9313 memset(&syn_filter, 0, sizeof(syn_filter)); 9314 9315 if (!strcmp(res->ops, "add")) { 9316 if (!strcmp(res->high, "high")) 9317 syn_filter.hig_pri = 1; 9318 else 9319 syn_filter.hig_pri = 0; 9320 9321 syn_filter.queue = res->queue_id; 9322 ret = rte_eth_dev_filter_ctrl(res->port_id, 9323 RTE_ETH_FILTER_SYN, 9324 RTE_ETH_FILTER_ADD, 9325 &syn_filter); 9326 } else 9327 ret = rte_eth_dev_filter_ctrl(res->port_id, 9328 RTE_ETH_FILTER_SYN, 9329 RTE_ETH_FILTER_DELETE, 9330 &syn_filter); 9331 9332 if (ret < 0) 9333 printf("syn filter programming error: (%s)\n", 9334 strerror(-ret)); 9335 } 9336 9337 cmdline_parse_token_string_t cmd_syn_filter_filter = 9338 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9339 filter, "syn_filter"); 9340 cmdline_parse_token_num_t cmd_syn_filter_port_id = 9341 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 9342 port_id, UINT16); 9343 cmdline_parse_token_string_t cmd_syn_filter_ops = 9344 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9345 ops, "add#del"); 9346 cmdline_parse_token_string_t cmd_syn_filter_priority = 9347 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9348 priority, "priority"); 9349 cmdline_parse_token_string_t cmd_syn_filter_high = 9350 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9351 high, "high#low"); 9352 cmdline_parse_token_string_t cmd_syn_filter_queue = 9353 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9354 queue, "queue"); 9355 cmdline_parse_token_num_t cmd_syn_filter_queue_id = 9356 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 9357 queue_id, UINT16); 9358 9359 cmdline_parse_inst_t cmd_syn_filter = { 9360 .f = cmd_syn_filter_parsed, 9361 .data = NULL, 9362 .help_str = "syn_filter <port_id> add|del priority high|low queue " 9363 "<queue_id>: Add/Delete syn filter", 9364 .tokens = { 9365 (void *)&cmd_syn_filter_filter, 9366 (void *)&cmd_syn_filter_port_id, 9367 (void *)&cmd_syn_filter_ops, 9368 (void *)&cmd_syn_filter_priority, 9369 (void *)&cmd_syn_filter_high, 9370 (void *)&cmd_syn_filter_queue, 9371 (void *)&cmd_syn_filter_queue_id, 9372 NULL, 9373 }, 9374 }; 9375 9376 /* *** queue region set *** */ 9377 struct cmd_queue_region_result { 9378 cmdline_fixed_string_t set; 9379 cmdline_fixed_string_t port; 9380 portid_t port_id; 9381 cmdline_fixed_string_t cmd; 9382 cmdline_fixed_string_t region; 9383 uint8_t region_id; 9384 cmdline_fixed_string_t queue_start_index; 9385 uint8_t queue_id; 9386 cmdline_fixed_string_t queue_num; 9387 uint8_t queue_num_value; 9388 }; 9389 9390 static void 9391 cmd_queue_region_parsed(void *parsed_result, 9392 __attribute__((unused)) struct cmdline *cl, 9393 __attribute__((unused)) void *data) 9394 { 9395 struct cmd_queue_region_result *res = parsed_result; 9396 int ret = -ENOTSUP; 9397 #ifdef RTE_LIBRTE_I40E_PMD 9398 struct rte_pmd_i40e_queue_region_conf region_conf; 9399 enum rte_pmd_i40e_queue_region_op op_type; 9400 #endif 9401 9402 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9403 return; 9404 9405 #ifdef RTE_LIBRTE_I40E_PMD 9406 memset(®ion_conf, 0, sizeof(region_conf)); 9407 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET; 9408 region_conf.region_id = res->region_id; 9409 region_conf.queue_num = res->queue_num_value; 9410 region_conf.queue_start_index = res->queue_id; 9411 9412 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9413 op_type, ®ion_conf); 9414 #endif 9415 9416 switch (ret) { 9417 case 0: 9418 break; 9419 case -ENOTSUP: 9420 printf("function not implemented or supported\n"); 9421 break; 9422 default: 9423 printf("queue region config error: (%s)\n", strerror(-ret)); 9424 } 9425 } 9426 9427 cmdline_parse_token_string_t cmd_queue_region_set = 9428 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9429 set, "set"); 9430 cmdline_parse_token_string_t cmd_queue_region_port = 9431 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port"); 9432 cmdline_parse_token_num_t cmd_queue_region_port_id = 9433 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9434 port_id, UINT16); 9435 cmdline_parse_token_string_t cmd_queue_region_cmd = 9436 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9437 cmd, "queue-region"); 9438 cmdline_parse_token_string_t cmd_queue_region_id = 9439 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9440 region, "region_id"); 9441 cmdline_parse_token_num_t cmd_queue_region_index = 9442 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9443 region_id, UINT8); 9444 cmdline_parse_token_string_t cmd_queue_region_queue_start_index = 9445 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9446 queue_start_index, "queue_start_index"); 9447 cmdline_parse_token_num_t cmd_queue_region_queue_id = 9448 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9449 queue_id, UINT8); 9450 cmdline_parse_token_string_t cmd_queue_region_queue_num = 9451 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9452 queue_num, "queue_num"); 9453 cmdline_parse_token_num_t cmd_queue_region_queue_num_value = 9454 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9455 queue_num_value, UINT8); 9456 9457 cmdline_parse_inst_t cmd_queue_region = { 9458 .f = cmd_queue_region_parsed, 9459 .data = NULL, 9460 .help_str = "set port <port_id> queue-region region_id <value> " 9461 "queue_start_index <value> queue_num <value>: Set a queue region", 9462 .tokens = { 9463 (void *)&cmd_queue_region_set, 9464 (void *)&cmd_queue_region_port, 9465 (void *)&cmd_queue_region_port_id, 9466 (void *)&cmd_queue_region_cmd, 9467 (void *)&cmd_queue_region_id, 9468 (void *)&cmd_queue_region_index, 9469 (void *)&cmd_queue_region_queue_start_index, 9470 (void *)&cmd_queue_region_queue_id, 9471 (void *)&cmd_queue_region_queue_num, 9472 (void *)&cmd_queue_region_queue_num_value, 9473 NULL, 9474 }, 9475 }; 9476 9477 /* *** queue region and flowtype set *** */ 9478 struct cmd_region_flowtype_result { 9479 cmdline_fixed_string_t set; 9480 cmdline_fixed_string_t port; 9481 portid_t port_id; 9482 cmdline_fixed_string_t cmd; 9483 cmdline_fixed_string_t region; 9484 uint8_t region_id; 9485 cmdline_fixed_string_t flowtype; 9486 uint8_t flowtype_id; 9487 }; 9488 9489 static void 9490 cmd_region_flowtype_parsed(void *parsed_result, 9491 __attribute__((unused)) struct cmdline *cl, 9492 __attribute__((unused)) void *data) 9493 { 9494 struct cmd_region_flowtype_result *res = parsed_result; 9495 int ret = -ENOTSUP; 9496 #ifdef RTE_LIBRTE_I40E_PMD 9497 struct rte_pmd_i40e_queue_region_conf region_conf; 9498 enum rte_pmd_i40e_queue_region_op op_type; 9499 #endif 9500 9501 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9502 return; 9503 9504 #ifdef RTE_LIBRTE_I40E_PMD 9505 memset(®ion_conf, 0, sizeof(region_conf)); 9506 9507 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET; 9508 region_conf.region_id = res->region_id; 9509 region_conf.hw_flowtype = res->flowtype_id; 9510 9511 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9512 op_type, ®ion_conf); 9513 #endif 9514 9515 switch (ret) { 9516 case 0: 9517 break; 9518 case -ENOTSUP: 9519 printf("function not implemented or supported\n"); 9520 break; 9521 default: 9522 printf("region flowtype config error: (%s)\n", strerror(-ret)); 9523 } 9524 } 9525 9526 cmdline_parse_token_string_t cmd_region_flowtype_set = 9527 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9528 set, "set"); 9529 cmdline_parse_token_string_t cmd_region_flowtype_port = 9530 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9531 port, "port"); 9532 cmdline_parse_token_num_t cmd_region_flowtype_port_index = 9533 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9534 port_id, UINT16); 9535 cmdline_parse_token_string_t cmd_region_flowtype_cmd = 9536 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9537 cmd, "queue-region"); 9538 cmdline_parse_token_string_t cmd_region_flowtype_index = 9539 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9540 region, "region_id"); 9541 cmdline_parse_token_num_t cmd_region_flowtype_id = 9542 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9543 region_id, UINT8); 9544 cmdline_parse_token_string_t cmd_region_flowtype_flow_index = 9545 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9546 flowtype, "flowtype"); 9547 cmdline_parse_token_num_t cmd_region_flowtype_flow_id = 9548 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9549 flowtype_id, UINT8); 9550 cmdline_parse_inst_t cmd_region_flowtype = { 9551 .f = cmd_region_flowtype_parsed, 9552 .data = NULL, 9553 .help_str = "set port <port_id> queue-region region_id <value> " 9554 "flowtype <value>: Set a flowtype region index", 9555 .tokens = { 9556 (void *)&cmd_region_flowtype_set, 9557 (void *)&cmd_region_flowtype_port, 9558 (void *)&cmd_region_flowtype_port_index, 9559 (void *)&cmd_region_flowtype_cmd, 9560 (void *)&cmd_region_flowtype_index, 9561 (void *)&cmd_region_flowtype_id, 9562 (void *)&cmd_region_flowtype_flow_index, 9563 (void *)&cmd_region_flowtype_flow_id, 9564 NULL, 9565 }, 9566 }; 9567 9568 /* *** User Priority (UP) to queue region (region_id) set *** */ 9569 struct cmd_user_priority_region_result { 9570 cmdline_fixed_string_t set; 9571 cmdline_fixed_string_t port; 9572 portid_t port_id; 9573 cmdline_fixed_string_t cmd; 9574 cmdline_fixed_string_t user_priority; 9575 uint8_t user_priority_id; 9576 cmdline_fixed_string_t region; 9577 uint8_t region_id; 9578 }; 9579 9580 static void 9581 cmd_user_priority_region_parsed(void *parsed_result, 9582 __attribute__((unused)) struct cmdline *cl, 9583 __attribute__((unused)) void *data) 9584 { 9585 struct cmd_user_priority_region_result *res = parsed_result; 9586 int ret = -ENOTSUP; 9587 #ifdef RTE_LIBRTE_I40E_PMD 9588 struct rte_pmd_i40e_queue_region_conf region_conf; 9589 enum rte_pmd_i40e_queue_region_op op_type; 9590 #endif 9591 9592 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9593 return; 9594 9595 #ifdef RTE_LIBRTE_I40E_PMD 9596 memset(®ion_conf, 0, sizeof(region_conf)); 9597 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET; 9598 region_conf.user_priority = res->user_priority_id; 9599 region_conf.region_id = res->region_id; 9600 9601 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9602 op_type, ®ion_conf); 9603 #endif 9604 9605 switch (ret) { 9606 case 0: 9607 break; 9608 case -ENOTSUP: 9609 printf("function not implemented or supported\n"); 9610 break; 9611 default: 9612 printf("user_priority region config error: (%s)\n", 9613 strerror(-ret)); 9614 } 9615 } 9616 9617 cmdline_parse_token_string_t cmd_user_priority_region_set = 9618 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9619 set, "set"); 9620 cmdline_parse_token_string_t cmd_user_priority_region_port = 9621 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9622 port, "port"); 9623 cmdline_parse_token_num_t cmd_user_priority_region_port_index = 9624 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9625 port_id, UINT16); 9626 cmdline_parse_token_string_t cmd_user_priority_region_cmd = 9627 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9628 cmd, "queue-region"); 9629 cmdline_parse_token_string_t cmd_user_priority_region_UP = 9630 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9631 user_priority, "UP"); 9632 cmdline_parse_token_num_t cmd_user_priority_region_UP_id = 9633 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9634 user_priority_id, UINT8); 9635 cmdline_parse_token_string_t cmd_user_priority_region_region = 9636 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9637 region, "region_id"); 9638 cmdline_parse_token_num_t cmd_user_priority_region_region_id = 9639 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9640 region_id, UINT8); 9641 9642 cmdline_parse_inst_t cmd_user_priority_region = { 9643 .f = cmd_user_priority_region_parsed, 9644 .data = NULL, 9645 .help_str = "set port <port_id> queue-region UP <value> " 9646 "region_id <value>: Set the mapping of User Priority (UP) " 9647 "to queue region (region_id) ", 9648 .tokens = { 9649 (void *)&cmd_user_priority_region_set, 9650 (void *)&cmd_user_priority_region_port, 9651 (void *)&cmd_user_priority_region_port_index, 9652 (void *)&cmd_user_priority_region_cmd, 9653 (void *)&cmd_user_priority_region_UP, 9654 (void *)&cmd_user_priority_region_UP_id, 9655 (void *)&cmd_user_priority_region_region, 9656 (void *)&cmd_user_priority_region_region_id, 9657 NULL, 9658 }, 9659 }; 9660 9661 /* *** flush all queue region related configuration *** */ 9662 struct cmd_flush_queue_region_result { 9663 cmdline_fixed_string_t set; 9664 cmdline_fixed_string_t port; 9665 portid_t port_id; 9666 cmdline_fixed_string_t cmd; 9667 cmdline_fixed_string_t flush; 9668 cmdline_fixed_string_t what; 9669 }; 9670 9671 static void 9672 cmd_flush_queue_region_parsed(void *parsed_result, 9673 __attribute__((unused)) struct cmdline *cl, 9674 __attribute__((unused)) void *data) 9675 { 9676 struct cmd_flush_queue_region_result *res = parsed_result; 9677 int ret = -ENOTSUP; 9678 #ifdef RTE_LIBRTE_I40E_PMD 9679 struct rte_pmd_i40e_queue_region_conf region_conf; 9680 enum rte_pmd_i40e_queue_region_op op_type; 9681 #endif 9682 9683 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9684 return; 9685 9686 #ifdef RTE_LIBRTE_I40E_PMD 9687 memset(®ion_conf, 0, sizeof(region_conf)); 9688 9689 if (strcmp(res->what, "on") == 0) 9690 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON; 9691 else 9692 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF; 9693 9694 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9695 op_type, ®ion_conf); 9696 #endif 9697 9698 switch (ret) { 9699 case 0: 9700 break; 9701 case -ENOTSUP: 9702 printf("function not implemented or supported\n"); 9703 break; 9704 default: 9705 printf("queue region config flush error: (%s)\n", 9706 strerror(-ret)); 9707 } 9708 } 9709 9710 cmdline_parse_token_string_t cmd_flush_queue_region_set = 9711 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9712 set, "set"); 9713 cmdline_parse_token_string_t cmd_flush_queue_region_port = 9714 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9715 port, "port"); 9716 cmdline_parse_token_num_t cmd_flush_queue_region_port_index = 9717 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result, 9718 port_id, UINT16); 9719 cmdline_parse_token_string_t cmd_flush_queue_region_cmd = 9720 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9721 cmd, "queue-region"); 9722 cmdline_parse_token_string_t cmd_flush_queue_region_flush = 9723 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9724 flush, "flush"); 9725 cmdline_parse_token_string_t cmd_flush_queue_region_what = 9726 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9727 what, "on#off"); 9728 9729 cmdline_parse_inst_t cmd_flush_queue_region = { 9730 .f = cmd_flush_queue_region_parsed, 9731 .data = NULL, 9732 .help_str = "set port <port_id> queue-region flush on|off" 9733 ": flush all queue region related configuration", 9734 .tokens = { 9735 (void *)&cmd_flush_queue_region_set, 9736 (void *)&cmd_flush_queue_region_port, 9737 (void *)&cmd_flush_queue_region_port_index, 9738 (void *)&cmd_flush_queue_region_cmd, 9739 (void *)&cmd_flush_queue_region_flush, 9740 (void *)&cmd_flush_queue_region_what, 9741 NULL, 9742 }, 9743 }; 9744 9745 /* *** get all queue region related configuration info *** */ 9746 struct cmd_show_queue_region_info { 9747 cmdline_fixed_string_t show; 9748 cmdline_fixed_string_t port; 9749 portid_t port_id; 9750 cmdline_fixed_string_t cmd; 9751 }; 9752 9753 static void 9754 cmd_show_queue_region_info_parsed(void *parsed_result, 9755 __attribute__((unused)) struct cmdline *cl, 9756 __attribute__((unused)) void *data) 9757 { 9758 struct cmd_show_queue_region_info *res = parsed_result; 9759 int ret = -ENOTSUP; 9760 #ifdef RTE_LIBRTE_I40E_PMD 9761 struct rte_pmd_i40e_queue_regions rte_pmd_regions; 9762 enum rte_pmd_i40e_queue_region_op op_type; 9763 #endif 9764 9765 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9766 return; 9767 9768 #ifdef RTE_LIBRTE_I40E_PMD 9769 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions)); 9770 9771 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET; 9772 9773 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9774 op_type, &rte_pmd_regions); 9775 9776 port_queue_region_info_display(res->port_id, &rte_pmd_regions); 9777 #endif 9778 9779 switch (ret) { 9780 case 0: 9781 break; 9782 case -ENOTSUP: 9783 printf("function not implemented or supported\n"); 9784 break; 9785 default: 9786 printf("queue region config info show error: (%s)\n", 9787 strerror(-ret)); 9788 } 9789 } 9790 9791 cmdline_parse_token_string_t cmd_show_queue_region_info_get = 9792 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9793 show, "show"); 9794 cmdline_parse_token_string_t cmd_show_queue_region_info_port = 9795 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9796 port, "port"); 9797 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index = 9798 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info, 9799 port_id, UINT16); 9800 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd = 9801 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9802 cmd, "queue-region"); 9803 9804 cmdline_parse_inst_t cmd_show_queue_region_info_all = { 9805 .f = cmd_show_queue_region_info_parsed, 9806 .data = NULL, 9807 .help_str = "show port <port_id> queue-region" 9808 ": show all queue region related configuration info", 9809 .tokens = { 9810 (void *)&cmd_show_queue_region_info_get, 9811 (void *)&cmd_show_queue_region_info_port, 9812 (void *)&cmd_show_queue_region_info_port_index, 9813 (void *)&cmd_show_queue_region_info_cmd, 9814 NULL, 9815 }, 9816 }; 9817 9818 /* *** ADD/REMOVE A 2tuple FILTER *** */ 9819 struct cmd_2tuple_filter_result { 9820 cmdline_fixed_string_t filter; 9821 portid_t port_id; 9822 cmdline_fixed_string_t ops; 9823 cmdline_fixed_string_t dst_port; 9824 uint16_t dst_port_value; 9825 cmdline_fixed_string_t protocol; 9826 uint8_t protocol_value; 9827 cmdline_fixed_string_t mask; 9828 uint8_t mask_value; 9829 cmdline_fixed_string_t tcp_flags; 9830 uint8_t tcp_flags_value; 9831 cmdline_fixed_string_t priority; 9832 uint8_t priority_value; 9833 cmdline_fixed_string_t queue; 9834 uint16_t queue_id; 9835 }; 9836 9837 static void 9838 cmd_2tuple_filter_parsed(void *parsed_result, 9839 __attribute__((unused)) struct cmdline *cl, 9840 __attribute__((unused)) void *data) 9841 { 9842 struct rte_eth_ntuple_filter filter; 9843 struct cmd_2tuple_filter_result *res = parsed_result; 9844 int ret = 0; 9845 9846 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 9847 if (ret < 0) { 9848 printf("ntuple filter is not supported on port %u.\n", 9849 res->port_id); 9850 return; 9851 } 9852 9853 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 9854 9855 filter.flags = RTE_2TUPLE_FLAGS; 9856 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 9857 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 9858 filter.proto = res->protocol_value; 9859 filter.priority = res->priority_value; 9860 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 9861 printf("nonzero tcp_flags is only meaningful" 9862 " when protocol is TCP.\n"); 9863 return; 9864 } 9865 if (res->tcp_flags_value > TCP_FLAG_ALL) { 9866 printf("invalid TCP flags.\n"); 9867 return; 9868 } 9869 9870 if (res->tcp_flags_value != 0) { 9871 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 9872 filter.tcp_flags = res->tcp_flags_value; 9873 } 9874 9875 /* need convert to big endian. */ 9876 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 9877 filter.queue = res->queue_id; 9878 9879 if (!strcmp(res->ops, "add")) 9880 ret = rte_eth_dev_filter_ctrl(res->port_id, 9881 RTE_ETH_FILTER_NTUPLE, 9882 RTE_ETH_FILTER_ADD, 9883 &filter); 9884 else 9885 ret = rte_eth_dev_filter_ctrl(res->port_id, 9886 RTE_ETH_FILTER_NTUPLE, 9887 RTE_ETH_FILTER_DELETE, 9888 &filter); 9889 if (ret < 0) 9890 printf("2tuple filter programming error: (%s)\n", 9891 strerror(-ret)); 9892 9893 } 9894 9895 cmdline_parse_token_string_t cmd_2tuple_filter_filter = 9896 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9897 filter, "2tuple_filter"); 9898 cmdline_parse_token_num_t cmd_2tuple_filter_port_id = 9899 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9900 port_id, UINT16); 9901 cmdline_parse_token_string_t cmd_2tuple_filter_ops = 9902 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9903 ops, "add#del"); 9904 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port = 9905 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9906 dst_port, "dst_port"); 9907 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value = 9908 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9909 dst_port_value, UINT16); 9910 cmdline_parse_token_string_t cmd_2tuple_filter_protocol = 9911 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9912 protocol, "protocol"); 9913 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value = 9914 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9915 protocol_value, UINT8); 9916 cmdline_parse_token_string_t cmd_2tuple_filter_mask = 9917 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9918 mask, "mask"); 9919 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value = 9920 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9921 mask_value, INT8); 9922 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags = 9923 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9924 tcp_flags, "tcp_flags"); 9925 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value = 9926 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9927 tcp_flags_value, UINT8); 9928 cmdline_parse_token_string_t cmd_2tuple_filter_priority = 9929 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9930 priority, "priority"); 9931 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value = 9932 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9933 priority_value, UINT8); 9934 cmdline_parse_token_string_t cmd_2tuple_filter_queue = 9935 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 9936 queue, "queue"); 9937 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id = 9938 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 9939 queue_id, UINT16); 9940 9941 cmdline_parse_inst_t cmd_2tuple_filter = { 9942 .f = cmd_2tuple_filter_parsed, 9943 .data = NULL, 9944 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol " 9945 "<value> mask <value> tcp_flags <value> priority <value> queue " 9946 "<queue_id>: Add a 2tuple filter", 9947 .tokens = { 9948 (void *)&cmd_2tuple_filter_filter, 9949 (void *)&cmd_2tuple_filter_port_id, 9950 (void *)&cmd_2tuple_filter_ops, 9951 (void *)&cmd_2tuple_filter_dst_port, 9952 (void *)&cmd_2tuple_filter_dst_port_value, 9953 (void *)&cmd_2tuple_filter_protocol, 9954 (void *)&cmd_2tuple_filter_protocol_value, 9955 (void *)&cmd_2tuple_filter_mask, 9956 (void *)&cmd_2tuple_filter_mask_value, 9957 (void *)&cmd_2tuple_filter_tcp_flags, 9958 (void *)&cmd_2tuple_filter_tcp_flags_value, 9959 (void *)&cmd_2tuple_filter_priority, 9960 (void *)&cmd_2tuple_filter_priority_value, 9961 (void *)&cmd_2tuple_filter_queue, 9962 (void *)&cmd_2tuple_filter_queue_id, 9963 NULL, 9964 }, 9965 }; 9966 9967 /* *** ADD/REMOVE A 5tuple FILTER *** */ 9968 struct cmd_5tuple_filter_result { 9969 cmdline_fixed_string_t filter; 9970 portid_t port_id; 9971 cmdline_fixed_string_t ops; 9972 cmdline_fixed_string_t dst_ip; 9973 cmdline_ipaddr_t dst_ip_value; 9974 cmdline_fixed_string_t src_ip; 9975 cmdline_ipaddr_t src_ip_value; 9976 cmdline_fixed_string_t dst_port; 9977 uint16_t dst_port_value; 9978 cmdline_fixed_string_t src_port; 9979 uint16_t src_port_value; 9980 cmdline_fixed_string_t protocol; 9981 uint8_t protocol_value; 9982 cmdline_fixed_string_t mask; 9983 uint8_t mask_value; 9984 cmdline_fixed_string_t tcp_flags; 9985 uint8_t tcp_flags_value; 9986 cmdline_fixed_string_t priority; 9987 uint8_t priority_value; 9988 cmdline_fixed_string_t queue; 9989 uint16_t queue_id; 9990 }; 9991 9992 static void 9993 cmd_5tuple_filter_parsed(void *parsed_result, 9994 __attribute__((unused)) struct cmdline *cl, 9995 __attribute__((unused)) void *data) 9996 { 9997 struct rte_eth_ntuple_filter filter; 9998 struct cmd_5tuple_filter_result *res = parsed_result; 9999 int ret = 0; 10000 10001 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 10002 if (ret < 0) { 10003 printf("ntuple filter is not supported on port %u.\n", 10004 res->port_id); 10005 return; 10006 } 10007 10008 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 10009 10010 filter.flags = RTE_5TUPLE_FLAGS; 10011 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0; 10012 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0; 10013 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0; 10014 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 10015 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 10016 filter.proto = res->protocol_value; 10017 filter.priority = res->priority_value; 10018 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 10019 printf("nonzero tcp_flags is only meaningful" 10020 " when protocol is TCP.\n"); 10021 return; 10022 } 10023 if (res->tcp_flags_value > TCP_FLAG_ALL) { 10024 printf("invalid TCP flags.\n"); 10025 return; 10026 } 10027 10028 if (res->tcp_flags_value != 0) { 10029 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 10030 filter.tcp_flags = res->tcp_flags_value; 10031 } 10032 10033 if (res->dst_ip_value.family == AF_INET) 10034 /* no need to convert, already big endian. */ 10035 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr; 10036 else { 10037 if (filter.dst_ip_mask == 0) { 10038 printf("can not support ipv6 involved compare.\n"); 10039 return; 10040 } 10041 filter.dst_ip = 0; 10042 } 10043 10044 if (res->src_ip_value.family == AF_INET) 10045 /* no need to convert, already big endian. */ 10046 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr; 10047 else { 10048 if (filter.src_ip_mask == 0) { 10049 printf("can not support ipv6 involved compare.\n"); 10050 return; 10051 } 10052 filter.src_ip = 0; 10053 } 10054 /* need convert to big endian. */ 10055 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 10056 filter.src_port = rte_cpu_to_be_16(res->src_port_value); 10057 filter.queue = res->queue_id; 10058 10059 if (!strcmp(res->ops, "add")) 10060 ret = rte_eth_dev_filter_ctrl(res->port_id, 10061 RTE_ETH_FILTER_NTUPLE, 10062 RTE_ETH_FILTER_ADD, 10063 &filter); 10064 else 10065 ret = rte_eth_dev_filter_ctrl(res->port_id, 10066 RTE_ETH_FILTER_NTUPLE, 10067 RTE_ETH_FILTER_DELETE, 10068 &filter); 10069 if (ret < 0) 10070 printf("5tuple filter programming error: (%s)\n", 10071 strerror(-ret)); 10072 } 10073 10074 cmdline_parse_token_string_t cmd_5tuple_filter_filter = 10075 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10076 filter, "5tuple_filter"); 10077 cmdline_parse_token_num_t cmd_5tuple_filter_port_id = 10078 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10079 port_id, UINT16); 10080 cmdline_parse_token_string_t cmd_5tuple_filter_ops = 10081 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10082 ops, "add#del"); 10083 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip = 10084 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10085 dst_ip, "dst_ip"); 10086 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value = 10087 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 10088 dst_ip_value); 10089 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip = 10090 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10091 src_ip, "src_ip"); 10092 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value = 10093 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 10094 src_ip_value); 10095 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port = 10096 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10097 dst_port, "dst_port"); 10098 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value = 10099 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10100 dst_port_value, UINT16); 10101 cmdline_parse_token_string_t cmd_5tuple_filter_src_port = 10102 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10103 src_port, "src_port"); 10104 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value = 10105 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10106 src_port_value, UINT16); 10107 cmdline_parse_token_string_t cmd_5tuple_filter_protocol = 10108 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10109 protocol, "protocol"); 10110 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value = 10111 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10112 protocol_value, UINT8); 10113 cmdline_parse_token_string_t cmd_5tuple_filter_mask = 10114 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10115 mask, "mask"); 10116 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value = 10117 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10118 mask_value, INT8); 10119 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags = 10120 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10121 tcp_flags, "tcp_flags"); 10122 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value = 10123 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10124 tcp_flags_value, UINT8); 10125 cmdline_parse_token_string_t cmd_5tuple_filter_priority = 10126 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10127 priority, "priority"); 10128 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value = 10129 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10130 priority_value, UINT8); 10131 cmdline_parse_token_string_t cmd_5tuple_filter_queue = 10132 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10133 queue, "queue"); 10134 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id = 10135 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10136 queue_id, UINT16); 10137 10138 cmdline_parse_inst_t cmd_5tuple_filter = { 10139 .f = cmd_5tuple_filter_parsed, 10140 .data = NULL, 10141 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> " 10142 "src_ip <value> dst_port <value> src_port <value> " 10143 "protocol <value> mask <value> tcp_flags <value> " 10144 "priority <value> queue <queue_id>: Add/Del a 5tuple filter", 10145 .tokens = { 10146 (void *)&cmd_5tuple_filter_filter, 10147 (void *)&cmd_5tuple_filter_port_id, 10148 (void *)&cmd_5tuple_filter_ops, 10149 (void *)&cmd_5tuple_filter_dst_ip, 10150 (void *)&cmd_5tuple_filter_dst_ip_value, 10151 (void *)&cmd_5tuple_filter_src_ip, 10152 (void *)&cmd_5tuple_filter_src_ip_value, 10153 (void *)&cmd_5tuple_filter_dst_port, 10154 (void *)&cmd_5tuple_filter_dst_port_value, 10155 (void *)&cmd_5tuple_filter_src_port, 10156 (void *)&cmd_5tuple_filter_src_port_value, 10157 (void *)&cmd_5tuple_filter_protocol, 10158 (void *)&cmd_5tuple_filter_protocol_value, 10159 (void *)&cmd_5tuple_filter_mask, 10160 (void *)&cmd_5tuple_filter_mask_value, 10161 (void *)&cmd_5tuple_filter_tcp_flags, 10162 (void *)&cmd_5tuple_filter_tcp_flags_value, 10163 (void *)&cmd_5tuple_filter_priority, 10164 (void *)&cmd_5tuple_filter_priority_value, 10165 (void *)&cmd_5tuple_filter_queue, 10166 (void *)&cmd_5tuple_filter_queue_id, 10167 NULL, 10168 }, 10169 }; 10170 10171 /* *** ADD/REMOVE A flex FILTER *** */ 10172 struct cmd_flex_filter_result { 10173 cmdline_fixed_string_t filter; 10174 cmdline_fixed_string_t ops; 10175 portid_t port_id; 10176 cmdline_fixed_string_t len; 10177 uint8_t len_value; 10178 cmdline_fixed_string_t bytes; 10179 cmdline_fixed_string_t bytes_value; 10180 cmdline_fixed_string_t mask; 10181 cmdline_fixed_string_t mask_value; 10182 cmdline_fixed_string_t priority; 10183 uint8_t priority_value; 10184 cmdline_fixed_string_t queue; 10185 uint16_t queue_id; 10186 }; 10187 10188 static int xdigit2val(unsigned char c) 10189 { 10190 int val; 10191 if (isdigit(c)) 10192 val = c - '0'; 10193 else if (isupper(c)) 10194 val = c - 'A' + 10; 10195 else 10196 val = c - 'a' + 10; 10197 return val; 10198 } 10199 10200 static void 10201 cmd_flex_filter_parsed(void *parsed_result, 10202 __attribute__((unused)) struct cmdline *cl, 10203 __attribute__((unused)) void *data) 10204 { 10205 int ret = 0; 10206 struct rte_eth_flex_filter filter; 10207 struct cmd_flex_filter_result *res = parsed_result; 10208 char *bytes_ptr, *mask_ptr; 10209 uint16_t len, i, j = 0; 10210 char c; 10211 int val; 10212 uint8_t byte = 0; 10213 10214 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) { 10215 printf("the len exceed the max length 128\n"); 10216 return; 10217 } 10218 memset(&filter, 0, sizeof(struct rte_eth_flex_filter)); 10219 filter.len = res->len_value; 10220 filter.priority = res->priority_value; 10221 filter.queue = res->queue_id; 10222 bytes_ptr = res->bytes_value; 10223 mask_ptr = res->mask_value; 10224 10225 /* translate bytes string to array. */ 10226 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') || 10227 (bytes_ptr[1] == 'X'))) 10228 bytes_ptr += 2; 10229 len = strnlen(bytes_ptr, res->len_value * 2); 10230 if (len == 0 || (len % 8 != 0)) { 10231 printf("please check len and bytes input\n"); 10232 return; 10233 } 10234 for (i = 0; i < len; i++) { 10235 c = bytes_ptr[i]; 10236 if (isxdigit(c) == 0) { 10237 /* invalid characters. */ 10238 printf("invalid input\n"); 10239 return; 10240 } 10241 val = xdigit2val(c); 10242 if (i % 2) { 10243 byte |= val; 10244 filter.bytes[j] = byte; 10245 printf("bytes[%d]:%02x ", j, filter.bytes[j]); 10246 j++; 10247 byte = 0; 10248 } else 10249 byte |= val << 4; 10250 } 10251 printf("\n"); 10252 /* translate mask string to uint8_t array. */ 10253 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') || 10254 (mask_ptr[1] == 'X'))) 10255 mask_ptr += 2; 10256 len = strnlen(mask_ptr, (res->len_value + 3) / 4); 10257 if (len == 0) { 10258 printf("invalid input\n"); 10259 return; 10260 } 10261 j = 0; 10262 byte = 0; 10263 for (i = 0; i < len; i++) { 10264 c = mask_ptr[i]; 10265 if (isxdigit(c) == 0) { 10266 /* invalid characters. */ 10267 printf("invalid input\n"); 10268 return; 10269 } 10270 val = xdigit2val(c); 10271 if (i % 2) { 10272 byte |= val; 10273 filter.mask[j] = byte; 10274 printf("mask[%d]:%02x ", j, filter.mask[j]); 10275 j++; 10276 byte = 0; 10277 } else 10278 byte |= val << 4; 10279 } 10280 printf("\n"); 10281 10282 if (!strcmp(res->ops, "add")) 10283 ret = rte_eth_dev_filter_ctrl(res->port_id, 10284 RTE_ETH_FILTER_FLEXIBLE, 10285 RTE_ETH_FILTER_ADD, 10286 &filter); 10287 else 10288 ret = rte_eth_dev_filter_ctrl(res->port_id, 10289 RTE_ETH_FILTER_FLEXIBLE, 10290 RTE_ETH_FILTER_DELETE, 10291 &filter); 10292 10293 if (ret < 0) 10294 printf("flex filter setting error: (%s)\n", strerror(-ret)); 10295 } 10296 10297 cmdline_parse_token_string_t cmd_flex_filter_filter = 10298 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10299 filter, "flex_filter"); 10300 cmdline_parse_token_num_t cmd_flex_filter_port_id = 10301 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10302 port_id, UINT16); 10303 cmdline_parse_token_string_t cmd_flex_filter_ops = 10304 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10305 ops, "add#del"); 10306 cmdline_parse_token_string_t cmd_flex_filter_len = 10307 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10308 len, "len"); 10309 cmdline_parse_token_num_t cmd_flex_filter_len_value = 10310 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10311 len_value, UINT8); 10312 cmdline_parse_token_string_t cmd_flex_filter_bytes = 10313 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10314 bytes, "bytes"); 10315 cmdline_parse_token_string_t cmd_flex_filter_bytes_value = 10316 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10317 bytes_value, NULL); 10318 cmdline_parse_token_string_t cmd_flex_filter_mask = 10319 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10320 mask, "mask"); 10321 cmdline_parse_token_string_t cmd_flex_filter_mask_value = 10322 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10323 mask_value, NULL); 10324 cmdline_parse_token_string_t cmd_flex_filter_priority = 10325 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10326 priority, "priority"); 10327 cmdline_parse_token_num_t cmd_flex_filter_priority_value = 10328 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10329 priority_value, UINT8); 10330 cmdline_parse_token_string_t cmd_flex_filter_queue = 10331 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10332 queue, "queue"); 10333 cmdline_parse_token_num_t cmd_flex_filter_queue_id = 10334 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10335 queue_id, UINT16); 10336 cmdline_parse_inst_t cmd_flex_filter = { 10337 .f = cmd_flex_filter_parsed, 10338 .data = NULL, 10339 .help_str = "flex_filter <port_id> add|del len <value> bytes " 10340 "<value> mask <value> priority <value> queue <queue_id>: " 10341 "Add/Del a flex filter", 10342 .tokens = { 10343 (void *)&cmd_flex_filter_filter, 10344 (void *)&cmd_flex_filter_port_id, 10345 (void *)&cmd_flex_filter_ops, 10346 (void *)&cmd_flex_filter_len, 10347 (void *)&cmd_flex_filter_len_value, 10348 (void *)&cmd_flex_filter_bytes, 10349 (void *)&cmd_flex_filter_bytes_value, 10350 (void *)&cmd_flex_filter_mask, 10351 (void *)&cmd_flex_filter_mask_value, 10352 (void *)&cmd_flex_filter_priority, 10353 (void *)&cmd_flex_filter_priority_value, 10354 (void *)&cmd_flex_filter_queue, 10355 (void *)&cmd_flex_filter_queue_id, 10356 NULL, 10357 }, 10358 }; 10359 10360 /* *** Filters Control *** */ 10361 10362 /* *** deal with ethertype filter *** */ 10363 struct cmd_ethertype_filter_result { 10364 cmdline_fixed_string_t filter; 10365 portid_t port_id; 10366 cmdline_fixed_string_t ops; 10367 cmdline_fixed_string_t mac; 10368 struct ether_addr mac_addr; 10369 cmdline_fixed_string_t ethertype; 10370 uint16_t ethertype_value; 10371 cmdline_fixed_string_t drop; 10372 cmdline_fixed_string_t queue; 10373 uint16_t queue_id; 10374 }; 10375 10376 cmdline_parse_token_string_t cmd_ethertype_filter_filter = 10377 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10378 filter, "ethertype_filter"); 10379 cmdline_parse_token_num_t cmd_ethertype_filter_port_id = 10380 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10381 port_id, UINT16); 10382 cmdline_parse_token_string_t cmd_ethertype_filter_ops = 10383 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10384 ops, "add#del"); 10385 cmdline_parse_token_string_t cmd_ethertype_filter_mac = 10386 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10387 mac, "mac_addr#mac_ignr"); 10388 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr = 10389 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result, 10390 mac_addr); 10391 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype = 10392 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10393 ethertype, "ethertype"); 10394 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value = 10395 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10396 ethertype_value, UINT16); 10397 cmdline_parse_token_string_t cmd_ethertype_filter_drop = 10398 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10399 drop, "drop#fwd"); 10400 cmdline_parse_token_string_t cmd_ethertype_filter_queue = 10401 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10402 queue, "queue"); 10403 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id = 10404 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10405 queue_id, UINT16); 10406 10407 static void 10408 cmd_ethertype_filter_parsed(void *parsed_result, 10409 __attribute__((unused)) struct cmdline *cl, 10410 __attribute__((unused)) void *data) 10411 { 10412 struct cmd_ethertype_filter_result *res = parsed_result; 10413 struct rte_eth_ethertype_filter filter; 10414 int ret = 0; 10415 10416 ret = rte_eth_dev_filter_supported(res->port_id, 10417 RTE_ETH_FILTER_ETHERTYPE); 10418 if (ret < 0) { 10419 printf("ethertype filter is not supported on port %u.\n", 10420 res->port_id); 10421 return; 10422 } 10423 10424 memset(&filter, 0, sizeof(filter)); 10425 if (!strcmp(res->mac, "mac_addr")) { 10426 filter.flags |= RTE_ETHTYPE_FLAGS_MAC; 10427 rte_memcpy(&filter.mac_addr, &res->mac_addr, 10428 sizeof(struct ether_addr)); 10429 } 10430 if (!strcmp(res->drop, "drop")) 10431 filter.flags |= RTE_ETHTYPE_FLAGS_DROP; 10432 filter.ether_type = res->ethertype_value; 10433 filter.queue = res->queue_id; 10434 10435 if (!strcmp(res->ops, "add")) 10436 ret = rte_eth_dev_filter_ctrl(res->port_id, 10437 RTE_ETH_FILTER_ETHERTYPE, 10438 RTE_ETH_FILTER_ADD, 10439 &filter); 10440 else 10441 ret = rte_eth_dev_filter_ctrl(res->port_id, 10442 RTE_ETH_FILTER_ETHERTYPE, 10443 RTE_ETH_FILTER_DELETE, 10444 &filter); 10445 if (ret < 0) 10446 printf("ethertype filter programming error: (%s)\n", 10447 strerror(-ret)); 10448 } 10449 10450 cmdline_parse_inst_t cmd_ethertype_filter = { 10451 .f = cmd_ethertype_filter_parsed, 10452 .data = NULL, 10453 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr " 10454 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: " 10455 "Add or delete an ethertype filter entry", 10456 .tokens = { 10457 (void *)&cmd_ethertype_filter_filter, 10458 (void *)&cmd_ethertype_filter_port_id, 10459 (void *)&cmd_ethertype_filter_ops, 10460 (void *)&cmd_ethertype_filter_mac, 10461 (void *)&cmd_ethertype_filter_mac_addr, 10462 (void *)&cmd_ethertype_filter_ethertype, 10463 (void *)&cmd_ethertype_filter_ethertype_value, 10464 (void *)&cmd_ethertype_filter_drop, 10465 (void *)&cmd_ethertype_filter_queue, 10466 (void *)&cmd_ethertype_filter_queue_id, 10467 NULL, 10468 }, 10469 }; 10470 10471 /* *** deal with flow director filter *** */ 10472 struct cmd_flow_director_result { 10473 cmdline_fixed_string_t flow_director_filter; 10474 portid_t port_id; 10475 cmdline_fixed_string_t mode; 10476 cmdline_fixed_string_t mode_value; 10477 cmdline_fixed_string_t ops; 10478 cmdline_fixed_string_t flow; 10479 cmdline_fixed_string_t flow_type; 10480 cmdline_fixed_string_t ether; 10481 uint16_t ether_type; 10482 cmdline_fixed_string_t src; 10483 cmdline_ipaddr_t ip_src; 10484 uint16_t port_src; 10485 cmdline_fixed_string_t dst; 10486 cmdline_ipaddr_t ip_dst; 10487 uint16_t port_dst; 10488 cmdline_fixed_string_t verify_tag; 10489 uint32_t verify_tag_value; 10490 cmdline_fixed_string_t tos; 10491 uint8_t tos_value; 10492 cmdline_fixed_string_t proto; 10493 uint8_t proto_value; 10494 cmdline_fixed_string_t ttl; 10495 uint8_t ttl_value; 10496 cmdline_fixed_string_t vlan; 10497 uint16_t vlan_value; 10498 cmdline_fixed_string_t flexbytes; 10499 cmdline_fixed_string_t flexbytes_value; 10500 cmdline_fixed_string_t pf_vf; 10501 cmdline_fixed_string_t drop; 10502 cmdline_fixed_string_t queue; 10503 uint16_t queue_id; 10504 cmdline_fixed_string_t fd_id; 10505 uint32_t fd_id_value; 10506 cmdline_fixed_string_t mac; 10507 struct ether_addr mac_addr; 10508 cmdline_fixed_string_t tunnel; 10509 cmdline_fixed_string_t tunnel_type; 10510 cmdline_fixed_string_t tunnel_id; 10511 uint32_t tunnel_id_value; 10512 cmdline_fixed_string_t packet; 10513 char filepath[]; 10514 }; 10515 10516 static inline int 10517 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num) 10518 { 10519 char s[256]; 10520 const char *p, *p0 = q_arg; 10521 char *end; 10522 unsigned long int_fld; 10523 char *str_fld[max_num]; 10524 int i; 10525 unsigned size; 10526 int ret = -1; 10527 10528 p = strchr(p0, '('); 10529 if (p == NULL) 10530 return -1; 10531 ++p; 10532 p0 = strchr(p, ')'); 10533 if (p0 == NULL) 10534 return -1; 10535 10536 size = p0 - p; 10537 if (size >= sizeof(s)) 10538 return -1; 10539 10540 snprintf(s, sizeof(s), "%.*s", size, p); 10541 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 10542 if (ret < 0 || ret > max_num) 10543 return -1; 10544 for (i = 0; i < ret; i++) { 10545 errno = 0; 10546 int_fld = strtoul(str_fld[i], &end, 0); 10547 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX) 10548 return -1; 10549 flexbytes[i] = (uint8_t)int_fld; 10550 } 10551 return ret; 10552 } 10553 10554 static uint16_t 10555 str2flowtype(char *string) 10556 { 10557 uint8_t i = 0; 10558 static const struct { 10559 char str[32]; 10560 uint16_t type; 10561 } flowtype_str[] = { 10562 {"raw", RTE_ETH_FLOW_RAW}, 10563 {"ipv4", RTE_ETH_FLOW_IPV4}, 10564 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 10565 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 10566 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 10567 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 10568 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 10569 {"ipv6", RTE_ETH_FLOW_IPV6}, 10570 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 10571 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 10572 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 10573 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 10574 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 10575 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 10576 }; 10577 10578 for (i = 0; i < RTE_DIM(flowtype_str); i++) { 10579 if (!strcmp(flowtype_str[i].str, string)) 10580 return flowtype_str[i].type; 10581 } 10582 10583 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) 10584 return (uint16_t)atoi(string); 10585 10586 return RTE_ETH_FLOW_UNKNOWN; 10587 } 10588 10589 static enum rte_eth_fdir_tunnel_type 10590 str2fdir_tunneltype(char *string) 10591 { 10592 uint8_t i = 0; 10593 10594 static const struct { 10595 char str[32]; 10596 enum rte_eth_fdir_tunnel_type type; 10597 } tunneltype_str[] = { 10598 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE}, 10599 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN}, 10600 }; 10601 10602 for (i = 0; i < RTE_DIM(tunneltype_str); i++) { 10603 if (!strcmp(tunneltype_str[i].str, string)) 10604 return tunneltype_str[i].type; 10605 } 10606 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN; 10607 } 10608 10609 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \ 10610 do { \ 10611 if ((ip_addr).family == AF_INET) \ 10612 (ip) = (ip_addr).addr.ipv4.s_addr; \ 10613 else { \ 10614 printf("invalid parameter.\n"); \ 10615 return; \ 10616 } \ 10617 } while (0) 10618 10619 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \ 10620 do { \ 10621 if ((ip_addr).family == AF_INET6) \ 10622 rte_memcpy(&(ip), \ 10623 &((ip_addr).addr.ipv6), \ 10624 sizeof(struct in6_addr)); \ 10625 else { \ 10626 printf("invalid parameter.\n"); \ 10627 return; \ 10628 } \ 10629 } while (0) 10630 10631 static void 10632 cmd_flow_director_filter_parsed(void *parsed_result, 10633 __attribute__((unused)) struct cmdline *cl, 10634 __attribute__((unused)) void *data) 10635 { 10636 struct cmd_flow_director_result *res = parsed_result; 10637 struct rte_eth_fdir_filter entry; 10638 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN]; 10639 char *end; 10640 unsigned long vf_id; 10641 int ret = 0; 10642 10643 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 10644 if (ret < 0) { 10645 printf("flow director is not supported on port %u.\n", 10646 res->port_id); 10647 return; 10648 } 10649 memset(flexbytes, 0, sizeof(flexbytes)); 10650 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter)); 10651 10652 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 10653 if (strcmp(res->mode_value, "MAC-VLAN")) { 10654 printf("Please set mode to MAC-VLAN.\n"); 10655 return; 10656 } 10657 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10658 if (strcmp(res->mode_value, "Tunnel")) { 10659 printf("Please set mode to Tunnel.\n"); 10660 return; 10661 } 10662 } else { 10663 if (!strcmp(res->mode_value, "raw")) { 10664 #ifdef RTE_LIBRTE_I40E_PMD 10665 struct rte_pmd_i40e_flow_type_mapping 10666 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 10667 struct rte_pmd_i40e_pkt_template_conf conf; 10668 uint16_t flow_type = str2flowtype(res->flow_type); 10669 uint16_t i, port = res->port_id; 10670 uint8_t add; 10671 10672 memset(&conf, 0, sizeof(conf)); 10673 10674 if (flow_type == RTE_ETH_FLOW_UNKNOWN) { 10675 printf("Invalid flow type specified.\n"); 10676 return; 10677 } 10678 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, 10679 mapping); 10680 if (ret) 10681 return; 10682 if (mapping[flow_type].pctype == 0ULL) { 10683 printf("Invalid flow type specified.\n"); 10684 return; 10685 } 10686 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) { 10687 if (mapping[flow_type].pctype & (1ULL << i)) { 10688 conf.input.pctype = i; 10689 break; 10690 } 10691 } 10692 10693 conf.input.packet = open_file(res->filepath, 10694 &conf.input.length); 10695 if (!conf.input.packet) 10696 return; 10697 if (!strcmp(res->drop, "drop")) 10698 conf.action.behavior = 10699 RTE_PMD_I40E_PKT_TEMPLATE_REJECT; 10700 else 10701 conf.action.behavior = 10702 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT; 10703 conf.action.report_status = 10704 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID; 10705 conf.action.rx_queue = res->queue_id; 10706 conf.soft_id = res->fd_id_value; 10707 add = strcmp(res->ops, "del") ? 1 : 0; 10708 ret = rte_pmd_i40e_flow_add_del_packet_template(port, 10709 &conf, 10710 add); 10711 if (ret < 0) 10712 printf("flow director config error: (%s)\n", 10713 strerror(-ret)); 10714 close_file(conf.input.packet); 10715 #endif 10716 return; 10717 } else if (strcmp(res->mode_value, "IP")) { 10718 printf("Please set mode to IP or raw.\n"); 10719 return; 10720 } 10721 entry.input.flow_type = str2flowtype(res->flow_type); 10722 } 10723 10724 ret = parse_flexbytes(res->flexbytes_value, 10725 flexbytes, 10726 RTE_ETH_FDIR_MAX_FLEXLEN); 10727 if (ret < 0) { 10728 printf("error: Cannot parse flexbytes input.\n"); 10729 return; 10730 } 10731 10732 switch (entry.input.flow_type) { 10733 case RTE_ETH_FLOW_FRAG_IPV4: 10734 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: 10735 entry.input.flow.ip4_flow.proto = res->proto_value; 10736 /* fall-through */ 10737 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP: 10738 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP: 10739 IPV4_ADDR_TO_UINT(res->ip_dst, 10740 entry.input.flow.ip4_flow.dst_ip); 10741 IPV4_ADDR_TO_UINT(res->ip_src, 10742 entry.input.flow.ip4_flow.src_ip); 10743 entry.input.flow.ip4_flow.tos = res->tos_value; 10744 entry.input.flow.ip4_flow.ttl = res->ttl_value; 10745 /* need convert to big endian. */ 10746 entry.input.flow.udp4_flow.dst_port = 10747 rte_cpu_to_be_16(res->port_dst); 10748 entry.input.flow.udp4_flow.src_port = 10749 rte_cpu_to_be_16(res->port_src); 10750 break; 10751 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: 10752 IPV4_ADDR_TO_UINT(res->ip_dst, 10753 entry.input.flow.sctp4_flow.ip.dst_ip); 10754 IPV4_ADDR_TO_UINT(res->ip_src, 10755 entry.input.flow.sctp4_flow.ip.src_ip); 10756 entry.input.flow.ip4_flow.tos = res->tos_value; 10757 entry.input.flow.ip4_flow.ttl = res->ttl_value; 10758 /* need convert to big endian. */ 10759 entry.input.flow.sctp4_flow.dst_port = 10760 rte_cpu_to_be_16(res->port_dst); 10761 entry.input.flow.sctp4_flow.src_port = 10762 rte_cpu_to_be_16(res->port_src); 10763 entry.input.flow.sctp4_flow.verify_tag = 10764 rte_cpu_to_be_32(res->verify_tag_value); 10765 break; 10766 case RTE_ETH_FLOW_FRAG_IPV6: 10767 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: 10768 entry.input.flow.ipv6_flow.proto = res->proto_value; 10769 /* fall-through */ 10770 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP: 10771 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP: 10772 IPV6_ADDR_TO_ARRAY(res->ip_dst, 10773 entry.input.flow.ipv6_flow.dst_ip); 10774 IPV6_ADDR_TO_ARRAY(res->ip_src, 10775 entry.input.flow.ipv6_flow.src_ip); 10776 entry.input.flow.ipv6_flow.tc = res->tos_value; 10777 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 10778 /* need convert to big endian. */ 10779 entry.input.flow.udp6_flow.dst_port = 10780 rte_cpu_to_be_16(res->port_dst); 10781 entry.input.flow.udp6_flow.src_port = 10782 rte_cpu_to_be_16(res->port_src); 10783 break; 10784 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: 10785 IPV6_ADDR_TO_ARRAY(res->ip_dst, 10786 entry.input.flow.sctp6_flow.ip.dst_ip); 10787 IPV6_ADDR_TO_ARRAY(res->ip_src, 10788 entry.input.flow.sctp6_flow.ip.src_ip); 10789 entry.input.flow.ipv6_flow.tc = res->tos_value; 10790 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 10791 /* need convert to big endian. */ 10792 entry.input.flow.sctp6_flow.dst_port = 10793 rte_cpu_to_be_16(res->port_dst); 10794 entry.input.flow.sctp6_flow.src_port = 10795 rte_cpu_to_be_16(res->port_src); 10796 entry.input.flow.sctp6_flow.verify_tag = 10797 rte_cpu_to_be_32(res->verify_tag_value); 10798 break; 10799 case RTE_ETH_FLOW_L2_PAYLOAD: 10800 entry.input.flow.l2_flow.ether_type = 10801 rte_cpu_to_be_16(res->ether_type); 10802 break; 10803 default: 10804 break; 10805 } 10806 10807 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) 10808 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr, 10809 &res->mac_addr, 10810 sizeof(struct ether_addr)); 10811 10812 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10813 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr, 10814 &res->mac_addr, 10815 sizeof(struct ether_addr)); 10816 entry.input.flow.tunnel_flow.tunnel_type = 10817 str2fdir_tunneltype(res->tunnel_type); 10818 entry.input.flow.tunnel_flow.tunnel_id = 10819 rte_cpu_to_be_32(res->tunnel_id_value); 10820 } 10821 10822 rte_memcpy(entry.input.flow_ext.flexbytes, 10823 flexbytes, 10824 RTE_ETH_FDIR_MAX_FLEXLEN); 10825 10826 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value); 10827 10828 entry.action.flex_off = 0; /*use 0 by default */ 10829 if (!strcmp(res->drop, "drop")) 10830 entry.action.behavior = RTE_ETH_FDIR_REJECT; 10831 else 10832 entry.action.behavior = RTE_ETH_FDIR_ACCEPT; 10833 10834 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN && 10835 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) { 10836 if (!strcmp(res->pf_vf, "pf")) 10837 entry.input.flow_ext.is_vf = 0; 10838 else if (!strncmp(res->pf_vf, "vf", 2)) { 10839 struct rte_eth_dev_info dev_info; 10840 10841 memset(&dev_info, 0, sizeof(dev_info)); 10842 rte_eth_dev_info_get(res->port_id, &dev_info); 10843 errno = 0; 10844 vf_id = strtoul(res->pf_vf + 2, &end, 10); 10845 if (errno != 0 || *end != '\0' || 10846 vf_id >= dev_info.max_vfs) { 10847 printf("invalid parameter %s.\n", res->pf_vf); 10848 return; 10849 } 10850 entry.input.flow_ext.is_vf = 1; 10851 entry.input.flow_ext.dst_id = (uint16_t)vf_id; 10852 } else { 10853 printf("invalid parameter %s.\n", res->pf_vf); 10854 return; 10855 } 10856 } 10857 10858 /* set to report FD ID by default */ 10859 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID; 10860 entry.action.rx_queue = res->queue_id; 10861 entry.soft_id = res->fd_id_value; 10862 if (!strcmp(res->ops, "add")) 10863 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10864 RTE_ETH_FILTER_ADD, &entry); 10865 else if (!strcmp(res->ops, "del")) 10866 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10867 RTE_ETH_FILTER_DELETE, &entry); 10868 else 10869 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10870 RTE_ETH_FILTER_UPDATE, &entry); 10871 if (ret < 0) 10872 printf("flow director programming error: (%s)\n", 10873 strerror(-ret)); 10874 } 10875 10876 cmdline_parse_token_string_t cmd_flow_director_filter = 10877 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10878 flow_director_filter, "flow_director_filter"); 10879 cmdline_parse_token_num_t cmd_flow_director_port_id = 10880 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10881 port_id, UINT16); 10882 cmdline_parse_token_string_t cmd_flow_director_ops = 10883 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10884 ops, "add#del#update"); 10885 cmdline_parse_token_string_t cmd_flow_director_flow = 10886 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10887 flow, "flow"); 10888 cmdline_parse_token_string_t cmd_flow_director_flow_type = 10889 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10890 flow_type, NULL); 10891 cmdline_parse_token_string_t cmd_flow_director_ether = 10892 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10893 ether, "ether"); 10894 cmdline_parse_token_num_t cmd_flow_director_ether_type = 10895 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10896 ether_type, UINT16); 10897 cmdline_parse_token_string_t cmd_flow_director_src = 10898 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10899 src, "src"); 10900 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src = 10901 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 10902 ip_src); 10903 cmdline_parse_token_num_t cmd_flow_director_port_src = 10904 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10905 port_src, UINT16); 10906 cmdline_parse_token_string_t cmd_flow_director_dst = 10907 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10908 dst, "dst"); 10909 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst = 10910 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 10911 ip_dst); 10912 cmdline_parse_token_num_t cmd_flow_director_port_dst = 10913 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10914 port_dst, UINT16); 10915 cmdline_parse_token_string_t cmd_flow_director_verify_tag = 10916 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10917 verify_tag, "verify_tag"); 10918 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value = 10919 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10920 verify_tag_value, UINT32); 10921 cmdline_parse_token_string_t cmd_flow_director_tos = 10922 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10923 tos, "tos"); 10924 cmdline_parse_token_num_t cmd_flow_director_tos_value = 10925 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10926 tos_value, UINT8); 10927 cmdline_parse_token_string_t cmd_flow_director_proto = 10928 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10929 proto, "proto"); 10930 cmdline_parse_token_num_t cmd_flow_director_proto_value = 10931 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10932 proto_value, UINT8); 10933 cmdline_parse_token_string_t cmd_flow_director_ttl = 10934 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10935 ttl, "ttl"); 10936 cmdline_parse_token_num_t cmd_flow_director_ttl_value = 10937 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10938 ttl_value, UINT8); 10939 cmdline_parse_token_string_t cmd_flow_director_vlan = 10940 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10941 vlan, "vlan"); 10942 cmdline_parse_token_num_t cmd_flow_director_vlan_value = 10943 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10944 vlan_value, UINT16); 10945 cmdline_parse_token_string_t cmd_flow_director_flexbytes = 10946 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10947 flexbytes, "flexbytes"); 10948 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value = 10949 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10950 flexbytes_value, NULL); 10951 cmdline_parse_token_string_t cmd_flow_director_drop = 10952 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10953 drop, "drop#fwd"); 10954 cmdline_parse_token_string_t cmd_flow_director_pf_vf = 10955 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10956 pf_vf, NULL); 10957 cmdline_parse_token_string_t cmd_flow_director_queue = 10958 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10959 queue, "queue"); 10960 cmdline_parse_token_num_t cmd_flow_director_queue_id = 10961 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10962 queue_id, UINT16); 10963 cmdline_parse_token_string_t cmd_flow_director_fd_id = 10964 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10965 fd_id, "fd_id"); 10966 cmdline_parse_token_num_t cmd_flow_director_fd_id_value = 10967 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 10968 fd_id_value, UINT32); 10969 10970 cmdline_parse_token_string_t cmd_flow_director_mode = 10971 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10972 mode, "mode"); 10973 cmdline_parse_token_string_t cmd_flow_director_mode_ip = 10974 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10975 mode_value, "IP"); 10976 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan = 10977 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10978 mode_value, "MAC-VLAN"); 10979 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel = 10980 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10981 mode_value, "Tunnel"); 10982 cmdline_parse_token_string_t cmd_flow_director_mode_raw = 10983 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10984 mode_value, "raw"); 10985 cmdline_parse_token_string_t cmd_flow_director_mac = 10986 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10987 mac, "mac"); 10988 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr = 10989 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result, 10990 mac_addr); 10991 cmdline_parse_token_string_t cmd_flow_director_tunnel = 10992 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10993 tunnel, "tunnel"); 10994 cmdline_parse_token_string_t cmd_flow_director_tunnel_type = 10995 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10996 tunnel_type, "NVGRE#VxLAN"); 10997 cmdline_parse_token_string_t cmd_flow_director_tunnel_id = 10998 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10999 tunnel_id, "tunnel-id"); 11000 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value = 11001 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11002 tunnel_id_value, UINT32); 11003 cmdline_parse_token_string_t cmd_flow_director_packet = 11004 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11005 packet, "packet"); 11006 cmdline_parse_token_string_t cmd_flow_director_filepath = 11007 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11008 filepath, NULL); 11009 11010 cmdline_parse_inst_t cmd_add_del_ip_flow_director = { 11011 .f = cmd_flow_director_filter_parsed, 11012 .data = NULL, 11013 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow" 11014 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 11015 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|" 11016 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> " 11017 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> " 11018 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> " 11019 "fd_id <fd_id_value>: " 11020 "Add or delete an ip flow director entry on NIC", 11021 .tokens = { 11022 (void *)&cmd_flow_director_filter, 11023 (void *)&cmd_flow_director_port_id, 11024 (void *)&cmd_flow_director_mode, 11025 (void *)&cmd_flow_director_mode_ip, 11026 (void *)&cmd_flow_director_ops, 11027 (void *)&cmd_flow_director_flow, 11028 (void *)&cmd_flow_director_flow_type, 11029 (void *)&cmd_flow_director_src, 11030 (void *)&cmd_flow_director_ip_src, 11031 (void *)&cmd_flow_director_dst, 11032 (void *)&cmd_flow_director_ip_dst, 11033 (void *)&cmd_flow_director_tos, 11034 (void *)&cmd_flow_director_tos_value, 11035 (void *)&cmd_flow_director_proto, 11036 (void *)&cmd_flow_director_proto_value, 11037 (void *)&cmd_flow_director_ttl, 11038 (void *)&cmd_flow_director_ttl_value, 11039 (void *)&cmd_flow_director_vlan, 11040 (void *)&cmd_flow_director_vlan_value, 11041 (void *)&cmd_flow_director_flexbytes, 11042 (void *)&cmd_flow_director_flexbytes_value, 11043 (void *)&cmd_flow_director_drop, 11044 (void *)&cmd_flow_director_pf_vf, 11045 (void *)&cmd_flow_director_queue, 11046 (void *)&cmd_flow_director_queue_id, 11047 (void *)&cmd_flow_director_fd_id, 11048 (void *)&cmd_flow_director_fd_id_value, 11049 NULL, 11050 }, 11051 }; 11052 11053 cmdline_parse_inst_t cmd_add_del_udp_flow_director = { 11054 .f = cmd_flow_director_filter_parsed, 11055 .data = NULL, 11056 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow " 11057 "director entry on NIC", 11058 .tokens = { 11059 (void *)&cmd_flow_director_filter, 11060 (void *)&cmd_flow_director_port_id, 11061 (void *)&cmd_flow_director_mode, 11062 (void *)&cmd_flow_director_mode_ip, 11063 (void *)&cmd_flow_director_ops, 11064 (void *)&cmd_flow_director_flow, 11065 (void *)&cmd_flow_director_flow_type, 11066 (void *)&cmd_flow_director_src, 11067 (void *)&cmd_flow_director_ip_src, 11068 (void *)&cmd_flow_director_port_src, 11069 (void *)&cmd_flow_director_dst, 11070 (void *)&cmd_flow_director_ip_dst, 11071 (void *)&cmd_flow_director_port_dst, 11072 (void *)&cmd_flow_director_tos, 11073 (void *)&cmd_flow_director_tos_value, 11074 (void *)&cmd_flow_director_ttl, 11075 (void *)&cmd_flow_director_ttl_value, 11076 (void *)&cmd_flow_director_vlan, 11077 (void *)&cmd_flow_director_vlan_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_pf_vf, 11082 (void *)&cmd_flow_director_queue, 11083 (void *)&cmd_flow_director_queue_id, 11084 (void *)&cmd_flow_director_fd_id, 11085 (void *)&cmd_flow_director_fd_id_value, 11086 NULL, 11087 }, 11088 }; 11089 11090 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = { 11091 .f = cmd_flow_director_filter_parsed, 11092 .data = NULL, 11093 .help_str = "flow_director_filter ... : Add or delete a sctp flow " 11094 "director entry on NIC", 11095 .tokens = { 11096 (void *)&cmd_flow_director_filter, 11097 (void *)&cmd_flow_director_port_id, 11098 (void *)&cmd_flow_director_mode, 11099 (void *)&cmd_flow_director_mode_ip, 11100 (void *)&cmd_flow_director_ops, 11101 (void *)&cmd_flow_director_flow, 11102 (void *)&cmd_flow_director_flow_type, 11103 (void *)&cmd_flow_director_src, 11104 (void *)&cmd_flow_director_ip_src, 11105 (void *)&cmd_flow_director_port_src, 11106 (void *)&cmd_flow_director_dst, 11107 (void *)&cmd_flow_director_ip_dst, 11108 (void *)&cmd_flow_director_port_dst, 11109 (void *)&cmd_flow_director_verify_tag, 11110 (void *)&cmd_flow_director_verify_tag_value, 11111 (void *)&cmd_flow_director_tos, 11112 (void *)&cmd_flow_director_tos_value, 11113 (void *)&cmd_flow_director_ttl, 11114 (void *)&cmd_flow_director_ttl_value, 11115 (void *)&cmd_flow_director_vlan, 11116 (void *)&cmd_flow_director_vlan_value, 11117 (void *)&cmd_flow_director_flexbytes, 11118 (void *)&cmd_flow_director_flexbytes_value, 11119 (void *)&cmd_flow_director_drop, 11120 (void *)&cmd_flow_director_pf_vf, 11121 (void *)&cmd_flow_director_queue, 11122 (void *)&cmd_flow_director_queue_id, 11123 (void *)&cmd_flow_director_fd_id, 11124 (void *)&cmd_flow_director_fd_id_value, 11125 NULL, 11126 }, 11127 }; 11128 11129 cmdline_parse_inst_t cmd_add_del_l2_flow_director = { 11130 .f = cmd_flow_director_filter_parsed, 11131 .data = NULL, 11132 .help_str = "flow_director_filter ... : Add or delete a L2 flow " 11133 "director entry on NIC", 11134 .tokens = { 11135 (void *)&cmd_flow_director_filter, 11136 (void *)&cmd_flow_director_port_id, 11137 (void *)&cmd_flow_director_mode, 11138 (void *)&cmd_flow_director_mode_ip, 11139 (void *)&cmd_flow_director_ops, 11140 (void *)&cmd_flow_director_flow, 11141 (void *)&cmd_flow_director_flow_type, 11142 (void *)&cmd_flow_director_ether, 11143 (void *)&cmd_flow_director_ether_type, 11144 (void *)&cmd_flow_director_flexbytes, 11145 (void *)&cmd_flow_director_flexbytes_value, 11146 (void *)&cmd_flow_director_drop, 11147 (void *)&cmd_flow_director_pf_vf, 11148 (void *)&cmd_flow_director_queue, 11149 (void *)&cmd_flow_director_queue_id, 11150 (void *)&cmd_flow_director_fd_id, 11151 (void *)&cmd_flow_director_fd_id_value, 11152 NULL, 11153 }, 11154 }; 11155 11156 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = { 11157 .f = cmd_flow_director_filter_parsed, 11158 .data = NULL, 11159 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow " 11160 "director entry on NIC", 11161 .tokens = { 11162 (void *)&cmd_flow_director_filter, 11163 (void *)&cmd_flow_director_port_id, 11164 (void *)&cmd_flow_director_mode, 11165 (void *)&cmd_flow_director_mode_mac_vlan, 11166 (void *)&cmd_flow_director_ops, 11167 (void *)&cmd_flow_director_mac, 11168 (void *)&cmd_flow_director_mac_addr, 11169 (void *)&cmd_flow_director_vlan, 11170 (void *)&cmd_flow_director_vlan_value, 11171 (void *)&cmd_flow_director_flexbytes, 11172 (void *)&cmd_flow_director_flexbytes_value, 11173 (void *)&cmd_flow_director_drop, 11174 (void *)&cmd_flow_director_queue, 11175 (void *)&cmd_flow_director_queue_id, 11176 (void *)&cmd_flow_director_fd_id, 11177 (void *)&cmd_flow_director_fd_id_value, 11178 NULL, 11179 }, 11180 }; 11181 11182 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = { 11183 .f = cmd_flow_director_filter_parsed, 11184 .data = NULL, 11185 .help_str = "flow_director_filter ... : Add or delete a tunnel flow " 11186 "director entry on NIC", 11187 .tokens = { 11188 (void *)&cmd_flow_director_filter, 11189 (void *)&cmd_flow_director_port_id, 11190 (void *)&cmd_flow_director_mode, 11191 (void *)&cmd_flow_director_mode_tunnel, 11192 (void *)&cmd_flow_director_ops, 11193 (void *)&cmd_flow_director_mac, 11194 (void *)&cmd_flow_director_mac_addr, 11195 (void *)&cmd_flow_director_vlan, 11196 (void *)&cmd_flow_director_vlan_value, 11197 (void *)&cmd_flow_director_tunnel, 11198 (void *)&cmd_flow_director_tunnel_type, 11199 (void *)&cmd_flow_director_tunnel_id, 11200 (void *)&cmd_flow_director_tunnel_id_value, 11201 (void *)&cmd_flow_director_flexbytes, 11202 (void *)&cmd_flow_director_flexbytes_value, 11203 (void *)&cmd_flow_director_drop, 11204 (void *)&cmd_flow_director_queue, 11205 (void *)&cmd_flow_director_queue_id, 11206 (void *)&cmd_flow_director_fd_id, 11207 (void *)&cmd_flow_director_fd_id_value, 11208 NULL, 11209 }, 11210 }; 11211 11212 cmdline_parse_inst_t cmd_add_del_raw_flow_director = { 11213 .f = cmd_flow_director_filter_parsed, 11214 .data = NULL, 11215 .help_str = "flow_director_filter ... : Add or delete a raw flow " 11216 "director entry on NIC", 11217 .tokens = { 11218 (void *)&cmd_flow_director_filter, 11219 (void *)&cmd_flow_director_port_id, 11220 (void *)&cmd_flow_director_mode, 11221 (void *)&cmd_flow_director_mode_raw, 11222 (void *)&cmd_flow_director_ops, 11223 (void *)&cmd_flow_director_flow, 11224 (void *)&cmd_flow_director_flow_type, 11225 (void *)&cmd_flow_director_drop, 11226 (void *)&cmd_flow_director_queue, 11227 (void *)&cmd_flow_director_queue_id, 11228 (void *)&cmd_flow_director_fd_id, 11229 (void *)&cmd_flow_director_fd_id_value, 11230 (void *)&cmd_flow_director_packet, 11231 (void *)&cmd_flow_director_filepath, 11232 NULL, 11233 }, 11234 }; 11235 11236 struct cmd_flush_flow_director_result { 11237 cmdline_fixed_string_t flush_flow_director; 11238 portid_t port_id; 11239 }; 11240 11241 cmdline_parse_token_string_t cmd_flush_flow_director_flush = 11242 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result, 11243 flush_flow_director, "flush_flow_director"); 11244 cmdline_parse_token_num_t cmd_flush_flow_director_port_id = 11245 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result, 11246 port_id, UINT16); 11247 11248 static void 11249 cmd_flush_flow_director_parsed(void *parsed_result, 11250 __attribute__((unused)) struct cmdline *cl, 11251 __attribute__((unused)) void *data) 11252 { 11253 struct cmd_flow_director_result *res = parsed_result; 11254 int ret = 0; 11255 11256 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 11257 if (ret < 0) { 11258 printf("flow director is not supported on port %u.\n", 11259 res->port_id); 11260 return; 11261 } 11262 11263 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11264 RTE_ETH_FILTER_FLUSH, NULL); 11265 if (ret < 0) 11266 printf("flow director table flushing error: (%s)\n", 11267 strerror(-ret)); 11268 } 11269 11270 cmdline_parse_inst_t cmd_flush_flow_director = { 11271 .f = cmd_flush_flow_director_parsed, 11272 .data = NULL, 11273 .help_str = "flush_flow_director <port_id>: " 11274 "Flush all flow director entries of a device on NIC", 11275 .tokens = { 11276 (void *)&cmd_flush_flow_director_flush, 11277 (void *)&cmd_flush_flow_director_port_id, 11278 NULL, 11279 }, 11280 }; 11281 11282 /* *** deal with flow director mask *** */ 11283 struct cmd_flow_director_mask_result { 11284 cmdline_fixed_string_t flow_director_mask; 11285 portid_t port_id; 11286 cmdline_fixed_string_t mode; 11287 cmdline_fixed_string_t mode_value; 11288 cmdline_fixed_string_t vlan; 11289 uint16_t vlan_mask; 11290 cmdline_fixed_string_t src_mask; 11291 cmdline_ipaddr_t ipv4_src; 11292 cmdline_ipaddr_t ipv6_src; 11293 uint16_t port_src; 11294 cmdline_fixed_string_t dst_mask; 11295 cmdline_ipaddr_t ipv4_dst; 11296 cmdline_ipaddr_t ipv6_dst; 11297 uint16_t port_dst; 11298 cmdline_fixed_string_t mac; 11299 uint8_t mac_addr_byte_mask; 11300 cmdline_fixed_string_t tunnel_id; 11301 uint32_t tunnel_id_mask; 11302 cmdline_fixed_string_t tunnel_type; 11303 uint8_t tunnel_type_mask; 11304 }; 11305 11306 static void 11307 cmd_flow_director_mask_parsed(void *parsed_result, 11308 __attribute__((unused)) struct cmdline *cl, 11309 __attribute__((unused)) void *data) 11310 { 11311 struct cmd_flow_director_mask_result *res = parsed_result; 11312 struct rte_eth_fdir_masks *mask; 11313 struct rte_port *port; 11314 11315 port = &ports[res->port_id]; 11316 /** Check if the port is not started **/ 11317 if (port->port_status != RTE_PORT_STOPPED) { 11318 printf("Please stop port %d first\n", res->port_id); 11319 return; 11320 } 11321 11322 mask = &port->dev_conf.fdir_conf.mask; 11323 11324 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 11325 if (strcmp(res->mode_value, "MAC-VLAN")) { 11326 printf("Please set mode to MAC-VLAN.\n"); 11327 return; 11328 } 11329 11330 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11331 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 11332 if (strcmp(res->mode_value, "Tunnel")) { 11333 printf("Please set mode to Tunnel.\n"); 11334 return; 11335 } 11336 11337 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11338 mask->mac_addr_byte_mask = res->mac_addr_byte_mask; 11339 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask); 11340 mask->tunnel_type_mask = res->tunnel_type_mask; 11341 } else { 11342 if (strcmp(res->mode_value, "IP")) { 11343 printf("Please set mode to IP.\n"); 11344 return; 11345 } 11346 11347 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11348 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip); 11349 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip); 11350 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip); 11351 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip); 11352 mask->src_port_mask = rte_cpu_to_be_16(res->port_src); 11353 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst); 11354 } 11355 11356 cmd_reconfig_device_queue(res->port_id, 1, 1); 11357 } 11358 11359 cmdline_parse_token_string_t cmd_flow_director_mask = 11360 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11361 flow_director_mask, "flow_director_mask"); 11362 cmdline_parse_token_num_t cmd_flow_director_mask_port_id = 11363 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11364 port_id, UINT16); 11365 cmdline_parse_token_string_t cmd_flow_director_mask_vlan = 11366 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11367 vlan, "vlan"); 11368 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value = 11369 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11370 vlan_mask, UINT16); 11371 cmdline_parse_token_string_t cmd_flow_director_mask_src = 11372 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11373 src_mask, "src_mask"); 11374 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src = 11375 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11376 ipv4_src); 11377 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src = 11378 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11379 ipv6_src); 11380 cmdline_parse_token_num_t cmd_flow_director_mask_port_src = 11381 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11382 port_src, UINT16); 11383 cmdline_parse_token_string_t cmd_flow_director_mask_dst = 11384 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11385 dst_mask, "dst_mask"); 11386 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst = 11387 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11388 ipv4_dst); 11389 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst = 11390 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11391 ipv6_dst); 11392 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst = 11393 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11394 port_dst, UINT16); 11395 11396 cmdline_parse_token_string_t cmd_flow_director_mask_mode = 11397 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11398 mode, "mode"); 11399 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip = 11400 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11401 mode_value, "IP"); 11402 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan = 11403 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11404 mode_value, "MAC-VLAN"); 11405 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel = 11406 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11407 mode_value, "Tunnel"); 11408 cmdline_parse_token_string_t cmd_flow_director_mask_mac = 11409 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11410 mac, "mac"); 11411 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value = 11412 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11413 mac_addr_byte_mask, UINT8); 11414 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type = 11415 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11416 tunnel_type, "tunnel-type"); 11417 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value = 11418 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11419 tunnel_type_mask, UINT8); 11420 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id = 11421 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11422 tunnel_id, "tunnel-id"); 11423 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value = 11424 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11425 tunnel_id_mask, UINT32); 11426 11427 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = { 11428 .f = cmd_flow_director_mask_parsed, 11429 .data = NULL, 11430 .help_str = "flow_director_mask ... : " 11431 "Set IP mode flow director's mask on NIC", 11432 .tokens = { 11433 (void *)&cmd_flow_director_mask, 11434 (void *)&cmd_flow_director_mask_port_id, 11435 (void *)&cmd_flow_director_mask_mode, 11436 (void *)&cmd_flow_director_mask_mode_ip, 11437 (void *)&cmd_flow_director_mask_vlan, 11438 (void *)&cmd_flow_director_mask_vlan_value, 11439 (void *)&cmd_flow_director_mask_src, 11440 (void *)&cmd_flow_director_mask_ipv4_src, 11441 (void *)&cmd_flow_director_mask_ipv6_src, 11442 (void *)&cmd_flow_director_mask_port_src, 11443 (void *)&cmd_flow_director_mask_dst, 11444 (void *)&cmd_flow_director_mask_ipv4_dst, 11445 (void *)&cmd_flow_director_mask_ipv6_dst, 11446 (void *)&cmd_flow_director_mask_port_dst, 11447 NULL, 11448 }, 11449 }; 11450 11451 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = { 11452 .f = cmd_flow_director_mask_parsed, 11453 .data = NULL, 11454 .help_str = "flow_director_mask ... : Set MAC VLAN mode " 11455 "flow director's mask on NIC", 11456 .tokens = { 11457 (void *)&cmd_flow_director_mask, 11458 (void *)&cmd_flow_director_mask_port_id, 11459 (void *)&cmd_flow_director_mask_mode, 11460 (void *)&cmd_flow_director_mask_mode_mac_vlan, 11461 (void *)&cmd_flow_director_mask_vlan, 11462 (void *)&cmd_flow_director_mask_vlan_value, 11463 NULL, 11464 }, 11465 }; 11466 11467 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = { 11468 .f = cmd_flow_director_mask_parsed, 11469 .data = NULL, 11470 .help_str = "flow_director_mask ... : Set tunnel mode " 11471 "flow director's mask on NIC", 11472 .tokens = { 11473 (void *)&cmd_flow_director_mask, 11474 (void *)&cmd_flow_director_mask_port_id, 11475 (void *)&cmd_flow_director_mask_mode, 11476 (void *)&cmd_flow_director_mask_mode_tunnel, 11477 (void *)&cmd_flow_director_mask_vlan, 11478 (void *)&cmd_flow_director_mask_vlan_value, 11479 (void *)&cmd_flow_director_mask_mac, 11480 (void *)&cmd_flow_director_mask_mac_value, 11481 (void *)&cmd_flow_director_mask_tunnel_type, 11482 (void *)&cmd_flow_director_mask_tunnel_type_value, 11483 (void *)&cmd_flow_director_mask_tunnel_id, 11484 (void *)&cmd_flow_director_mask_tunnel_id_value, 11485 NULL, 11486 }, 11487 }; 11488 11489 /* *** deal with flow director mask on flexible payload *** */ 11490 struct cmd_flow_director_flex_mask_result { 11491 cmdline_fixed_string_t flow_director_flexmask; 11492 portid_t port_id; 11493 cmdline_fixed_string_t flow; 11494 cmdline_fixed_string_t flow_type; 11495 cmdline_fixed_string_t mask; 11496 }; 11497 11498 static void 11499 cmd_flow_director_flex_mask_parsed(void *parsed_result, 11500 __attribute__((unused)) struct cmdline *cl, 11501 __attribute__((unused)) void *data) 11502 { 11503 struct cmd_flow_director_flex_mask_result *res = parsed_result; 11504 struct rte_eth_fdir_info fdir_info; 11505 struct rte_eth_fdir_flex_mask flex_mask; 11506 struct rte_port *port; 11507 uint64_t flow_type_mask; 11508 uint16_t i; 11509 int ret; 11510 11511 port = &ports[res->port_id]; 11512 /** Check if the port is not started **/ 11513 if (port->port_status != RTE_PORT_STOPPED) { 11514 printf("Please stop port %d first\n", res->port_id); 11515 return; 11516 } 11517 11518 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask)); 11519 ret = parse_flexbytes(res->mask, 11520 flex_mask.mask, 11521 RTE_ETH_FDIR_MAX_FLEXLEN); 11522 if (ret < 0) { 11523 printf("error: Cannot parse mask input.\n"); 11524 return; 11525 } 11526 11527 memset(&fdir_info, 0, sizeof(fdir_info)); 11528 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11529 RTE_ETH_FILTER_INFO, &fdir_info); 11530 if (ret < 0) { 11531 printf("Cannot get FDir filter info\n"); 11532 return; 11533 } 11534 11535 if (!strcmp(res->flow_type, "none")) { 11536 /* means don't specify the flow type */ 11537 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN; 11538 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) 11539 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i], 11540 0, sizeof(struct rte_eth_fdir_flex_mask)); 11541 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1; 11542 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0], 11543 &flex_mask, 11544 sizeof(struct rte_eth_fdir_flex_mask)); 11545 cmd_reconfig_device_queue(res->port_id, 1, 1); 11546 return; 11547 } 11548 flow_type_mask = fdir_info.flow_types_mask[0]; 11549 if (!strcmp(res->flow_type, "all")) { 11550 if (!flow_type_mask) { 11551 printf("No flow type supported\n"); 11552 return; 11553 } 11554 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) { 11555 if (flow_type_mask & (1ULL << i)) { 11556 flex_mask.flow_type = i; 11557 fdir_set_flex_mask(res->port_id, &flex_mask); 11558 } 11559 } 11560 cmd_reconfig_device_queue(res->port_id, 1, 1); 11561 return; 11562 } 11563 flex_mask.flow_type = str2flowtype(res->flow_type); 11564 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) { 11565 printf("Flow type %s not supported on port %d\n", 11566 res->flow_type, res->port_id); 11567 return; 11568 } 11569 fdir_set_flex_mask(res->port_id, &flex_mask); 11570 cmd_reconfig_device_queue(res->port_id, 1, 1); 11571 } 11572 11573 cmdline_parse_token_string_t cmd_flow_director_flexmask = 11574 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11575 flow_director_flexmask, 11576 "flow_director_flex_mask"); 11577 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id = 11578 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11579 port_id, UINT16); 11580 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow = 11581 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11582 flow, "flow"); 11583 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type = 11584 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11585 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 11586 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all"); 11587 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask = 11588 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11589 mask, NULL); 11590 11591 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = { 11592 .f = cmd_flow_director_flex_mask_parsed, 11593 .data = NULL, 11594 .help_str = "flow_director_flex_mask ... : " 11595 "Set flow director's flex mask on NIC", 11596 .tokens = { 11597 (void *)&cmd_flow_director_flexmask, 11598 (void *)&cmd_flow_director_flexmask_port_id, 11599 (void *)&cmd_flow_director_flexmask_flow, 11600 (void *)&cmd_flow_director_flexmask_flow_type, 11601 (void *)&cmd_flow_director_flexmask_mask, 11602 NULL, 11603 }, 11604 }; 11605 11606 /* *** deal with flow director flexible payload configuration *** */ 11607 struct cmd_flow_director_flexpayload_result { 11608 cmdline_fixed_string_t flow_director_flexpayload; 11609 portid_t port_id; 11610 cmdline_fixed_string_t payload_layer; 11611 cmdline_fixed_string_t payload_cfg; 11612 }; 11613 11614 static inline int 11615 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num) 11616 { 11617 char s[256]; 11618 const char *p, *p0 = q_arg; 11619 char *end; 11620 unsigned long int_fld; 11621 char *str_fld[max_num]; 11622 int i; 11623 unsigned size; 11624 int ret = -1; 11625 11626 p = strchr(p0, '('); 11627 if (p == NULL) 11628 return -1; 11629 ++p; 11630 p0 = strchr(p, ')'); 11631 if (p0 == NULL) 11632 return -1; 11633 11634 size = p0 - p; 11635 if (size >= sizeof(s)) 11636 return -1; 11637 11638 snprintf(s, sizeof(s), "%.*s", size, p); 11639 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 11640 if (ret < 0 || ret > max_num) 11641 return -1; 11642 for (i = 0; i < ret; i++) { 11643 errno = 0; 11644 int_fld = strtoul(str_fld[i], &end, 0); 11645 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX) 11646 return -1; 11647 offsets[i] = (uint16_t)int_fld; 11648 } 11649 return ret; 11650 } 11651 11652 static void 11653 cmd_flow_director_flxpld_parsed(void *parsed_result, 11654 __attribute__((unused)) struct cmdline *cl, 11655 __attribute__((unused)) void *data) 11656 { 11657 struct cmd_flow_director_flexpayload_result *res = parsed_result; 11658 struct rte_eth_flex_payload_cfg flex_cfg; 11659 struct rte_port *port; 11660 int ret = 0; 11661 11662 port = &ports[res->port_id]; 11663 /** Check if the port is not started **/ 11664 if (port->port_status != RTE_PORT_STOPPED) { 11665 printf("Please stop port %d first\n", res->port_id); 11666 return; 11667 } 11668 11669 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg)); 11670 11671 if (!strcmp(res->payload_layer, "raw")) 11672 flex_cfg.type = RTE_ETH_RAW_PAYLOAD; 11673 else if (!strcmp(res->payload_layer, "l2")) 11674 flex_cfg.type = RTE_ETH_L2_PAYLOAD; 11675 else if (!strcmp(res->payload_layer, "l3")) 11676 flex_cfg.type = RTE_ETH_L3_PAYLOAD; 11677 else if (!strcmp(res->payload_layer, "l4")) 11678 flex_cfg.type = RTE_ETH_L4_PAYLOAD; 11679 11680 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset, 11681 RTE_ETH_FDIR_MAX_FLEXLEN); 11682 if (ret < 0) { 11683 printf("error: Cannot parse flex payload input.\n"); 11684 return; 11685 } 11686 11687 fdir_set_flex_payload(res->port_id, &flex_cfg); 11688 cmd_reconfig_device_queue(res->port_id, 1, 1); 11689 } 11690 11691 cmdline_parse_token_string_t cmd_flow_director_flexpayload = 11692 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11693 flow_director_flexpayload, 11694 "flow_director_flex_payload"); 11695 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id = 11696 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11697 port_id, UINT16); 11698 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer = 11699 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11700 payload_layer, "raw#l2#l3#l4"); 11701 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg = 11702 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11703 payload_cfg, NULL); 11704 11705 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = { 11706 .f = cmd_flow_director_flxpld_parsed, 11707 .data = NULL, 11708 .help_str = "flow_director_flexpayload ... : " 11709 "Set flow director's flex payload on NIC", 11710 .tokens = { 11711 (void *)&cmd_flow_director_flexpayload, 11712 (void *)&cmd_flow_director_flexpayload_port_id, 11713 (void *)&cmd_flow_director_flexpayload_payload_layer, 11714 (void *)&cmd_flow_director_flexpayload_payload_cfg, 11715 NULL, 11716 }, 11717 }; 11718 11719 /* Generic flow interface command. */ 11720 extern cmdline_parse_inst_t cmd_flow; 11721 11722 /* *** Classification Filters Control *** */ 11723 /* *** Get symmetric hash enable per port *** */ 11724 struct cmd_get_sym_hash_ena_per_port_result { 11725 cmdline_fixed_string_t get_sym_hash_ena_per_port; 11726 portid_t port_id; 11727 }; 11728 11729 static void 11730 cmd_get_sym_hash_per_port_parsed(void *parsed_result, 11731 __rte_unused struct cmdline *cl, 11732 __rte_unused void *data) 11733 { 11734 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result; 11735 struct rte_eth_hash_filter_info info; 11736 int ret; 11737 11738 if (rte_eth_dev_filter_supported(res->port_id, 11739 RTE_ETH_FILTER_HASH) < 0) { 11740 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 11741 res->port_id); 11742 return; 11743 } 11744 11745 memset(&info, 0, sizeof(info)); 11746 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 11747 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11748 RTE_ETH_FILTER_GET, &info); 11749 11750 if (ret < 0) { 11751 printf("Cannot get symmetric hash enable per port " 11752 "on port %u\n", res->port_id); 11753 return; 11754 } 11755 11756 printf("Symmetric hash is %s on port %u\n", info.info.enable ? 11757 "enabled" : "disabled", res->port_id); 11758 } 11759 11760 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all = 11761 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 11762 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port"); 11763 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id = 11764 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 11765 port_id, UINT16); 11766 11767 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = { 11768 .f = cmd_get_sym_hash_per_port_parsed, 11769 .data = NULL, 11770 .help_str = "get_sym_hash_ena_per_port <port_id>", 11771 .tokens = { 11772 (void *)&cmd_get_sym_hash_ena_per_port_all, 11773 (void *)&cmd_get_sym_hash_ena_per_port_port_id, 11774 NULL, 11775 }, 11776 }; 11777 11778 /* *** Set symmetric hash enable per port *** */ 11779 struct cmd_set_sym_hash_ena_per_port_result { 11780 cmdline_fixed_string_t set_sym_hash_ena_per_port; 11781 cmdline_fixed_string_t enable; 11782 portid_t port_id; 11783 }; 11784 11785 static void 11786 cmd_set_sym_hash_per_port_parsed(void *parsed_result, 11787 __rte_unused struct cmdline *cl, 11788 __rte_unused void *data) 11789 { 11790 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result; 11791 struct rte_eth_hash_filter_info info; 11792 int ret; 11793 11794 if (rte_eth_dev_filter_supported(res->port_id, 11795 RTE_ETH_FILTER_HASH) < 0) { 11796 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 11797 res->port_id); 11798 return; 11799 } 11800 11801 memset(&info, 0, sizeof(info)); 11802 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 11803 if (!strcmp(res->enable, "enable")) 11804 info.info.enable = 1; 11805 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11806 RTE_ETH_FILTER_SET, &info); 11807 if (ret < 0) { 11808 printf("Cannot set symmetric hash enable per port on " 11809 "port %u\n", res->port_id); 11810 return; 11811 } 11812 printf("Symmetric hash has been set to %s on port %u\n", 11813 res->enable, res->port_id); 11814 } 11815 11816 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all = 11817 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11818 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port"); 11819 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id = 11820 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11821 port_id, UINT16); 11822 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable = 11823 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11824 enable, "enable#disable"); 11825 11826 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = { 11827 .f = cmd_set_sym_hash_per_port_parsed, 11828 .data = NULL, 11829 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable", 11830 .tokens = { 11831 (void *)&cmd_set_sym_hash_ena_per_port_all, 11832 (void *)&cmd_set_sym_hash_ena_per_port_port_id, 11833 (void *)&cmd_set_sym_hash_ena_per_port_enable, 11834 NULL, 11835 }, 11836 }; 11837 11838 /* Get global config of hash function */ 11839 struct cmd_get_hash_global_config_result { 11840 cmdline_fixed_string_t get_hash_global_config; 11841 portid_t port_id; 11842 }; 11843 11844 static char * 11845 flowtype_to_str(uint16_t ftype) 11846 { 11847 uint16_t i; 11848 static struct { 11849 char str[16]; 11850 uint16_t ftype; 11851 } ftype_table[] = { 11852 {"ipv4", RTE_ETH_FLOW_IPV4}, 11853 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 11854 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 11855 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 11856 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 11857 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 11858 {"ipv6", RTE_ETH_FLOW_IPV6}, 11859 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 11860 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 11861 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 11862 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 11863 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 11864 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 11865 {"port", RTE_ETH_FLOW_PORT}, 11866 {"vxlan", RTE_ETH_FLOW_VXLAN}, 11867 {"geneve", RTE_ETH_FLOW_GENEVE}, 11868 {"nvgre", RTE_ETH_FLOW_NVGRE}, 11869 }; 11870 11871 for (i = 0; i < RTE_DIM(ftype_table); i++) { 11872 if (ftype_table[i].ftype == ftype) 11873 return ftype_table[i].str; 11874 } 11875 11876 return NULL; 11877 } 11878 11879 static void 11880 cmd_get_hash_global_config_parsed(void *parsed_result, 11881 __rte_unused struct cmdline *cl, 11882 __rte_unused void *data) 11883 { 11884 struct cmd_get_hash_global_config_result *res = parsed_result; 11885 struct rte_eth_hash_filter_info info; 11886 uint32_t idx, offset; 11887 uint16_t i; 11888 char *str; 11889 int ret; 11890 11891 if (rte_eth_dev_filter_supported(res->port_id, 11892 RTE_ETH_FILTER_HASH) < 0) { 11893 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 11894 res->port_id); 11895 return; 11896 } 11897 11898 memset(&info, 0, sizeof(info)); 11899 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 11900 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11901 RTE_ETH_FILTER_GET, &info); 11902 if (ret < 0) { 11903 printf("Cannot get hash global configurations by port %d\n", 11904 res->port_id); 11905 return; 11906 } 11907 11908 switch (info.info.global_conf.hash_func) { 11909 case RTE_ETH_HASH_FUNCTION_TOEPLITZ: 11910 printf("Hash function is Toeplitz\n"); 11911 break; 11912 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: 11913 printf("Hash function is Simple XOR\n"); 11914 break; 11915 default: 11916 printf("Unknown hash function\n"); 11917 break; 11918 } 11919 11920 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) { 11921 idx = i / UINT64_BIT; 11922 offset = i % UINT64_BIT; 11923 if (!(info.info.global_conf.valid_bit_mask[idx] & 11924 (1ULL << offset))) 11925 continue; 11926 str = flowtype_to_str(i); 11927 if (!str) 11928 continue; 11929 printf("Symmetric hash is %s globally for flow type %s " 11930 "by port %d\n", 11931 ((info.info.global_conf.sym_hash_enable_mask[idx] & 11932 (1ULL << offset)) ? "enabled" : "disabled"), str, 11933 res->port_id); 11934 } 11935 } 11936 11937 cmdline_parse_token_string_t cmd_get_hash_global_config_all = 11938 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result, 11939 get_hash_global_config, "get_hash_global_config"); 11940 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id = 11941 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result, 11942 port_id, UINT16); 11943 11944 cmdline_parse_inst_t cmd_get_hash_global_config = { 11945 .f = cmd_get_hash_global_config_parsed, 11946 .data = NULL, 11947 .help_str = "get_hash_global_config <port_id>", 11948 .tokens = { 11949 (void *)&cmd_get_hash_global_config_all, 11950 (void *)&cmd_get_hash_global_config_port_id, 11951 NULL, 11952 }, 11953 }; 11954 11955 /* Set global config of hash function */ 11956 struct cmd_set_hash_global_config_result { 11957 cmdline_fixed_string_t set_hash_global_config; 11958 portid_t port_id; 11959 cmdline_fixed_string_t hash_func; 11960 cmdline_fixed_string_t flow_type; 11961 cmdline_fixed_string_t enable; 11962 }; 11963 11964 static void 11965 cmd_set_hash_global_config_parsed(void *parsed_result, 11966 __rte_unused struct cmdline *cl, 11967 __rte_unused void *data) 11968 { 11969 struct cmd_set_hash_global_config_result *res = parsed_result; 11970 struct rte_eth_hash_filter_info info; 11971 uint32_t ftype, idx, offset; 11972 int ret; 11973 11974 if (rte_eth_dev_filter_supported(res->port_id, 11975 RTE_ETH_FILTER_HASH) < 0) { 11976 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 11977 res->port_id); 11978 return; 11979 } 11980 memset(&info, 0, sizeof(info)); 11981 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 11982 if (!strcmp(res->hash_func, "toeplitz")) 11983 info.info.global_conf.hash_func = 11984 RTE_ETH_HASH_FUNCTION_TOEPLITZ; 11985 else if (!strcmp(res->hash_func, "simple_xor")) 11986 info.info.global_conf.hash_func = 11987 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; 11988 else if (!strcmp(res->hash_func, "default")) 11989 info.info.global_conf.hash_func = 11990 RTE_ETH_HASH_FUNCTION_DEFAULT; 11991 11992 ftype = str2flowtype(res->flow_type); 11993 idx = ftype / UINT64_BIT; 11994 offset = ftype % UINT64_BIT; 11995 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset); 11996 if (!strcmp(res->enable, "enable")) 11997 info.info.global_conf.sym_hash_enable_mask[idx] |= 11998 (1ULL << offset); 11999 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12000 RTE_ETH_FILTER_SET, &info); 12001 if (ret < 0) 12002 printf("Cannot set global hash configurations by port %d\n", 12003 res->port_id); 12004 else 12005 printf("Global hash configurations have been set " 12006 "succcessfully by port %d\n", res->port_id); 12007 } 12008 12009 cmdline_parse_token_string_t cmd_set_hash_global_config_all = 12010 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12011 set_hash_global_config, "set_hash_global_config"); 12012 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id = 12013 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result, 12014 port_id, UINT16); 12015 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func = 12016 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12017 hash_func, "toeplitz#simple_xor#default"); 12018 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type = 12019 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12020 flow_type, 12021 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#" 12022 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 12023 cmdline_parse_token_string_t cmd_set_hash_global_config_enable = 12024 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12025 enable, "enable#disable"); 12026 12027 cmdline_parse_inst_t cmd_set_hash_global_config = { 12028 .f = cmd_set_hash_global_config_parsed, 12029 .data = NULL, 12030 .help_str = "set_hash_global_config <port_id> " 12031 "toeplitz|simple_xor|default " 12032 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12033 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 12034 "l2_payload enable|disable", 12035 .tokens = { 12036 (void *)&cmd_set_hash_global_config_all, 12037 (void *)&cmd_set_hash_global_config_port_id, 12038 (void *)&cmd_set_hash_global_config_hash_func, 12039 (void *)&cmd_set_hash_global_config_flow_type, 12040 (void *)&cmd_set_hash_global_config_enable, 12041 NULL, 12042 }, 12043 }; 12044 12045 /* Set hash input set */ 12046 struct cmd_set_hash_input_set_result { 12047 cmdline_fixed_string_t set_hash_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 enum rte_eth_input_set_field 12055 str2inset(char *string) 12056 { 12057 uint16_t i; 12058 12059 static const struct { 12060 char str[32]; 12061 enum rte_eth_input_set_field inset; 12062 } inset_table[] = { 12063 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE}, 12064 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN}, 12065 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN}, 12066 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4}, 12067 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4}, 12068 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS}, 12069 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO}, 12070 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL}, 12071 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6}, 12072 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6}, 12073 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC}, 12074 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER}, 12075 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS}, 12076 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT}, 12077 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT}, 12078 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT}, 12079 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT}, 12080 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT}, 12081 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT}, 12082 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG}, 12083 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY}, 12084 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY}, 12085 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD}, 12086 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD}, 12087 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD}, 12088 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD}, 12089 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD}, 12090 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD}, 12091 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD}, 12092 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD}, 12093 {"none", RTE_ETH_INPUT_SET_NONE}, 12094 }; 12095 12096 for (i = 0; i < RTE_DIM(inset_table); i++) { 12097 if (!strcmp(string, inset_table[i].str)) 12098 return inset_table[i].inset; 12099 } 12100 12101 return RTE_ETH_INPUT_SET_UNKNOWN; 12102 } 12103 12104 static void 12105 cmd_set_hash_input_set_parsed(void *parsed_result, 12106 __rte_unused struct cmdline *cl, 12107 __rte_unused void *data) 12108 { 12109 struct cmd_set_hash_input_set_result *res = parsed_result; 12110 struct rte_eth_hash_filter_info info; 12111 12112 memset(&info, 0, sizeof(info)); 12113 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT; 12114 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 12115 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 12116 info.info.input_set_conf.inset_size = 1; 12117 if (!strcmp(res->select, "select")) 12118 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 12119 else if (!strcmp(res->select, "add")) 12120 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 12121 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12122 RTE_ETH_FILTER_SET, &info); 12123 } 12124 12125 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd = 12126 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12127 set_hash_input_set, "set_hash_input_set"); 12128 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id = 12129 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result, 12130 port_id, UINT16); 12131 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type = 12132 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12133 flow_type, NULL); 12134 cmdline_parse_token_string_t cmd_set_hash_input_set_field = 12135 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12136 inset_field, 12137 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12138 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#" 12139 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#" 12140 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#" 12141 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#" 12142 "fld-8th#none"); 12143 cmdline_parse_token_string_t cmd_set_hash_input_set_select = 12144 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12145 select, "select#add"); 12146 12147 cmdline_parse_inst_t cmd_set_hash_input_set = { 12148 .f = cmd_set_hash_input_set_parsed, 12149 .data = NULL, 12150 .help_str = "set_hash_input_set <port_id> " 12151 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12152 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> " 12153 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|" 12154 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|" 12155 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|" 12156 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|" 12157 "fld-7th|fld-8th|none select|add", 12158 .tokens = { 12159 (void *)&cmd_set_hash_input_set_cmd, 12160 (void *)&cmd_set_hash_input_set_port_id, 12161 (void *)&cmd_set_hash_input_set_flow_type, 12162 (void *)&cmd_set_hash_input_set_field, 12163 (void *)&cmd_set_hash_input_set_select, 12164 NULL, 12165 }, 12166 }; 12167 12168 /* Set flow director input set */ 12169 struct cmd_set_fdir_input_set_result { 12170 cmdline_fixed_string_t set_fdir_input_set; 12171 portid_t port_id; 12172 cmdline_fixed_string_t flow_type; 12173 cmdline_fixed_string_t inset_field; 12174 cmdline_fixed_string_t select; 12175 }; 12176 12177 static void 12178 cmd_set_fdir_input_set_parsed(void *parsed_result, 12179 __rte_unused struct cmdline *cl, 12180 __rte_unused void *data) 12181 { 12182 struct cmd_set_fdir_input_set_result *res = parsed_result; 12183 struct rte_eth_fdir_filter_info info; 12184 12185 memset(&info, 0, sizeof(info)); 12186 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT; 12187 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 12188 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 12189 info.info.input_set_conf.inset_size = 1; 12190 if (!strcmp(res->select, "select")) 12191 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 12192 else if (!strcmp(res->select, "add")) 12193 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 12194 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 12195 RTE_ETH_FILTER_SET, &info); 12196 } 12197 12198 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd = 12199 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12200 set_fdir_input_set, "set_fdir_input_set"); 12201 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id = 12202 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result, 12203 port_id, UINT16); 12204 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type = 12205 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12206 flow_type, 12207 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#" 12208 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 12209 cmdline_parse_token_string_t cmd_set_fdir_input_set_field = 12210 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12211 inset_field, 12212 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12213 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#" 12214 "ipv6-hop-limits#udp-src-port#udp-dst-port#" 12215 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#" 12216 "sctp-veri-tag#none"); 12217 cmdline_parse_token_string_t cmd_set_fdir_input_set_select = 12218 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12219 select, "select#add"); 12220 12221 cmdline_parse_inst_t cmd_set_fdir_input_set = { 12222 .f = cmd_set_fdir_input_set_parsed, 12223 .data = NULL, 12224 .help_str = "set_fdir_input_set <port_id> " 12225 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12226 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload " 12227 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|" 12228 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|" 12229 "ipv6-hop-limits|udp-src-port|udp-dst-port|" 12230 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|" 12231 "sctp-veri-tag|none select|add", 12232 .tokens = { 12233 (void *)&cmd_set_fdir_input_set_cmd, 12234 (void *)&cmd_set_fdir_input_set_port_id, 12235 (void *)&cmd_set_fdir_input_set_flow_type, 12236 (void *)&cmd_set_fdir_input_set_field, 12237 (void *)&cmd_set_fdir_input_set_select, 12238 NULL, 12239 }, 12240 }; 12241 12242 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ 12243 struct cmd_mcast_addr_result { 12244 cmdline_fixed_string_t mcast_addr_cmd; 12245 cmdline_fixed_string_t what; 12246 uint16_t port_num; 12247 struct ether_addr mc_addr; 12248 }; 12249 12250 static void cmd_mcast_addr_parsed(void *parsed_result, 12251 __attribute__((unused)) struct cmdline *cl, 12252 __attribute__((unused)) void *data) 12253 { 12254 struct cmd_mcast_addr_result *res = parsed_result; 12255 12256 if (!is_multicast_ether_addr(&res->mc_addr)) { 12257 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n", 12258 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1], 12259 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3], 12260 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]); 12261 return; 12262 } 12263 if (strcmp(res->what, "add") == 0) 12264 mcast_addr_add(res->port_num, &res->mc_addr); 12265 else 12266 mcast_addr_remove(res->port_num, &res->mc_addr); 12267 } 12268 12269 cmdline_parse_token_string_t cmd_mcast_addr_cmd = 12270 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, 12271 mcast_addr_cmd, "mcast_addr"); 12272 cmdline_parse_token_string_t cmd_mcast_addr_what = 12273 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, 12274 "add#remove"); 12275 cmdline_parse_token_num_t cmd_mcast_addr_portnum = 12276 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16); 12277 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = 12278 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 12279 12280 cmdline_parse_inst_t cmd_mcast_addr = { 12281 .f = cmd_mcast_addr_parsed, 12282 .data = (void *)0, 12283 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: " 12284 "Add/Remove multicast MAC address on port_id", 12285 .tokens = { 12286 (void *)&cmd_mcast_addr_cmd, 12287 (void *)&cmd_mcast_addr_what, 12288 (void *)&cmd_mcast_addr_portnum, 12289 (void *)&cmd_mcast_addr_addr, 12290 NULL, 12291 }, 12292 }; 12293 12294 /* l2 tunnel config 12295 * only support E-tag now. 12296 */ 12297 12298 /* Ether type config */ 12299 struct cmd_config_l2_tunnel_eth_type_result { 12300 cmdline_fixed_string_t port; 12301 cmdline_fixed_string_t config; 12302 cmdline_fixed_string_t all; 12303 portid_t id; 12304 cmdline_fixed_string_t l2_tunnel; 12305 cmdline_fixed_string_t l2_tunnel_type; 12306 cmdline_fixed_string_t eth_type; 12307 uint16_t eth_type_val; 12308 }; 12309 12310 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port = 12311 TOKEN_STRING_INITIALIZER 12312 (struct cmd_config_l2_tunnel_eth_type_result, 12313 port, "port"); 12314 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config = 12315 TOKEN_STRING_INITIALIZER 12316 (struct cmd_config_l2_tunnel_eth_type_result, 12317 config, "config"); 12318 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str = 12319 TOKEN_STRING_INITIALIZER 12320 (struct cmd_config_l2_tunnel_eth_type_result, 12321 all, "all"); 12322 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id = 12323 TOKEN_NUM_INITIALIZER 12324 (struct cmd_config_l2_tunnel_eth_type_result, 12325 id, UINT16); 12326 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel = 12327 TOKEN_STRING_INITIALIZER 12328 (struct cmd_config_l2_tunnel_eth_type_result, 12329 l2_tunnel, "l2-tunnel"); 12330 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type = 12331 TOKEN_STRING_INITIALIZER 12332 (struct cmd_config_l2_tunnel_eth_type_result, 12333 l2_tunnel_type, "E-tag"); 12334 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type = 12335 TOKEN_STRING_INITIALIZER 12336 (struct cmd_config_l2_tunnel_eth_type_result, 12337 eth_type, "ether-type"); 12338 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val = 12339 TOKEN_NUM_INITIALIZER 12340 (struct cmd_config_l2_tunnel_eth_type_result, 12341 eth_type_val, UINT16); 12342 12343 static enum rte_eth_tunnel_type 12344 str2fdir_l2_tunnel_type(char *string) 12345 { 12346 uint32_t i = 0; 12347 12348 static const struct { 12349 char str[32]; 12350 enum rte_eth_tunnel_type type; 12351 } l2_tunnel_type_str[] = { 12352 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG}, 12353 }; 12354 12355 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) { 12356 if (!strcmp(l2_tunnel_type_str[i].str, string)) 12357 return l2_tunnel_type_str[i].type; 12358 } 12359 return RTE_TUNNEL_TYPE_NONE; 12360 } 12361 12362 /* ether type config for all ports */ 12363 static void 12364 cmd_config_l2_tunnel_eth_type_all_parsed 12365 (void *parsed_result, 12366 __attribute__((unused)) struct cmdline *cl, 12367 __attribute__((unused)) void *data) 12368 { 12369 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result; 12370 struct rte_eth_l2_tunnel_conf entry; 12371 portid_t pid; 12372 12373 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12374 entry.ether_type = res->eth_type_val; 12375 12376 RTE_ETH_FOREACH_DEV(pid) { 12377 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry); 12378 } 12379 } 12380 12381 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = { 12382 .f = cmd_config_l2_tunnel_eth_type_all_parsed, 12383 .data = NULL, 12384 .help_str = "port config all l2-tunnel E-tag ether-type <value>", 12385 .tokens = { 12386 (void *)&cmd_config_l2_tunnel_eth_type_port, 12387 (void *)&cmd_config_l2_tunnel_eth_type_config, 12388 (void *)&cmd_config_l2_tunnel_eth_type_all_str, 12389 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 12390 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 12391 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 12392 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 12393 NULL, 12394 }, 12395 }; 12396 12397 /* ether type config for a specific port */ 12398 static void 12399 cmd_config_l2_tunnel_eth_type_specific_parsed( 12400 void *parsed_result, 12401 __attribute__((unused)) struct cmdline *cl, 12402 __attribute__((unused)) void *data) 12403 { 12404 struct cmd_config_l2_tunnel_eth_type_result *res = 12405 parsed_result; 12406 struct rte_eth_l2_tunnel_conf entry; 12407 12408 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12409 return; 12410 12411 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12412 entry.ether_type = res->eth_type_val; 12413 12414 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry); 12415 } 12416 12417 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = { 12418 .f = cmd_config_l2_tunnel_eth_type_specific_parsed, 12419 .data = NULL, 12420 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>", 12421 .tokens = { 12422 (void *)&cmd_config_l2_tunnel_eth_type_port, 12423 (void *)&cmd_config_l2_tunnel_eth_type_config, 12424 (void *)&cmd_config_l2_tunnel_eth_type_id, 12425 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 12426 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 12427 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 12428 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 12429 NULL, 12430 }, 12431 }; 12432 12433 /* Enable/disable l2 tunnel */ 12434 struct cmd_config_l2_tunnel_en_dis_result { 12435 cmdline_fixed_string_t port; 12436 cmdline_fixed_string_t config; 12437 cmdline_fixed_string_t all; 12438 portid_t id; 12439 cmdline_fixed_string_t l2_tunnel; 12440 cmdline_fixed_string_t l2_tunnel_type; 12441 cmdline_fixed_string_t en_dis; 12442 }; 12443 12444 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port = 12445 TOKEN_STRING_INITIALIZER 12446 (struct cmd_config_l2_tunnel_en_dis_result, 12447 port, "port"); 12448 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config = 12449 TOKEN_STRING_INITIALIZER 12450 (struct cmd_config_l2_tunnel_en_dis_result, 12451 config, "config"); 12452 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str = 12453 TOKEN_STRING_INITIALIZER 12454 (struct cmd_config_l2_tunnel_en_dis_result, 12455 all, "all"); 12456 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id = 12457 TOKEN_NUM_INITIALIZER 12458 (struct cmd_config_l2_tunnel_en_dis_result, 12459 id, UINT16); 12460 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel = 12461 TOKEN_STRING_INITIALIZER 12462 (struct cmd_config_l2_tunnel_en_dis_result, 12463 l2_tunnel, "l2-tunnel"); 12464 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type = 12465 TOKEN_STRING_INITIALIZER 12466 (struct cmd_config_l2_tunnel_en_dis_result, 12467 l2_tunnel_type, "E-tag"); 12468 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis = 12469 TOKEN_STRING_INITIALIZER 12470 (struct cmd_config_l2_tunnel_en_dis_result, 12471 en_dis, "enable#disable"); 12472 12473 /* enable/disable l2 tunnel for all ports */ 12474 static void 12475 cmd_config_l2_tunnel_en_dis_all_parsed( 12476 void *parsed_result, 12477 __attribute__((unused)) struct cmdline *cl, 12478 __attribute__((unused)) void *data) 12479 { 12480 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result; 12481 struct rte_eth_l2_tunnel_conf entry; 12482 portid_t pid; 12483 uint8_t en; 12484 12485 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12486 12487 if (!strcmp("enable", res->en_dis)) 12488 en = 1; 12489 else 12490 en = 0; 12491 12492 RTE_ETH_FOREACH_DEV(pid) { 12493 rte_eth_dev_l2_tunnel_offload_set(pid, 12494 &entry, 12495 ETH_L2_TUNNEL_ENABLE_MASK, 12496 en); 12497 } 12498 } 12499 12500 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = { 12501 .f = cmd_config_l2_tunnel_en_dis_all_parsed, 12502 .data = NULL, 12503 .help_str = "port config all l2-tunnel E-tag enable|disable", 12504 .tokens = { 12505 (void *)&cmd_config_l2_tunnel_en_dis_port, 12506 (void *)&cmd_config_l2_tunnel_en_dis_config, 12507 (void *)&cmd_config_l2_tunnel_en_dis_all_str, 12508 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12509 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12510 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12511 NULL, 12512 }, 12513 }; 12514 12515 /* enable/disable l2 tunnel for a port */ 12516 static void 12517 cmd_config_l2_tunnel_en_dis_specific_parsed( 12518 void *parsed_result, 12519 __attribute__((unused)) struct cmdline *cl, 12520 __attribute__((unused)) void *data) 12521 { 12522 struct cmd_config_l2_tunnel_en_dis_result *res = 12523 parsed_result; 12524 struct rte_eth_l2_tunnel_conf entry; 12525 12526 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12527 return; 12528 12529 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12530 12531 if (!strcmp("enable", res->en_dis)) 12532 rte_eth_dev_l2_tunnel_offload_set(res->id, 12533 &entry, 12534 ETH_L2_TUNNEL_ENABLE_MASK, 12535 1); 12536 else 12537 rte_eth_dev_l2_tunnel_offload_set(res->id, 12538 &entry, 12539 ETH_L2_TUNNEL_ENABLE_MASK, 12540 0); 12541 } 12542 12543 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = { 12544 .f = cmd_config_l2_tunnel_en_dis_specific_parsed, 12545 .data = NULL, 12546 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable", 12547 .tokens = { 12548 (void *)&cmd_config_l2_tunnel_en_dis_port, 12549 (void *)&cmd_config_l2_tunnel_en_dis_config, 12550 (void *)&cmd_config_l2_tunnel_en_dis_id, 12551 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12552 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12553 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12554 NULL, 12555 }, 12556 }; 12557 12558 /* E-tag configuration */ 12559 12560 /* Common result structure for all E-tag configuration */ 12561 struct cmd_config_e_tag_result { 12562 cmdline_fixed_string_t e_tag; 12563 cmdline_fixed_string_t set; 12564 cmdline_fixed_string_t insertion; 12565 cmdline_fixed_string_t stripping; 12566 cmdline_fixed_string_t forwarding; 12567 cmdline_fixed_string_t filter; 12568 cmdline_fixed_string_t add; 12569 cmdline_fixed_string_t del; 12570 cmdline_fixed_string_t on; 12571 cmdline_fixed_string_t off; 12572 cmdline_fixed_string_t on_off; 12573 cmdline_fixed_string_t port_tag_id; 12574 uint32_t port_tag_id_val; 12575 cmdline_fixed_string_t e_tag_id; 12576 uint16_t e_tag_id_val; 12577 cmdline_fixed_string_t dst_pool; 12578 uint8_t dst_pool_val; 12579 cmdline_fixed_string_t port; 12580 portid_t port_id; 12581 cmdline_fixed_string_t vf; 12582 uint8_t vf_id; 12583 }; 12584 12585 /* Common CLI fields for all E-tag configuration */ 12586 cmdline_parse_token_string_t cmd_config_e_tag_e_tag = 12587 TOKEN_STRING_INITIALIZER 12588 (struct cmd_config_e_tag_result, 12589 e_tag, "E-tag"); 12590 cmdline_parse_token_string_t cmd_config_e_tag_set = 12591 TOKEN_STRING_INITIALIZER 12592 (struct cmd_config_e_tag_result, 12593 set, "set"); 12594 cmdline_parse_token_string_t cmd_config_e_tag_insertion = 12595 TOKEN_STRING_INITIALIZER 12596 (struct cmd_config_e_tag_result, 12597 insertion, "insertion"); 12598 cmdline_parse_token_string_t cmd_config_e_tag_stripping = 12599 TOKEN_STRING_INITIALIZER 12600 (struct cmd_config_e_tag_result, 12601 stripping, "stripping"); 12602 cmdline_parse_token_string_t cmd_config_e_tag_forwarding = 12603 TOKEN_STRING_INITIALIZER 12604 (struct cmd_config_e_tag_result, 12605 forwarding, "forwarding"); 12606 cmdline_parse_token_string_t cmd_config_e_tag_filter = 12607 TOKEN_STRING_INITIALIZER 12608 (struct cmd_config_e_tag_result, 12609 filter, "filter"); 12610 cmdline_parse_token_string_t cmd_config_e_tag_add = 12611 TOKEN_STRING_INITIALIZER 12612 (struct cmd_config_e_tag_result, 12613 add, "add"); 12614 cmdline_parse_token_string_t cmd_config_e_tag_del = 12615 TOKEN_STRING_INITIALIZER 12616 (struct cmd_config_e_tag_result, 12617 del, "del"); 12618 cmdline_parse_token_string_t cmd_config_e_tag_on = 12619 TOKEN_STRING_INITIALIZER 12620 (struct cmd_config_e_tag_result, 12621 on, "on"); 12622 cmdline_parse_token_string_t cmd_config_e_tag_off = 12623 TOKEN_STRING_INITIALIZER 12624 (struct cmd_config_e_tag_result, 12625 off, "off"); 12626 cmdline_parse_token_string_t cmd_config_e_tag_on_off = 12627 TOKEN_STRING_INITIALIZER 12628 (struct cmd_config_e_tag_result, 12629 on_off, "on#off"); 12630 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id = 12631 TOKEN_STRING_INITIALIZER 12632 (struct cmd_config_e_tag_result, 12633 port_tag_id, "port-tag-id"); 12634 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val = 12635 TOKEN_NUM_INITIALIZER 12636 (struct cmd_config_e_tag_result, 12637 port_tag_id_val, UINT32); 12638 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id = 12639 TOKEN_STRING_INITIALIZER 12640 (struct cmd_config_e_tag_result, 12641 e_tag_id, "e-tag-id"); 12642 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val = 12643 TOKEN_NUM_INITIALIZER 12644 (struct cmd_config_e_tag_result, 12645 e_tag_id_val, UINT16); 12646 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool = 12647 TOKEN_STRING_INITIALIZER 12648 (struct cmd_config_e_tag_result, 12649 dst_pool, "dst-pool"); 12650 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val = 12651 TOKEN_NUM_INITIALIZER 12652 (struct cmd_config_e_tag_result, 12653 dst_pool_val, UINT8); 12654 cmdline_parse_token_string_t cmd_config_e_tag_port = 12655 TOKEN_STRING_INITIALIZER 12656 (struct cmd_config_e_tag_result, 12657 port, "port"); 12658 cmdline_parse_token_num_t cmd_config_e_tag_port_id = 12659 TOKEN_NUM_INITIALIZER 12660 (struct cmd_config_e_tag_result, 12661 port_id, UINT16); 12662 cmdline_parse_token_string_t cmd_config_e_tag_vf = 12663 TOKEN_STRING_INITIALIZER 12664 (struct cmd_config_e_tag_result, 12665 vf, "vf"); 12666 cmdline_parse_token_num_t cmd_config_e_tag_vf_id = 12667 TOKEN_NUM_INITIALIZER 12668 (struct cmd_config_e_tag_result, 12669 vf_id, UINT8); 12670 12671 /* E-tag insertion configuration */ 12672 static void 12673 cmd_config_e_tag_insertion_en_parsed( 12674 void *parsed_result, 12675 __attribute__((unused)) struct cmdline *cl, 12676 __attribute__((unused)) void *data) 12677 { 12678 struct cmd_config_e_tag_result *res = 12679 parsed_result; 12680 struct rte_eth_l2_tunnel_conf entry; 12681 12682 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12683 return; 12684 12685 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12686 entry.tunnel_id = res->port_tag_id_val; 12687 entry.vf_id = res->vf_id; 12688 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 12689 &entry, 12690 ETH_L2_TUNNEL_INSERTION_MASK, 12691 1); 12692 } 12693 12694 static void 12695 cmd_config_e_tag_insertion_dis_parsed( 12696 void *parsed_result, 12697 __attribute__((unused)) struct cmdline *cl, 12698 __attribute__((unused)) void *data) 12699 { 12700 struct cmd_config_e_tag_result *res = 12701 parsed_result; 12702 struct rte_eth_l2_tunnel_conf entry; 12703 12704 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12705 return; 12706 12707 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12708 entry.vf_id = res->vf_id; 12709 12710 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 12711 &entry, 12712 ETH_L2_TUNNEL_INSERTION_MASK, 12713 0); 12714 } 12715 12716 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = { 12717 .f = cmd_config_e_tag_insertion_en_parsed, 12718 .data = NULL, 12719 .help_str = "E-tag ... : E-tag insertion enable", 12720 .tokens = { 12721 (void *)&cmd_config_e_tag_e_tag, 12722 (void *)&cmd_config_e_tag_set, 12723 (void *)&cmd_config_e_tag_insertion, 12724 (void *)&cmd_config_e_tag_on, 12725 (void *)&cmd_config_e_tag_port_tag_id, 12726 (void *)&cmd_config_e_tag_port_tag_id_val, 12727 (void *)&cmd_config_e_tag_port, 12728 (void *)&cmd_config_e_tag_port_id, 12729 (void *)&cmd_config_e_tag_vf, 12730 (void *)&cmd_config_e_tag_vf_id, 12731 NULL, 12732 }, 12733 }; 12734 12735 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = { 12736 .f = cmd_config_e_tag_insertion_dis_parsed, 12737 .data = NULL, 12738 .help_str = "E-tag ... : E-tag insertion disable", 12739 .tokens = { 12740 (void *)&cmd_config_e_tag_e_tag, 12741 (void *)&cmd_config_e_tag_set, 12742 (void *)&cmd_config_e_tag_insertion, 12743 (void *)&cmd_config_e_tag_off, 12744 (void *)&cmd_config_e_tag_port, 12745 (void *)&cmd_config_e_tag_port_id, 12746 (void *)&cmd_config_e_tag_vf, 12747 (void *)&cmd_config_e_tag_vf_id, 12748 NULL, 12749 }, 12750 }; 12751 12752 /* E-tag stripping configuration */ 12753 static void 12754 cmd_config_e_tag_stripping_parsed( 12755 void *parsed_result, 12756 __attribute__((unused)) struct cmdline *cl, 12757 __attribute__((unused)) void *data) 12758 { 12759 struct cmd_config_e_tag_result *res = 12760 parsed_result; 12761 struct rte_eth_l2_tunnel_conf entry; 12762 12763 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12764 return; 12765 12766 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12767 12768 if (!strcmp(res->on_off, "on")) 12769 rte_eth_dev_l2_tunnel_offload_set 12770 (res->port_id, 12771 &entry, 12772 ETH_L2_TUNNEL_STRIPPING_MASK, 12773 1); 12774 else 12775 rte_eth_dev_l2_tunnel_offload_set 12776 (res->port_id, 12777 &entry, 12778 ETH_L2_TUNNEL_STRIPPING_MASK, 12779 0); 12780 } 12781 12782 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = { 12783 .f = cmd_config_e_tag_stripping_parsed, 12784 .data = NULL, 12785 .help_str = "E-tag ... : E-tag stripping enable/disable", 12786 .tokens = { 12787 (void *)&cmd_config_e_tag_e_tag, 12788 (void *)&cmd_config_e_tag_set, 12789 (void *)&cmd_config_e_tag_stripping, 12790 (void *)&cmd_config_e_tag_on_off, 12791 (void *)&cmd_config_e_tag_port, 12792 (void *)&cmd_config_e_tag_port_id, 12793 NULL, 12794 }, 12795 }; 12796 12797 /* E-tag forwarding configuration */ 12798 static void 12799 cmd_config_e_tag_forwarding_parsed( 12800 void *parsed_result, 12801 __attribute__((unused)) struct cmdline *cl, 12802 __attribute__((unused)) void *data) 12803 { 12804 struct cmd_config_e_tag_result *res = parsed_result; 12805 struct rte_eth_l2_tunnel_conf entry; 12806 12807 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12808 return; 12809 12810 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12811 12812 if (!strcmp(res->on_off, "on")) 12813 rte_eth_dev_l2_tunnel_offload_set 12814 (res->port_id, 12815 &entry, 12816 ETH_L2_TUNNEL_FORWARDING_MASK, 12817 1); 12818 else 12819 rte_eth_dev_l2_tunnel_offload_set 12820 (res->port_id, 12821 &entry, 12822 ETH_L2_TUNNEL_FORWARDING_MASK, 12823 0); 12824 } 12825 12826 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = { 12827 .f = cmd_config_e_tag_forwarding_parsed, 12828 .data = NULL, 12829 .help_str = "E-tag ... : E-tag forwarding enable/disable", 12830 .tokens = { 12831 (void *)&cmd_config_e_tag_e_tag, 12832 (void *)&cmd_config_e_tag_set, 12833 (void *)&cmd_config_e_tag_forwarding, 12834 (void *)&cmd_config_e_tag_on_off, 12835 (void *)&cmd_config_e_tag_port, 12836 (void *)&cmd_config_e_tag_port_id, 12837 NULL, 12838 }, 12839 }; 12840 12841 /* E-tag filter configuration */ 12842 static void 12843 cmd_config_e_tag_filter_add_parsed( 12844 void *parsed_result, 12845 __attribute__((unused)) struct cmdline *cl, 12846 __attribute__((unused)) void *data) 12847 { 12848 struct cmd_config_e_tag_result *res = parsed_result; 12849 struct rte_eth_l2_tunnel_conf entry; 12850 int ret = 0; 12851 12852 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12853 return; 12854 12855 if (res->e_tag_id_val > 0x3fff) { 12856 printf("e-tag-id must be equal or less than 0x3fff.\n"); 12857 return; 12858 } 12859 12860 ret = rte_eth_dev_filter_supported(res->port_id, 12861 RTE_ETH_FILTER_L2_TUNNEL); 12862 if (ret < 0) { 12863 printf("E-tag filter is not supported on port %u.\n", 12864 res->port_id); 12865 return; 12866 } 12867 12868 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12869 entry.tunnel_id = res->e_tag_id_val; 12870 entry.pool = res->dst_pool_val; 12871 12872 ret = rte_eth_dev_filter_ctrl(res->port_id, 12873 RTE_ETH_FILTER_L2_TUNNEL, 12874 RTE_ETH_FILTER_ADD, 12875 &entry); 12876 if (ret < 0) 12877 printf("E-tag filter programming error: (%s)\n", 12878 strerror(-ret)); 12879 } 12880 12881 cmdline_parse_inst_t cmd_config_e_tag_filter_add = { 12882 .f = cmd_config_e_tag_filter_add_parsed, 12883 .data = NULL, 12884 .help_str = "E-tag ... : E-tag filter add", 12885 .tokens = { 12886 (void *)&cmd_config_e_tag_e_tag, 12887 (void *)&cmd_config_e_tag_set, 12888 (void *)&cmd_config_e_tag_filter, 12889 (void *)&cmd_config_e_tag_add, 12890 (void *)&cmd_config_e_tag_e_tag_id, 12891 (void *)&cmd_config_e_tag_e_tag_id_val, 12892 (void *)&cmd_config_e_tag_dst_pool, 12893 (void *)&cmd_config_e_tag_dst_pool_val, 12894 (void *)&cmd_config_e_tag_port, 12895 (void *)&cmd_config_e_tag_port_id, 12896 NULL, 12897 }, 12898 }; 12899 12900 static void 12901 cmd_config_e_tag_filter_del_parsed( 12902 void *parsed_result, 12903 __attribute__((unused)) struct cmdline *cl, 12904 __attribute__((unused)) void *data) 12905 { 12906 struct cmd_config_e_tag_result *res = parsed_result; 12907 struct rte_eth_l2_tunnel_conf entry; 12908 int ret = 0; 12909 12910 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12911 return; 12912 12913 if (res->e_tag_id_val > 0x3fff) { 12914 printf("e-tag-id must be less than 0x3fff.\n"); 12915 return; 12916 } 12917 12918 ret = rte_eth_dev_filter_supported(res->port_id, 12919 RTE_ETH_FILTER_L2_TUNNEL); 12920 if (ret < 0) { 12921 printf("E-tag filter is not supported on port %u.\n", 12922 res->port_id); 12923 return; 12924 } 12925 12926 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12927 entry.tunnel_id = res->e_tag_id_val; 12928 12929 ret = rte_eth_dev_filter_ctrl(res->port_id, 12930 RTE_ETH_FILTER_L2_TUNNEL, 12931 RTE_ETH_FILTER_DELETE, 12932 &entry); 12933 if (ret < 0) 12934 printf("E-tag filter programming error: (%s)\n", 12935 strerror(-ret)); 12936 } 12937 12938 cmdline_parse_inst_t cmd_config_e_tag_filter_del = { 12939 .f = cmd_config_e_tag_filter_del_parsed, 12940 .data = NULL, 12941 .help_str = "E-tag ... : E-tag filter delete", 12942 .tokens = { 12943 (void *)&cmd_config_e_tag_e_tag, 12944 (void *)&cmd_config_e_tag_set, 12945 (void *)&cmd_config_e_tag_filter, 12946 (void *)&cmd_config_e_tag_del, 12947 (void *)&cmd_config_e_tag_e_tag_id, 12948 (void *)&cmd_config_e_tag_e_tag_id_val, 12949 (void *)&cmd_config_e_tag_port, 12950 (void *)&cmd_config_e_tag_port_id, 12951 NULL, 12952 }, 12953 }; 12954 12955 /* vf vlan anti spoof configuration */ 12956 12957 /* Common result structure for vf vlan anti spoof */ 12958 struct cmd_vf_vlan_anti_spoof_result { 12959 cmdline_fixed_string_t set; 12960 cmdline_fixed_string_t vf; 12961 cmdline_fixed_string_t vlan; 12962 cmdline_fixed_string_t antispoof; 12963 portid_t port_id; 12964 uint32_t vf_id; 12965 cmdline_fixed_string_t on_off; 12966 }; 12967 12968 /* Common CLI fields for vf vlan anti spoof enable disable */ 12969 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set = 12970 TOKEN_STRING_INITIALIZER 12971 (struct cmd_vf_vlan_anti_spoof_result, 12972 set, "set"); 12973 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf = 12974 TOKEN_STRING_INITIALIZER 12975 (struct cmd_vf_vlan_anti_spoof_result, 12976 vf, "vf"); 12977 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan = 12978 TOKEN_STRING_INITIALIZER 12979 (struct cmd_vf_vlan_anti_spoof_result, 12980 vlan, "vlan"); 12981 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof = 12982 TOKEN_STRING_INITIALIZER 12983 (struct cmd_vf_vlan_anti_spoof_result, 12984 antispoof, "antispoof"); 12985 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id = 12986 TOKEN_NUM_INITIALIZER 12987 (struct cmd_vf_vlan_anti_spoof_result, 12988 port_id, UINT16); 12989 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id = 12990 TOKEN_NUM_INITIALIZER 12991 (struct cmd_vf_vlan_anti_spoof_result, 12992 vf_id, UINT32); 12993 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off = 12994 TOKEN_STRING_INITIALIZER 12995 (struct cmd_vf_vlan_anti_spoof_result, 12996 on_off, "on#off"); 12997 12998 static void 12999 cmd_set_vf_vlan_anti_spoof_parsed( 13000 void *parsed_result, 13001 __attribute__((unused)) struct cmdline *cl, 13002 __attribute__((unused)) void *data) 13003 { 13004 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result; 13005 int ret = -ENOTSUP; 13006 13007 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13008 13009 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13010 return; 13011 13012 #ifdef RTE_LIBRTE_IXGBE_PMD 13013 if (ret == -ENOTSUP) 13014 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, 13015 res->vf_id, is_on); 13016 #endif 13017 #ifdef RTE_LIBRTE_I40E_PMD 13018 if (ret == -ENOTSUP) 13019 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id, 13020 res->vf_id, is_on); 13021 #endif 13022 #ifdef RTE_LIBRTE_BNXT_PMD 13023 if (ret == -ENOTSUP) 13024 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id, 13025 res->vf_id, is_on); 13026 #endif 13027 13028 switch (ret) { 13029 case 0: 13030 break; 13031 case -EINVAL: 13032 printf("invalid vf_id %d\n", res->vf_id); 13033 break; 13034 case -ENODEV: 13035 printf("invalid port_id %d\n", res->port_id); 13036 break; 13037 case -ENOTSUP: 13038 printf("function not implemented\n"); 13039 break; 13040 default: 13041 printf("programming error: (%s)\n", strerror(-ret)); 13042 } 13043 } 13044 13045 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = { 13046 .f = cmd_set_vf_vlan_anti_spoof_parsed, 13047 .data = NULL, 13048 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off", 13049 .tokens = { 13050 (void *)&cmd_vf_vlan_anti_spoof_set, 13051 (void *)&cmd_vf_vlan_anti_spoof_vf, 13052 (void *)&cmd_vf_vlan_anti_spoof_vlan, 13053 (void *)&cmd_vf_vlan_anti_spoof_antispoof, 13054 (void *)&cmd_vf_vlan_anti_spoof_port_id, 13055 (void *)&cmd_vf_vlan_anti_spoof_vf_id, 13056 (void *)&cmd_vf_vlan_anti_spoof_on_off, 13057 NULL, 13058 }, 13059 }; 13060 13061 /* vf mac anti spoof configuration */ 13062 13063 /* Common result structure for vf mac anti spoof */ 13064 struct cmd_vf_mac_anti_spoof_result { 13065 cmdline_fixed_string_t set; 13066 cmdline_fixed_string_t vf; 13067 cmdline_fixed_string_t mac; 13068 cmdline_fixed_string_t antispoof; 13069 portid_t port_id; 13070 uint32_t vf_id; 13071 cmdline_fixed_string_t on_off; 13072 }; 13073 13074 /* Common CLI fields for vf mac anti spoof enable disable */ 13075 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set = 13076 TOKEN_STRING_INITIALIZER 13077 (struct cmd_vf_mac_anti_spoof_result, 13078 set, "set"); 13079 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf = 13080 TOKEN_STRING_INITIALIZER 13081 (struct cmd_vf_mac_anti_spoof_result, 13082 vf, "vf"); 13083 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac = 13084 TOKEN_STRING_INITIALIZER 13085 (struct cmd_vf_mac_anti_spoof_result, 13086 mac, "mac"); 13087 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof = 13088 TOKEN_STRING_INITIALIZER 13089 (struct cmd_vf_mac_anti_spoof_result, 13090 antispoof, "antispoof"); 13091 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id = 13092 TOKEN_NUM_INITIALIZER 13093 (struct cmd_vf_mac_anti_spoof_result, 13094 port_id, UINT16); 13095 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id = 13096 TOKEN_NUM_INITIALIZER 13097 (struct cmd_vf_mac_anti_spoof_result, 13098 vf_id, UINT32); 13099 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off = 13100 TOKEN_STRING_INITIALIZER 13101 (struct cmd_vf_mac_anti_spoof_result, 13102 on_off, "on#off"); 13103 13104 static void 13105 cmd_set_vf_mac_anti_spoof_parsed( 13106 void *parsed_result, 13107 __attribute__((unused)) struct cmdline *cl, 13108 __attribute__((unused)) void *data) 13109 { 13110 struct cmd_vf_mac_anti_spoof_result *res = parsed_result; 13111 int ret = -ENOTSUP; 13112 13113 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13114 13115 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13116 return; 13117 13118 #ifdef RTE_LIBRTE_IXGBE_PMD 13119 if (ret == -ENOTSUP) 13120 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, 13121 res->vf_id, is_on); 13122 #endif 13123 #ifdef RTE_LIBRTE_I40E_PMD 13124 if (ret == -ENOTSUP) 13125 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id, 13126 res->vf_id, is_on); 13127 #endif 13128 #ifdef RTE_LIBRTE_BNXT_PMD 13129 if (ret == -ENOTSUP) 13130 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id, 13131 res->vf_id, is_on); 13132 #endif 13133 13134 switch (ret) { 13135 case 0: 13136 break; 13137 case -EINVAL: 13138 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13139 break; 13140 case -ENODEV: 13141 printf("invalid port_id %d\n", res->port_id); 13142 break; 13143 case -ENOTSUP: 13144 printf("function not implemented\n"); 13145 break; 13146 default: 13147 printf("programming error: (%s)\n", strerror(-ret)); 13148 } 13149 } 13150 13151 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = { 13152 .f = cmd_set_vf_mac_anti_spoof_parsed, 13153 .data = NULL, 13154 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off", 13155 .tokens = { 13156 (void *)&cmd_vf_mac_anti_spoof_set, 13157 (void *)&cmd_vf_mac_anti_spoof_vf, 13158 (void *)&cmd_vf_mac_anti_spoof_mac, 13159 (void *)&cmd_vf_mac_anti_spoof_antispoof, 13160 (void *)&cmd_vf_mac_anti_spoof_port_id, 13161 (void *)&cmd_vf_mac_anti_spoof_vf_id, 13162 (void *)&cmd_vf_mac_anti_spoof_on_off, 13163 NULL, 13164 }, 13165 }; 13166 13167 /* vf vlan strip queue configuration */ 13168 13169 /* Common result structure for vf mac anti spoof */ 13170 struct cmd_vf_vlan_stripq_result { 13171 cmdline_fixed_string_t set; 13172 cmdline_fixed_string_t vf; 13173 cmdline_fixed_string_t vlan; 13174 cmdline_fixed_string_t stripq; 13175 portid_t port_id; 13176 uint16_t vf_id; 13177 cmdline_fixed_string_t on_off; 13178 }; 13179 13180 /* Common CLI fields for vf vlan strip enable disable */ 13181 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set = 13182 TOKEN_STRING_INITIALIZER 13183 (struct cmd_vf_vlan_stripq_result, 13184 set, "set"); 13185 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf = 13186 TOKEN_STRING_INITIALIZER 13187 (struct cmd_vf_vlan_stripq_result, 13188 vf, "vf"); 13189 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan = 13190 TOKEN_STRING_INITIALIZER 13191 (struct cmd_vf_vlan_stripq_result, 13192 vlan, "vlan"); 13193 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq = 13194 TOKEN_STRING_INITIALIZER 13195 (struct cmd_vf_vlan_stripq_result, 13196 stripq, "stripq"); 13197 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id = 13198 TOKEN_NUM_INITIALIZER 13199 (struct cmd_vf_vlan_stripq_result, 13200 port_id, UINT16); 13201 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id = 13202 TOKEN_NUM_INITIALIZER 13203 (struct cmd_vf_vlan_stripq_result, 13204 vf_id, UINT16); 13205 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off = 13206 TOKEN_STRING_INITIALIZER 13207 (struct cmd_vf_vlan_stripq_result, 13208 on_off, "on#off"); 13209 13210 static void 13211 cmd_set_vf_vlan_stripq_parsed( 13212 void *parsed_result, 13213 __attribute__((unused)) struct cmdline *cl, 13214 __attribute__((unused)) void *data) 13215 { 13216 struct cmd_vf_vlan_stripq_result *res = parsed_result; 13217 int ret = -ENOTSUP; 13218 13219 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13220 13221 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13222 return; 13223 13224 #ifdef RTE_LIBRTE_IXGBE_PMD 13225 if (ret == -ENOTSUP) 13226 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, 13227 res->vf_id, is_on); 13228 #endif 13229 #ifdef RTE_LIBRTE_I40E_PMD 13230 if (ret == -ENOTSUP) 13231 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id, 13232 res->vf_id, is_on); 13233 #endif 13234 #ifdef RTE_LIBRTE_BNXT_PMD 13235 if (ret == -ENOTSUP) 13236 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id, 13237 res->vf_id, is_on); 13238 #endif 13239 13240 switch (ret) { 13241 case 0: 13242 break; 13243 case -EINVAL: 13244 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13245 break; 13246 case -ENODEV: 13247 printf("invalid port_id %d\n", res->port_id); 13248 break; 13249 case -ENOTSUP: 13250 printf("function not implemented\n"); 13251 break; 13252 default: 13253 printf("programming error: (%s)\n", strerror(-ret)); 13254 } 13255 } 13256 13257 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = { 13258 .f = cmd_set_vf_vlan_stripq_parsed, 13259 .data = NULL, 13260 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off", 13261 .tokens = { 13262 (void *)&cmd_vf_vlan_stripq_set, 13263 (void *)&cmd_vf_vlan_stripq_vf, 13264 (void *)&cmd_vf_vlan_stripq_vlan, 13265 (void *)&cmd_vf_vlan_stripq_stripq, 13266 (void *)&cmd_vf_vlan_stripq_port_id, 13267 (void *)&cmd_vf_vlan_stripq_vf_id, 13268 (void *)&cmd_vf_vlan_stripq_on_off, 13269 NULL, 13270 }, 13271 }; 13272 13273 /* vf vlan insert configuration */ 13274 13275 /* Common result structure for vf vlan insert */ 13276 struct cmd_vf_vlan_insert_result { 13277 cmdline_fixed_string_t set; 13278 cmdline_fixed_string_t vf; 13279 cmdline_fixed_string_t vlan; 13280 cmdline_fixed_string_t insert; 13281 portid_t port_id; 13282 uint16_t vf_id; 13283 uint16_t vlan_id; 13284 }; 13285 13286 /* Common CLI fields for vf vlan insert enable disable */ 13287 cmdline_parse_token_string_t cmd_vf_vlan_insert_set = 13288 TOKEN_STRING_INITIALIZER 13289 (struct cmd_vf_vlan_insert_result, 13290 set, "set"); 13291 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf = 13292 TOKEN_STRING_INITIALIZER 13293 (struct cmd_vf_vlan_insert_result, 13294 vf, "vf"); 13295 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan = 13296 TOKEN_STRING_INITIALIZER 13297 (struct cmd_vf_vlan_insert_result, 13298 vlan, "vlan"); 13299 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert = 13300 TOKEN_STRING_INITIALIZER 13301 (struct cmd_vf_vlan_insert_result, 13302 insert, "insert"); 13303 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id = 13304 TOKEN_NUM_INITIALIZER 13305 (struct cmd_vf_vlan_insert_result, 13306 port_id, UINT16); 13307 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id = 13308 TOKEN_NUM_INITIALIZER 13309 (struct cmd_vf_vlan_insert_result, 13310 vf_id, UINT16); 13311 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id = 13312 TOKEN_NUM_INITIALIZER 13313 (struct cmd_vf_vlan_insert_result, 13314 vlan_id, UINT16); 13315 13316 static void 13317 cmd_set_vf_vlan_insert_parsed( 13318 void *parsed_result, 13319 __attribute__((unused)) struct cmdline *cl, 13320 __attribute__((unused)) void *data) 13321 { 13322 struct cmd_vf_vlan_insert_result *res = parsed_result; 13323 int ret = -ENOTSUP; 13324 13325 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13326 return; 13327 13328 #ifdef RTE_LIBRTE_IXGBE_PMD 13329 if (ret == -ENOTSUP) 13330 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, 13331 res->vlan_id); 13332 #endif 13333 #ifdef RTE_LIBRTE_I40E_PMD 13334 if (ret == -ENOTSUP) 13335 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id, 13336 res->vlan_id); 13337 #endif 13338 #ifdef RTE_LIBRTE_BNXT_PMD 13339 if (ret == -ENOTSUP) 13340 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id, 13341 res->vlan_id); 13342 #endif 13343 13344 switch (ret) { 13345 case 0: 13346 break; 13347 case -EINVAL: 13348 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id); 13349 break; 13350 case -ENODEV: 13351 printf("invalid port_id %d\n", res->port_id); 13352 break; 13353 case -ENOTSUP: 13354 printf("function not implemented\n"); 13355 break; 13356 default: 13357 printf("programming error: (%s)\n", strerror(-ret)); 13358 } 13359 } 13360 13361 cmdline_parse_inst_t cmd_set_vf_vlan_insert = { 13362 .f = cmd_set_vf_vlan_insert_parsed, 13363 .data = NULL, 13364 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>", 13365 .tokens = { 13366 (void *)&cmd_vf_vlan_insert_set, 13367 (void *)&cmd_vf_vlan_insert_vf, 13368 (void *)&cmd_vf_vlan_insert_vlan, 13369 (void *)&cmd_vf_vlan_insert_insert, 13370 (void *)&cmd_vf_vlan_insert_port_id, 13371 (void *)&cmd_vf_vlan_insert_vf_id, 13372 (void *)&cmd_vf_vlan_insert_vlan_id, 13373 NULL, 13374 }, 13375 }; 13376 13377 /* tx loopback configuration */ 13378 13379 /* Common result structure for tx loopback */ 13380 struct cmd_tx_loopback_result { 13381 cmdline_fixed_string_t set; 13382 cmdline_fixed_string_t tx; 13383 cmdline_fixed_string_t loopback; 13384 portid_t port_id; 13385 cmdline_fixed_string_t on_off; 13386 }; 13387 13388 /* Common CLI fields for tx loopback enable disable */ 13389 cmdline_parse_token_string_t cmd_tx_loopback_set = 13390 TOKEN_STRING_INITIALIZER 13391 (struct cmd_tx_loopback_result, 13392 set, "set"); 13393 cmdline_parse_token_string_t cmd_tx_loopback_tx = 13394 TOKEN_STRING_INITIALIZER 13395 (struct cmd_tx_loopback_result, 13396 tx, "tx"); 13397 cmdline_parse_token_string_t cmd_tx_loopback_loopback = 13398 TOKEN_STRING_INITIALIZER 13399 (struct cmd_tx_loopback_result, 13400 loopback, "loopback"); 13401 cmdline_parse_token_num_t cmd_tx_loopback_port_id = 13402 TOKEN_NUM_INITIALIZER 13403 (struct cmd_tx_loopback_result, 13404 port_id, UINT16); 13405 cmdline_parse_token_string_t cmd_tx_loopback_on_off = 13406 TOKEN_STRING_INITIALIZER 13407 (struct cmd_tx_loopback_result, 13408 on_off, "on#off"); 13409 13410 static void 13411 cmd_set_tx_loopback_parsed( 13412 void *parsed_result, 13413 __attribute__((unused)) struct cmdline *cl, 13414 __attribute__((unused)) void *data) 13415 { 13416 struct cmd_tx_loopback_result *res = parsed_result; 13417 int ret = -ENOTSUP; 13418 13419 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13420 13421 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13422 return; 13423 13424 #ifdef RTE_LIBRTE_IXGBE_PMD 13425 if (ret == -ENOTSUP) 13426 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on); 13427 #endif 13428 #ifdef RTE_LIBRTE_I40E_PMD 13429 if (ret == -ENOTSUP) 13430 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on); 13431 #endif 13432 #ifdef RTE_LIBRTE_BNXT_PMD 13433 if (ret == -ENOTSUP) 13434 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on); 13435 #endif 13436 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD 13437 if (ret == -ENOTSUP) 13438 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on); 13439 #endif 13440 13441 switch (ret) { 13442 case 0: 13443 break; 13444 case -EINVAL: 13445 printf("invalid is_on %d\n", is_on); 13446 break; 13447 case -ENODEV: 13448 printf("invalid port_id %d\n", res->port_id); 13449 break; 13450 case -ENOTSUP: 13451 printf("function not implemented\n"); 13452 break; 13453 default: 13454 printf("programming error: (%s)\n", strerror(-ret)); 13455 } 13456 } 13457 13458 cmdline_parse_inst_t cmd_set_tx_loopback = { 13459 .f = cmd_set_tx_loopback_parsed, 13460 .data = NULL, 13461 .help_str = "set tx loopback <port_id> on|off", 13462 .tokens = { 13463 (void *)&cmd_tx_loopback_set, 13464 (void *)&cmd_tx_loopback_tx, 13465 (void *)&cmd_tx_loopback_loopback, 13466 (void *)&cmd_tx_loopback_port_id, 13467 (void *)&cmd_tx_loopback_on_off, 13468 NULL, 13469 }, 13470 }; 13471 13472 /* all queues drop enable configuration */ 13473 13474 /* Common result structure for all queues drop enable */ 13475 struct cmd_all_queues_drop_en_result { 13476 cmdline_fixed_string_t set; 13477 cmdline_fixed_string_t all; 13478 cmdline_fixed_string_t queues; 13479 cmdline_fixed_string_t drop; 13480 portid_t port_id; 13481 cmdline_fixed_string_t on_off; 13482 }; 13483 13484 /* Common CLI fields for tx loopback enable disable */ 13485 cmdline_parse_token_string_t cmd_all_queues_drop_en_set = 13486 TOKEN_STRING_INITIALIZER 13487 (struct cmd_all_queues_drop_en_result, 13488 set, "set"); 13489 cmdline_parse_token_string_t cmd_all_queues_drop_en_all = 13490 TOKEN_STRING_INITIALIZER 13491 (struct cmd_all_queues_drop_en_result, 13492 all, "all"); 13493 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues = 13494 TOKEN_STRING_INITIALIZER 13495 (struct cmd_all_queues_drop_en_result, 13496 queues, "queues"); 13497 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop = 13498 TOKEN_STRING_INITIALIZER 13499 (struct cmd_all_queues_drop_en_result, 13500 drop, "drop"); 13501 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id = 13502 TOKEN_NUM_INITIALIZER 13503 (struct cmd_all_queues_drop_en_result, 13504 port_id, UINT16); 13505 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off = 13506 TOKEN_STRING_INITIALIZER 13507 (struct cmd_all_queues_drop_en_result, 13508 on_off, "on#off"); 13509 13510 static void 13511 cmd_set_all_queues_drop_en_parsed( 13512 void *parsed_result, 13513 __attribute__((unused)) struct cmdline *cl, 13514 __attribute__((unused)) void *data) 13515 { 13516 struct cmd_all_queues_drop_en_result *res = parsed_result; 13517 int ret = -ENOTSUP; 13518 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13519 13520 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13521 return; 13522 13523 #ifdef RTE_LIBRTE_IXGBE_PMD 13524 if (ret == -ENOTSUP) 13525 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on); 13526 #endif 13527 #ifdef RTE_LIBRTE_BNXT_PMD 13528 if (ret == -ENOTSUP) 13529 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on); 13530 #endif 13531 switch (ret) { 13532 case 0: 13533 break; 13534 case -EINVAL: 13535 printf("invalid is_on %d\n", is_on); 13536 break; 13537 case -ENODEV: 13538 printf("invalid port_id %d\n", res->port_id); 13539 break; 13540 case -ENOTSUP: 13541 printf("function not implemented\n"); 13542 break; 13543 default: 13544 printf("programming error: (%s)\n", strerror(-ret)); 13545 } 13546 } 13547 13548 cmdline_parse_inst_t cmd_set_all_queues_drop_en = { 13549 .f = cmd_set_all_queues_drop_en_parsed, 13550 .data = NULL, 13551 .help_str = "set all queues drop <port_id> on|off", 13552 .tokens = { 13553 (void *)&cmd_all_queues_drop_en_set, 13554 (void *)&cmd_all_queues_drop_en_all, 13555 (void *)&cmd_all_queues_drop_en_queues, 13556 (void *)&cmd_all_queues_drop_en_drop, 13557 (void *)&cmd_all_queues_drop_en_port_id, 13558 (void *)&cmd_all_queues_drop_en_on_off, 13559 NULL, 13560 }, 13561 }; 13562 13563 /* vf split drop enable configuration */ 13564 13565 /* Common result structure for vf split drop enable */ 13566 struct cmd_vf_split_drop_en_result { 13567 cmdline_fixed_string_t set; 13568 cmdline_fixed_string_t vf; 13569 cmdline_fixed_string_t split; 13570 cmdline_fixed_string_t drop; 13571 portid_t port_id; 13572 uint16_t vf_id; 13573 cmdline_fixed_string_t on_off; 13574 }; 13575 13576 /* Common CLI fields for vf split drop enable disable */ 13577 cmdline_parse_token_string_t cmd_vf_split_drop_en_set = 13578 TOKEN_STRING_INITIALIZER 13579 (struct cmd_vf_split_drop_en_result, 13580 set, "set"); 13581 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf = 13582 TOKEN_STRING_INITIALIZER 13583 (struct cmd_vf_split_drop_en_result, 13584 vf, "vf"); 13585 cmdline_parse_token_string_t cmd_vf_split_drop_en_split = 13586 TOKEN_STRING_INITIALIZER 13587 (struct cmd_vf_split_drop_en_result, 13588 split, "split"); 13589 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop = 13590 TOKEN_STRING_INITIALIZER 13591 (struct cmd_vf_split_drop_en_result, 13592 drop, "drop"); 13593 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id = 13594 TOKEN_NUM_INITIALIZER 13595 (struct cmd_vf_split_drop_en_result, 13596 port_id, UINT16); 13597 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id = 13598 TOKEN_NUM_INITIALIZER 13599 (struct cmd_vf_split_drop_en_result, 13600 vf_id, UINT16); 13601 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off = 13602 TOKEN_STRING_INITIALIZER 13603 (struct cmd_vf_split_drop_en_result, 13604 on_off, "on#off"); 13605 13606 static void 13607 cmd_set_vf_split_drop_en_parsed( 13608 void *parsed_result, 13609 __attribute__((unused)) struct cmdline *cl, 13610 __attribute__((unused)) void *data) 13611 { 13612 struct cmd_vf_split_drop_en_result *res = parsed_result; 13613 int ret = -ENOTSUP; 13614 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13615 13616 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13617 return; 13618 13619 #ifdef RTE_LIBRTE_IXGBE_PMD 13620 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, 13621 is_on); 13622 #endif 13623 switch (ret) { 13624 case 0: 13625 break; 13626 case -EINVAL: 13627 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13628 break; 13629 case -ENODEV: 13630 printf("invalid port_id %d\n", res->port_id); 13631 break; 13632 case -ENOTSUP: 13633 printf("not supported on port %d\n", res->port_id); 13634 break; 13635 default: 13636 printf("programming error: (%s)\n", strerror(-ret)); 13637 } 13638 } 13639 13640 cmdline_parse_inst_t cmd_set_vf_split_drop_en = { 13641 .f = cmd_set_vf_split_drop_en_parsed, 13642 .data = NULL, 13643 .help_str = "set vf split drop <port_id> <vf_id> on|off", 13644 .tokens = { 13645 (void *)&cmd_vf_split_drop_en_set, 13646 (void *)&cmd_vf_split_drop_en_vf, 13647 (void *)&cmd_vf_split_drop_en_split, 13648 (void *)&cmd_vf_split_drop_en_drop, 13649 (void *)&cmd_vf_split_drop_en_port_id, 13650 (void *)&cmd_vf_split_drop_en_vf_id, 13651 (void *)&cmd_vf_split_drop_en_on_off, 13652 NULL, 13653 }, 13654 }; 13655 13656 /* vf mac address configuration */ 13657 13658 /* Common result structure for vf mac address */ 13659 struct cmd_set_vf_mac_addr_result { 13660 cmdline_fixed_string_t set; 13661 cmdline_fixed_string_t vf; 13662 cmdline_fixed_string_t mac; 13663 cmdline_fixed_string_t addr; 13664 portid_t port_id; 13665 uint16_t vf_id; 13666 struct ether_addr mac_addr; 13667 13668 }; 13669 13670 /* Common CLI fields for vf split drop enable disable */ 13671 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set = 13672 TOKEN_STRING_INITIALIZER 13673 (struct cmd_set_vf_mac_addr_result, 13674 set, "set"); 13675 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf = 13676 TOKEN_STRING_INITIALIZER 13677 (struct cmd_set_vf_mac_addr_result, 13678 vf, "vf"); 13679 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac = 13680 TOKEN_STRING_INITIALIZER 13681 (struct cmd_set_vf_mac_addr_result, 13682 mac, "mac"); 13683 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr = 13684 TOKEN_STRING_INITIALIZER 13685 (struct cmd_set_vf_mac_addr_result, 13686 addr, "addr"); 13687 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id = 13688 TOKEN_NUM_INITIALIZER 13689 (struct cmd_set_vf_mac_addr_result, 13690 port_id, UINT16); 13691 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id = 13692 TOKEN_NUM_INITIALIZER 13693 (struct cmd_set_vf_mac_addr_result, 13694 vf_id, UINT16); 13695 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr = 13696 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result, 13697 mac_addr); 13698 13699 static void 13700 cmd_set_vf_mac_addr_parsed( 13701 void *parsed_result, 13702 __attribute__((unused)) struct cmdline *cl, 13703 __attribute__((unused)) void *data) 13704 { 13705 struct cmd_set_vf_mac_addr_result *res = parsed_result; 13706 int ret = -ENOTSUP; 13707 13708 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13709 return; 13710 13711 #ifdef RTE_LIBRTE_IXGBE_PMD 13712 if (ret == -ENOTSUP) 13713 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, 13714 &res->mac_addr); 13715 #endif 13716 #ifdef RTE_LIBRTE_I40E_PMD 13717 if (ret == -ENOTSUP) 13718 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id, 13719 &res->mac_addr); 13720 #endif 13721 #ifdef RTE_LIBRTE_BNXT_PMD 13722 if (ret == -ENOTSUP) 13723 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id, 13724 &res->mac_addr); 13725 #endif 13726 13727 switch (ret) { 13728 case 0: 13729 break; 13730 case -EINVAL: 13731 printf("invalid vf_id %d or mac_addr\n", res->vf_id); 13732 break; 13733 case -ENODEV: 13734 printf("invalid port_id %d\n", res->port_id); 13735 break; 13736 case -ENOTSUP: 13737 printf("function not implemented\n"); 13738 break; 13739 default: 13740 printf("programming error: (%s)\n", strerror(-ret)); 13741 } 13742 } 13743 13744 cmdline_parse_inst_t cmd_set_vf_mac_addr = { 13745 .f = cmd_set_vf_mac_addr_parsed, 13746 .data = NULL, 13747 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>", 13748 .tokens = { 13749 (void *)&cmd_set_vf_mac_addr_set, 13750 (void *)&cmd_set_vf_mac_addr_vf, 13751 (void *)&cmd_set_vf_mac_addr_mac, 13752 (void *)&cmd_set_vf_mac_addr_addr, 13753 (void *)&cmd_set_vf_mac_addr_port_id, 13754 (void *)&cmd_set_vf_mac_addr_vf_id, 13755 (void *)&cmd_set_vf_mac_addr_mac_addr, 13756 NULL, 13757 }, 13758 }; 13759 13760 /* MACsec configuration */ 13761 13762 /* Common result structure for MACsec offload enable */ 13763 struct cmd_macsec_offload_on_result { 13764 cmdline_fixed_string_t set; 13765 cmdline_fixed_string_t macsec; 13766 cmdline_fixed_string_t offload; 13767 portid_t port_id; 13768 cmdline_fixed_string_t on; 13769 cmdline_fixed_string_t encrypt; 13770 cmdline_fixed_string_t en_on_off; 13771 cmdline_fixed_string_t replay_protect; 13772 cmdline_fixed_string_t rp_on_off; 13773 }; 13774 13775 /* Common CLI fields for MACsec offload disable */ 13776 cmdline_parse_token_string_t cmd_macsec_offload_on_set = 13777 TOKEN_STRING_INITIALIZER 13778 (struct cmd_macsec_offload_on_result, 13779 set, "set"); 13780 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec = 13781 TOKEN_STRING_INITIALIZER 13782 (struct cmd_macsec_offload_on_result, 13783 macsec, "macsec"); 13784 cmdline_parse_token_string_t cmd_macsec_offload_on_offload = 13785 TOKEN_STRING_INITIALIZER 13786 (struct cmd_macsec_offload_on_result, 13787 offload, "offload"); 13788 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id = 13789 TOKEN_NUM_INITIALIZER 13790 (struct cmd_macsec_offload_on_result, 13791 port_id, UINT16); 13792 cmdline_parse_token_string_t cmd_macsec_offload_on_on = 13793 TOKEN_STRING_INITIALIZER 13794 (struct cmd_macsec_offload_on_result, 13795 on, "on"); 13796 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt = 13797 TOKEN_STRING_INITIALIZER 13798 (struct cmd_macsec_offload_on_result, 13799 encrypt, "encrypt"); 13800 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off = 13801 TOKEN_STRING_INITIALIZER 13802 (struct cmd_macsec_offload_on_result, 13803 en_on_off, "on#off"); 13804 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect = 13805 TOKEN_STRING_INITIALIZER 13806 (struct cmd_macsec_offload_on_result, 13807 replay_protect, "replay-protect"); 13808 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off = 13809 TOKEN_STRING_INITIALIZER 13810 (struct cmd_macsec_offload_on_result, 13811 rp_on_off, "on#off"); 13812 13813 static void 13814 cmd_set_macsec_offload_on_parsed( 13815 void *parsed_result, 13816 __attribute__((unused)) struct cmdline *cl, 13817 __attribute__((unused)) void *data) 13818 { 13819 struct cmd_macsec_offload_on_result *res = parsed_result; 13820 int ret = -ENOTSUP; 13821 portid_t port_id = res->port_id; 13822 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; 13823 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; 13824 struct rte_eth_dev_info dev_info; 13825 13826 if (port_id_is_invalid(port_id, ENABLED_WARN)) 13827 return; 13828 if (!port_is_stopped(port_id)) { 13829 printf("Please stop port %d first\n", port_id); 13830 return; 13831 } 13832 13833 rte_eth_dev_info_get(port_id, &dev_info); 13834 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 13835 #ifdef RTE_LIBRTE_IXGBE_PMD 13836 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); 13837 #endif 13838 } 13839 RTE_SET_USED(en); 13840 RTE_SET_USED(rp); 13841 13842 switch (ret) { 13843 case 0: 13844 ports[port_id].dev_conf.txmode.offloads |= 13845 DEV_TX_OFFLOAD_MACSEC_INSERT; 13846 cmd_reconfig_device_queue(port_id, 1, 1); 13847 break; 13848 case -ENODEV: 13849 printf("invalid port_id %d\n", port_id); 13850 break; 13851 case -ENOTSUP: 13852 printf("not supported on port %d\n", port_id); 13853 break; 13854 default: 13855 printf("programming error: (%s)\n", strerror(-ret)); 13856 } 13857 } 13858 13859 cmdline_parse_inst_t cmd_set_macsec_offload_on = { 13860 .f = cmd_set_macsec_offload_on_parsed, 13861 .data = NULL, 13862 .help_str = "set macsec offload <port_id> on " 13863 "encrypt on|off replay-protect on|off", 13864 .tokens = { 13865 (void *)&cmd_macsec_offload_on_set, 13866 (void *)&cmd_macsec_offload_on_macsec, 13867 (void *)&cmd_macsec_offload_on_offload, 13868 (void *)&cmd_macsec_offload_on_port_id, 13869 (void *)&cmd_macsec_offload_on_on, 13870 (void *)&cmd_macsec_offload_on_encrypt, 13871 (void *)&cmd_macsec_offload_on_en_on_off, 13872 (void *)&cmd_macsec_offload_on_replay_protect, 13873 (void *)&cmd_macsec_offload_on_rp_on_off, 13874 NULL, 13875 }, 13876 }; 13877 13878 /* Common result structure for MACsec offload disable */ 13879 struct cmd_macsec_offload_off_result { 13880 cmdline_fixed_string_t set; 13881 cmdline_fixed_string_t macsec; 13882 cmdline_fixed_string_t offload; 13883 portid_t port_id; 13884 cmdline_fixed_string_t off; 13885 }; 13886 13887 /* Common CLI fields for MACsec offload disable */ 13888 cmdline_parse_token_string_t cmd_macsec_offload_off_set = 13889 TOKEN_STRING_INITIALIZER 13890 (struct cmd_macsec_offload_off_result, 13891 set, "set"); 13892 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec = 13893 TOKEN_STRING_INITIALIZER 13894 (struct cmd_macsec_offload_off_result, 13895 macsec, "macsec"); 13896 cmdline_parse_token_string_t cmd_macsec_offload_off_offload = 13897 TOKEN_STRING_INITIALIZER 13898 (struct cmd_macsec_offload_off_result, 13899 offload, "offload"); 13900 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id = 13901 TOKEN_NUM_INITIALIZER 13902 (struct cmd_macsec_offload_off_result, 13903 port_id, UINT16); 13904 cmdline_parse_token_string_t cmd_macsec_offload_off_off = 13905 TOKEN_STRING_INITIALIZER 13906 (struct cmd_macsec_offload_off_result, 13907 off, "off"); 13908 13909 static void 13910 cmd_set_macsec_offload_off_parsed( 13911 void *parsed_result, 13912 __attribute__((unused)) struct cmdline *cl, 13913 __attribute__((unused)) void *data) 13914 { 13915 struct cmd_macsec_offload_off_result *res = parsed_result; 13916 int ret = -ENOTSUP; 13917 struct rte_eth_dev_info dev_info; 13918 portid_t port_id = res->port_id; 13919 13920 if (port_id_is_invalid(port_id, ENABLED_WARN)) 13921 return; 13922 if (!port_is_stopped(port_id)) { 13923 printf("Please stop port %d first\n", port_id); 13924 return; 13925 } 13926 13927 rte_eth_dev_info_get(port_id, &dev_info); 13928 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 13929 #ifdef RTE_LIBRTE_IXGBE_PMD 13930 ret = rte_pmd_ixgbe_macsec_disable(port_id); 13931 #endif 13932 } 13933 switch (ret) { 13934 case 0: 13935 ports[port_id].dev_conf.txmode.offloads &= 13936 ~DEV_TX_OFFLOAD_MACSEC_INSERT; 13937 cmd_reconfig_device_queue(port_id, 1, 1); 13938 break; 13939 case -ENODEV: 13940 printf("invalid port_id %d\n", port_id); 13941 break; 13942 case -ENOTSUP: 13943 printf("not supported on port %d\n", port_id); 13944 break; 13945 default: 13946 printf("programming error: (%s)\n", strerror(-ret)); 13947 } 13948 } 13949 13950 cmdline_parse_inst_t cmd_set_macsec_offload_off = { 13951 .f = cmd_set_macsec_offload_off_parsed, 13952 .data = NULL, 13953 .help_str = "set macsec offload <port_id> off", 13954 .tokens = { 13955 (void *)&cmd_macsec_offload_off_set, 13956 (void *)&cmd_macsec_offload_off_macsec, 13957 (void *)&cmd_macsec_offload_off_offload, 13958 (void *)&cmd_macsec_offload_off_port_id, 13959 (void *)&cmd_macsec_offload_off_off, 13960 NULL, 13961 }, 13962 }; 13963 13964 /* Common result structure for MACsec secure connection configure */ 13965 struct cmd_macsec_sc_result { 13966 cmdline_fixed_string_t set; 13967 cmdline_fixed_string_t macsec; 13968 cmdline_fixed_string_t sc; 13969 cmdline_fixed_string_t tx_rx; 13970 portid_t port_id; 13971 struct ether_addr mac; 13972 uint16_t pi; 13973 }; 13974 13975 /* Common CLI fields for MACsec secure connection configure */ 13976 cmdline_parse_token_string_t cmd_macsec_sc_set = 13977 TOKEN_STRING_INITIALIZER 13978 (struct cmd_macsec_sc_result, 13979 set, "set"); 13980 cmdline_parse_token_string_t cmd_macsec_sc_macsec = 13981 TOKEN_STRING_INITIALIZER 13982 (struct cmd_macsec_sc_result, 13983 macsec, "macsec"); 13984 cmdline_parse_token_string_t cmd_macsec_sc_sc = 13985 TOKEN_STRING_INITIALIZER 13986 (struct cmd_macsec_sc_result, 13987 sc, "sc"); 13988 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx = 13989 TOKEN_STRING_INITIALIZER 13990 (struct cmd_macsec_sc_result, 13991 tx_rx, "tx#rx"); 13992 cmdline_parse_token_num_t cmd_macsec_sc_port_id = 13993 TOKEN_NUM_INITIALIZER 13994 (struct cmd_macsec_sc_result, 13995 port_id, UINT16); 13996 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac = 13997 TOKEN_ETHERADDR_INITIALIZER 13998 (struct cmd_macsec_sc_result, 13999 mac); 14000 cmdline_parse_token_num_t cmd_macsec_sc_pi = 14001 TOKEN_NUM_INITIALIZER 14002 (struct cmd_macsec_sc_result, 14003 pi, UINT16); 14004 14005 static void 14006 cmd_set_macsec_sc_parsed( 14007 void *parsed_result, 14008 __attribute__((unused)) struct cmdline *cl, 14009 __attribute__((unused)) void *data) 14010 { 14011 struct cmd_macsec_sc_result *res = parsed_result; 14012 int ret = -ENOTSUP; 14013 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 14014 14015 #ifdef RTE_LIBRTE_IXGBE_PMD 14016 ret = is_tx ? 14017 rte_pmd_ixgbe_macsec_config_txsc(res->port_id, 14018 res->mac.addr_bytes) : 14019 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, 14020 res->mac.addr_bytes, res->pi); 14021 #endif 14022 RTE_SET_USED(is_tx); 14023 14024 switch (ret) { 14025 case 0: 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_sc = { 14039 .f = cmd_set_macsec_sc_parsed, 14040 .data = NULL, 14041 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>", 14042 .tokens = { 14043 (void *)&cmd_macsec_sc_set, 14044 (void *)&cmd_macsec_sc_macsec, 14045 (void *)&cmd_macsec_sc_sc, 14046 (void *)&cmd_macsec_sc_tx_rx, 14047 (void *)&cmd_macsec_sc_port_id, 14048 (void *)&cmd_macsec_sc_mac, 14049 (void *)&cmd_macsec_sc_pi, 14050 NULL, 14051 }, 14052 }; 14053 14054 /* Common result structure for MACsec secure connection configure */ 14055 struct cmd_macsec_sa_result { 14056 cmdline_fixed_string_t set; 14057 cmdline_fixed_string_t macsec; 14058 cmdline_fixed_string_t sa; 14059 cmdline_fixed_string_t tx_rx; 14060 portid_t port_id; 14061 uint8_t idx; 14062 uint8_t an; 14063 uint32_t pn; 14064 cmdline_fixed_string_t key; 14065 }; 14066 14067 /* Common CLI fields for MACsec secure connection configure */ 14068 cmdline_parse_token_string_t cmd_macsec_sa_set = 14069 TOKEN_STRING_INITIALIZER 14070 (struct cmd_macsec_sa_result, 14071 set, "set"); 14072 cmdline_parse_token_string_t cmd_macsec_sa_macsec = 14073 TOKEN_STRING_INITIALIZER 14074 (struct cmd_macsec_sa_result, 14075 macsec, "macsec"); 14076 cmdline_parse_token_string_t cmd_macsec_sa_sa = 14077 TOKEN_STRING_INITIALIZER 14078 (struct cmd_macsec_sa_result, 14079 sa, "sa"); 14080 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx = 14081 TOKEN_STRING_INITIALIZER 14082 (struct cmd_macsec_sa_result, 14083 tx_rx, "tx#rx"); 14084 cmdline_parse_token_num_t cmd_macsec_sa_port_id = 14085 TOKEN_NUM_INITIALIZER 14086 (struct cmd_macsec_sa_result, 14087 port_id, UINT16); 14088 cmdline_parse_token_num_t cmd_macsec_sa_idx = 14089 TOKEN_NUM_INITIALIZER 14090 (struct cmd_macsec_sa_result, 14091 idx, UINT8); 14092 cmdline_parse_token_num_t cmd_macsec_sa_an = 14093 TOKEN_NUM_INITIALIZER 14094 (struct cmd_macsec_sa_result, 14095 an, UINT8); 14096 cmdline_parse_token_num_t cmd_macsec_sa_pn = 14097 TOKEN_NUM_INITIALIZER 14098 (struct cmd_macsec_sa_result, 14099 pn, UINT32); 14100 cmdline_parse_token_string_t cmd_macsec_sa_key = 14101 TOKEN_STRING_INITIALIZER 14102 (struct cmd_macsec_sa_result, 14103 key, NULL); 14104 14105 static void 14106 cmd_set_macsec_sa_parsed( 14107 void *parsed_result, 14108 __attribute__((unused)) struct cmdline *cl, 14109 __attribute__((unused)) void *data) 14110 { 14111 struct cmd_macsec_sa_result *res = parsed_result; 14112 int ret = -ENOTSUP; 14113 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 14114 uint8_t key[16] = { 0 }; 14115 uint8_t xdgt0; 14116 uint8_t xdgt1; 14117 int key_len; 14118 int i; 14119 14120 key_len = strlen(res->key) / 2; 14121 if (key_len > 16) 14122 key_len = 16; 14123 14124 for (i = 0; i < key_len; i++) { 14125 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 14126 if (xdgt0 == 0xFF) 14127 return; 14128 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 14129 if (xdgt1 == 0xFF) 14130 return; 14131 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 14132 } 14133 14134 #ifdef RTE_LIBRTE_IXGBE_PMD 14135 ret = is_tx ? 14136 rte_pmd_ixgbe_macsec_select_txsa(res->port_id, 14137 res->idx, res->an, res->pn, key) : 14138 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id, 14139 res->idx, res->an, res->pn, key); 14140 #endif 14141 RTE_SET_USED(is_tx); 14142 RTE_SET_USED(key); 14143 14144 switch (ret) { 14145 case 0: 14146 break; 14147 case -EINVAL: 14148 printf("invalid idx %d or an %d\n", res->idx, res->an); 14149 break; 14150 case -ENODEV: 14151 printf("invalid port_id %d\n", res->port_id); 14152 break; 14153 case -ENOTSUP: 14154 printf("not supported on port %d\n", res->port_id); 14155 break; 14156 default: 14157 printf("programming error: (%s)\n", strerror(-ret)); 14158 } 14159 } 14160 14161 cmdline_parse_inst_t cmd_set_macsec_sa = { 14162 .f = cmd_set_macsec_sa_parsed, 14163 .data = NULL, 14164 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>", 14165 .tokens = { 14166 (void *)&cmd_macsec_sa_set, 14167 (void *)&cmd_macsec_sa_macsec, 14168 (void *)&cmd_macsec_sa_sa, 14169 (void *)&cmd_macsec_sa_tx_rx, 14170 (void *)&cmd_macsec_sa_port_id, 14171 (void *)&cmd_macsec_sa_idx, 14172 (void *)&cmd_macsec_sa_an, 14173 (void *)&cmd_macsec_sa_pn, 14174 (void *)&cmd_macsec_sa_key, 14175 NULL, 14176 }, 14177 }; 14178 14179 /* VF unicast promiscuous mode configuration */ 14180 14181 /* Common result structure for VF unicast promiscuous mode */ 14182 struct cmd_vf_promisc_result { 14183 cmdline_fixed_string_t set; 14184 cmdline_fixed_string_t vf; 14185 cmdline_fixed_string_t promisc; 14186 portid_t port_id; 14187 uint32_t vf_id; 14188 cmdline_fixed_string_t on_off; 14189 }; 14190 14191 /* Common CLI fields for VF unicast promiscuous mode enable disable */ 14192 cmdline_parse_token_string_t cmd_vf_promisc_set = 14193 TOKEN_STRING_INITIALIZER 14194 (struct cmd_vf_promisc_result, 14195 set, "set"); 14196 cmdline_parse_token_string_t cmd_vf_promisc_vf = 14197 TOKEN_STRING_INITIALIZER 14198 (struct cmd_vf_promisc_result, 14199 vf, "vf"); 14200 cmdline_parse_token_string_t cmd_vf_promisc_promisc = 14201 TOKEN_STRING_INITIALIZER 14202 (struct cmd_vf_promisc_result, 14203 promisc, "promisc"); 14204 cmdline_parse_token_num_t cmd_vf_promisc_port_id = 14205 TOKEN_NUM_INITIALIZER 14206 (struct cmd_vf_promisc_result, 14207 port_id, UINT16); 14208 cmdline_parse_token_num_t cmd_vf_promisc_vf_id = 14209 TOKEN_NUM_INITIALIZER 14210 (struct cmd_vf_promisc_result, 14211 vf_id, UINT32); 14212 cmdline_parse_token_string_t cmd_vf_promisc_on_off = 14213 TOKEN_STRING_INITIALIZER 14214 (struct cmd_vf_promisc_result, 14215 on_off, "on#off"); 14216 14217 static void 14218 cmd_set_vf_promisc_parsed( 14219 void *parsed_result, 14220 __attribute__((unused)) struct cmdline *cl, 14221 __attribute__((unused)) void *data) 14222 { 14223 struct cmd_vf_promisc_result *res = parsed_result; 14224 int ret = -ENOTSUP; 14225 14226 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14227 14228 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14229 return; 14230 14231 #ifdef RTE_LIBRTE_I40E_PMD 14232 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id, 14233 res->vf_id, is_on); 14234 #endif 14235 14236 switch (ret) { 14237 case 0: 14238 break; 14239 case -EINVAL: 14240 printf("invalid vf_id %d\n", res->vf_id); 14241 break; 14242 case -ENODEV: 14243 printf("invalid port_id %d\n", res->port_id); 14244 break; 14245 case -ENOTSUP: 14246 printf("function not implemented\n"); 14247 break; 14248 default: 14249 printf("programming error: (%s)\n", strerror(-ret)); 14250 } 14251 } 14252 14253 cmdline_parse_inst_t cmd_set_vf_promisc = { 14254 .f = cmd_set_vf_promisc_parsed, 14255 .data = NULL, 14256 .help_str = "set vf promisc <port_id> <vf_id> on|off: " 14257 "Set unicast promiscuous mode for a VF from the PF", 14258 .tokens = { 14259 (void *)&cmd_vf_promisc_set, 14260 (void *)&cmd_vf_promisc_vf, 14261 (void *)&cmd_vf_promisc_promisc, 14262 (void *)&cmd_vf_promisc_port_id, 14263 (void *)&cmd_vf_promisc_vf_id, 14264 (void *)&cmd_vf_promisc_on_off, 14265 NULL, 14266 }, 14267 }; 14268 14269 /* VF multicast promiscuous mode configuration */ 14270 14271 /* Common result structure for VF multicast promiscuous mode */ 14272 struct cmd_vf_allmulti_result { 14273 cmdline_fixed_string_t set; 14274 cmdline_fixed_string_t vf; 14275 cmdline_fixed_string_t allmulti; 14276 portid_t port_id; 14277 uint32_t vf_id; 14278 cmdline_fixed_string_t on_off; 14279 }; 14280 14281 /* Common CLI fields for VF multicast promiscuous mode enable disable */ 14282 cmdline_parse_token_string_t cmd_vf_allmulti_set = 14283 TOKEN_STRING_INITIALIZER 14284 (struct cmd_vf_allmulti_result, 14285 set, "set"); 14286 cmdline_parse_token_string_t cmd_vf_allmulti_vf = 14287 TOKEN_STRING_INITIALIZER 14288 (struct cmd_vf_allmulti_result, 14289 vf, "vf"); 14290 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti = 14291 TOKEN_STRING_INITIALIZER 14292 (struct cmd_vf_allmulti_result, 14293 allmulti, "allmulti"); 14294 cmdline_parse_token_num_t cmd_vf_allmulti_port_id = 14295 TOKEN_NUM_INITIALIZER 14296 (struct cmd_vf_allmulti_result, 14297 port_id, UINT16); 14298 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id = 14299 TOKEN_NUM_INITIALIZER 14300 (struct cmd_vf_allmulti_result, 14301 vf_id, UINT32); 14302 cmdline_parse_token_string_t cmd_vf_allmulti_on_off = 14303 TOKEN_STRING_INITIALIZER 14304 (struct cmd_vf_allmulti_result, 14305 on_off, "on#off"); 14306 14307 static void 14308 cmd_set_vf_allmulti_parsed( 14309 void *parsed_result, 14310 __attribute__((unused)) struct cmdline *cl, 14311 __attribute__((unused)) void *data) 14312 { 14313 struct cmd_vf_allmulti_result *res = parsed_result; 14314 int ret = -ENOTSUP; 14315 14316 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14317 14318 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14319 return; 14320 14321 #ifdef RTE_LIBRTE_I40E_PMD 14322 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id, 14323 res->vf_id, is_on); 14324 #endif 14325 14326 switch (ret) { 14327 case 0: 14328 break; 14329 case -EINVAL: 14330 printf("invalid vf_id %d\n", res->vf_id); 14331 break; 14332 case -ENODEV: 14333 printf("invalid port_id %d\n", res->port_id); 14334 break; 14335 case -ENOTSUP: 14336 printf("function not implemented\n"); 14337 break; 14338 default: 14339 printf("programming error: (%s)\n", strerror(-ret)); 14340 } 14341 } 14342 14343 cmdline_parse_inst_t cmd_set_vf_allmulti = { 14344 .f = cmd_set_vf_allmulti_parsed, 14345 .data = NULL, 14346 .help_str = "set vf allmulti <port_id> <vf_id> on|off: " 14347 "Set multicast promiscuous mode for a VF from the PF", 14348 .tokens = { 14349 (void *)&cmd_vf_allmulti_set, 14350 (void *)&cmd_vf_allmulti_vf, 14351 (void *)&cmd_vf_allmulti_allmulti, 14352 (void *)&cmd_vf_allmulti_port_id, 14353 (void *)&cmd_vf_allmulti_vf_id, 14354 (void *)&cmd_vf_allmulti_on_off, 14355 NULL, 14356 }, 14357 }; 14358 14359 /* vf broadcast mode configuration */ 14360 14361 /* Common result structure for vf broadcast */ 14362 struct cmd_set_vf_broadcast_result { 14363 cmdline_fixed_string_t set; 14364 cmdline_fixed_string_t vf; 14365 cmdline_fixed_string_t broadcast; 14366 portid_t port_id; 14367 uint16_t vf_id; 14368 cmdline_fixed_string_t on_off; 14369 }; 14370 14371 /* Common CLI fields for vf broadcast enable disable */ 14372 cmdline_parse_token_string_t cmd_set_vf_broadcast_set = 14373 TOKEN_STRING_INITIALIZER 14374 (struct cmd_set_vf_broadcast_result, 14375 set, "set"); 14376 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf = 14377 TOKEN_STRING_INITIALIZER 14378 (struct cmd_set_vf_broadcast_result, 14379 vf, "vf"); 14380 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast = 14381 TOKEN_STRING_INITIALIZER 14382 (struct cmd_set_vf_broadcast_result, 14383 broadcast, "broadcast"); 14384 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id = 14385 TOKEN_NUM_INITIALIZER 14386 (struct cmd_set_vf_broadcast_result, 14387 port_id, UINT16); 14388 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id = 14389 TOKEN_NUM_INITIALIZER 14390 (struct cmd_set_vf_broadcast_result, 14391 vf_id, UINT16); 14392 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off = 14393 TOKEN_STRING_INITIALIZER 14394 (struct cmd_set_vf_broadcast_result, 14395 on_off, "on#off"); 14396 14397 static void 14398 cmd_set_vf_broadcast_parsed( 14399 void *parsed_result, 14400 __attribute__((unused)) struct cmdline *cl, 14401 __attribute__((unused)) void *data) 14402 { 14403 struct cmd_set_vf_broadcast_result *res = parsed_result; 14404 int ret = -ENOTSUP; 14405 14406 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14407 14408 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14409 return; 14410 14411 #ifdef RTE_LIBRTE_I40E_PMD 14412 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id, 14413 res->vf_id, is_on); 14414 #endif 14415 14416 switch (ret) { 14417 case 0: 14418 break; 14419 case -EINVAL: 14420 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14421 break; 14422 case -ENODEV: 14423 printf("invalid port_id %d\n", res->port_id); 14424 break; 14425 case -ENOTSUP: 14426 printf("function not implemented\n"); 14427 break; 14428 default: 14429 printf("programming error: (%s)\n", strerror(-ret)); 14430 } 14431 } 14432 14433 cmdline_parse_inst_t cmd_set_vf_broadcast = { 14434 .f = cmd_set_vf_broadcast_parsed, 14435 .data = NULL, 14436 .help_str = "set vf broadcast <port_id> <vf_id> on|off", 14437 .tokens = { 14438 (void *)&cmd_set_vf_broadcast_set, 14439 (void *)&cmd_set_vf_broadcast_vf, 14440 (void *)&cmd_set_vf_broadcast_broadcast, 14441 (void *)&cmd_set_vf_broadcast_port_id, 14442 (void *)&cmd_set_vf_broadcast_vf_id, 14443 (void *)&cmd_set_vf_broadcast_on_off, 14444 NULL, 14445 }, 14446 }; 14447 14448 /* vf vlan tag configuration */ 14449 14450 /* Common result structure for vf vlan tag */ 14451 struct cmd_set_vf_vlan_tag_result { 14452 cmdline_fixed_string_t set; 14453 cmdline_fixed_string_t vf; 14454 cmdline_fixed_string_t vlan; 14455 cmdline_fixed_string_t tag; 14456 portid_t port_id; 14457 uint16_t vf_id; 14458 cmdline_fixed_string_t on_off; 14459 }; 14460 14461 /* Common CLI fields for vf vlan tag enable disable */ 14462 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set = 14463 TOKEN_STRING_INITIALIZER 14464 (struct cmd_set_vf_vlan_tag_result, 14465 set, "set"); 14466 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf = 14467 TOKEN_STRING_INITIALIZER 14468 (struct cmd_set_vf_vlan_tag_result, 14469 vf, "vf"); 14470 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan = 14471 TOKEN_STRING_INITIALIZER 14472 (struct cmd_set_vf_vlan_tag_result, 14473 vlan, "vlan"); 14474 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag = 14475 TOKEN_STRING_INITIALIZER 14476 (struct cmd_set_vf_vlan_tag_result, 14477 tag, "tag"); 14478 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id = 14479 TOKEN_NUM_INITIALIZER 14480 (struct cmd_set_vf_vlan_tag_result, 14481 port_id, UINT16); 14482 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id = 14483 TOKEN_NUM_INITIALIZER 14484 (struct cmd_set_vf_vlan_tag_result, 14485 vf_id, UINT16); 14486 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off = 14487 TOKEN_STRING_INITIALIZER 14488 (struct cmd_set_vf_vlan_tag_result, 14489 on_off, "on#off"); 14490 14491 static void 14492 cmd_set_vf_vlan_tag_parsed( 14493 void *parsed_result, 14494 __attribute__((unused)) struct cmdline *cl, 14495 __attribute__((unused)) void *data) 14496 { 14497 struct cmd_set_vf_vlan_tag_result *res = parsed_result; 14498 int ret = -ENOTSUP; 14499 14500 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14501 14502 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14503 return; 14504 14505 #ifdef RTE_LIBRTE_I40E_PMD 14506 ret = rte_pmd_i40e_set_vf_vlan_tag(res->port_id, 14507 res->vf_id, is_on); 14508 #endif 14509 14510 switch (ret) { 14511 case 0: 14512 break; 14513 case -EINVAL: 14514 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14515 break; 14516 case -ENODEV: 14517 printf("invalid port_id %d\n", res->port_id); 14518 break; 14519 case -ENOTSUP: 14520 printf("function not implemented\n"); 14521 break; 14522 default: 14523 printf("programming error: (%s)\n", strerror(-ret)); 14524 } 14525 } 14526 14527 cmdline_parse_inst_t cmd_set_vf_vlan_tag = { 14528 .f = cmd_set_vf_vlan_tag_parsed, 14529 .data = NULL, 14530 .help_str = "set vf vlan tag <port_id> <vf_id> on|off", 14531 .tokens = { 14532 (void *)&cmd_set_vf_vlan_tag_set, 14533 (void *)&cmd_set_vf_vlan_tag_vf, 14534 (void *)&cmd_set_vf_vlan_tag_vlan, 14535 (void *)&cmd_set_vf_vlan_tag_tag, 14536 (void *)&cmd_set_vf_vlan_tag_port_id, 14537 (void *)&cmd_set_vf_vlan_tag_vf_id, 14538 (void *)&cmd_set_vf_vlan_tag_on_off, 14539 NULL, 14540 }, 14541 }; 14542 14543 /* Common definition of VF and TC TX bandwidth configuration */ 14544 struct cmd_vf_tc_bw_result { 14545 cmdline_fixed_string_t set; 14546 cmdline_fixed_string_t vf; 14547 cmdline_fixed_string_t tc; 14548 cmdline_fixed_string_t tx; 14549 cmdline_fixed_string_t min_bw; 14550 cmdline_fixed_string_t max_bw; 14551 cmdline_fixed_string_t strict_link_prio; 14552 portid_t port_id; 14553 uint16_t vf_id; 14554 uint8_t tc_no; 14555 uint32_t bw; 14556 cmdline_fixed_string_t bw_list; 14557 uint8_t tc_map; 14558 }; 14559 14560 cmdline_parse_token_string_t cmd_vf_tc_bw_set = 14561 TOKEN_STRING_INITIALIZER 14562 (struct cmd_vf_tc_bw_result, 14563 set, "set"); 14564 cmdline_parse_token_string_t cmd_vf_tc_bw_vf = 14565 TOKEN_STRING_INITIALIZER 14566 (struct cmd_vf_tc_bw_result, 14567 vf, "vf"); 14568 cmdline_parse_token_string_t cmd_vf_tc_bw_tc = 14569 TOKEN_STRING_INITIALIZER 14570 (struct cmd_vf_tc_bw_result, 14571 tc, "tc"); 14572 cmdline_parse_token_string_t cmd_vf_tc_bw_tx = 14573 TOKEN_STRING_INITIALIZER 14574 (struct cmd_vf_tc_bw_result, 14575 tx, "tx"); 14576 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio = 14577 TOKEN_STRING_INITIALIZER 14578 (struct cmd_vf_tc_bw_result, 14579 strict_link_prio, "strict-link-priority"); 14580 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw = 14581 TOKEN_STRING_INITIALIZER 14582 (struct cmd_vf_tc_bw_result, 14583 min_bw, "min-bandwidth"); 14584 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw = 14585 TOKEN_STRING_INITIALIZER 14586 (struct cmd_vf_tc_bw_result, 14587 max_bw, "max-bandwidth"); 14588 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id = 14589 TOKEN_NUM_INITIALIZER 14590 (struct cmd_vf_tc_bw_result, 14591 port_id, UINT16); 14592 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id = 14593 TOKEN_NUM_INITIALIZER 14594 (struct cmd_vf_tc_bw_result, 14595 vf_id, UINT16); 14596 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no = 14597 TOKEN_NUM_INITIALIZER 14598 (struct cmd_vf_tc_bw_result, 14599 tc_no, UINT8); 14600 cmdline_parse_token_num_t cmd_vf_tc_bw_bw = 14601 TOKEN_NUM_INITIALIZER 14602 (struct cmd_vf_tc_bw_result, 14603 bw, UINT32); 14604 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list = 14605 TOKEN_STRING_INITIALIZER 14606 (struct cmd_vf_tc_bw_result, 14607 bw_list, NULL); 14608 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map = 14609 TOKEN_NUM_INITIALIZER 14610 (struct cmd_vf_tc_bw_result, 14611 tc_map, UINT8); 14612 14613 /* VF max bandwidth setting */ 14614 static void 14615 cmd_vf_max_bw_parsed( 14616 void *parsed_result, 14617 __attribute__((unused)) struct cmdline *cl, 14618 __attribute__((unused)) void *data) 14619 { 14620 struct cmd_vf_tc_bw_result *res = parsed_result; 14621 int ret = -ENOTSUP; 14622 14623 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14624 return; 14625 14626 #ifdef RTE_LIBRTE_I40E_PMD 14627 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id, 14628 res->vf_id, res->bw); 14629 #endif 14630 14631 switch (ret) { 14632 case 0: 14633 break; 14634 case -EINVAL: 14635 printf("invalid vf_id %d or bandwidth %d\n", 14636 res->vf_id, res->bw); 14637 break; 14638 case -ENODEV: 14639 printf("invalid port_id %d\n", res->port_id); 14640 break; 14641 case -ENOTSUP: 14642 printf("function not implemented\n"); 14643 break; 14644 default: 14645 printf("programming error: (%s)\n", strerror(-ret)); 14646 } 14647 } 14648 14649 cmdline_parse_inst_t cmd_vf_max_bw = { 14650 .f = cmd_vf_max_bw_parsed, 14651 .data = NULL, 14652 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>", 14653 .tokens = { 14654 (void *)&cmd_vf_tc_bw_set, 14655 (void *)&cmd_vf_tc_bw_vf, 14656 (void *)&cmd_vf_tc_bw_tx, 14657 (void *)&cmd_vf_tc_bw_max_bw, 14658 (void *)&cmd_vf_tc_bw_port_id, 14659 (void *)&cmd_vf_tc_bw_vf_id, 14660 (void *)&cmd_vf_tc_bw_bw, 14661 NULL, 14662 }, 14663 }; 14664 14665 static int 14666 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list, 14667 uint8_t *tc_num, 14668 char *str) 14669 { 14670 uint32_t size; 14671 const char *p, *p0 = str; 14672 char s[256]; 14673 char *end; 14674 char *str_fld[16]; 14675 uint16_t i; 14676 int ret; 14677 14678 p = strchr(p0, '('); 14679 if (p == NULL) { 14680 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 14681 return -1; 14682 } 14683 p++; 14684 p0 = strchr(p, ')'); 14685 if (p0 == NULL) { 14686 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 14687 return -1; 14688 } 14689 size = p0 - p; 14690 if (size >= sizeof(s)) { 14691 printf("The string size exceeds the internal buffer size\n"); 14692 return -1; 14693 } 14694 snprintf(s, sizeof(s), "%.*s", size, p); 14695 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ','); 14696 if (ret <= 0) { 14697 printf("Failed to get the bandwidth list. "); 14698 return -1; 14699 } 14700 *tc_num = ret; 14701 for (i = 0; i < ret; i++) 14702 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0); 14703 14704 return 0; 14705 } 14706 14707 /* TC min bandwidth setting */ 14708 static void 14709 cmd_vf_tc_min_bw_parsed( 14710 void *parsed_result, 14711 __attribute__((unused)) struct cmdline *cl, 14712 __attribute__((unused)) void *data) 14713 { 14714 struct cmd_vf_tc_bw_result *res = parsed_result; 14715 uint8_t tc_num; 14716 uint8_t bw[16]; 14717 int ret = -ENOTSUP; 14718 14719 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14720 return; 14721 14722 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 14723 if (ret) 14724 return; 14725 14726 #ifdef RTE_LIBRTE_I40E_PMD 14727 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id, 14728 tc_num, bw); 14729 #endif 14730 14731 switch (ret) { 14732 case 0: 14733 break; 14734 case -EINVAL: 14735 printf("invalid vf_id %d or bandwidth\n", res->vf_id); 14736 break; 14737 case -ENODEV: 14738 printf("invalid port_id %d\n", res->port_id); 14739 break; 14740 case -ENOTSUP: 14741 printf("function not implemented\n"); 14742 break; 14743 default: 14744 printf("programming error: (%s)\n", strerror(-ret)); 14745 } 14746 } 14747 14748 cmdline_parse_inst_t cmd_vf_tc_min_bw = { 14749 .f = cmd_vf_tc_min_bw_parsed, 14750 .data = NULL, 14751 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>" 14752 " <bw1, bw2, ...>", 14753 .tokens = { 14754 (void *)&cmd_vf_tc_bw_set, 14755 (void *)&cmd_vf_tc_bw_vf, 14756 (void *)&cmd_vf_tc_bw_tc, 14757 (void *)&cmd_vf_tc_bw_tx, 14758 (void *)&cmd_vf_tc_bw_min_bw, 14759 (void *)&cmd_vf_tc_bw_port_id, 14760 (void *)&cmd_vf_tc_bw_vf_id, 14761 (void *)&cmd_vf_tc_bw_bw_list, 14762 NULL, 14763 }, 14764 }; 14765 14766 static void 14767 cmd_tc_min_bw_parsed( 14768 void *parsed_result, 14769 __attribute__((unused)) struct cmdline *cl, 14770 __attribute__((unused)) void *data) 14771 { 14772 struct cmd_vf_tc_bw_result *res = parsed_result; 14773 struct rte_port *port; 14774 uint8_t tc_num; 14775 uint8_t bw[16]; 14776 int ret = -ENOTSUP; 14777 14778 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14779 return; 14780 14781 port = &ports[res->port_id]; 14782 /** Check if the port is not started **/ 14783 if (port->port_status != RTE_PORT_STOPPED) { 14784 printf("Please stop port %d first\n", res->port_id); 14785 return; 14786 } 14787 14788 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 14789 if (ret) 14790 return; 14791 14792 #ifdef RTE_LIBRTE_IXGBE_PMD 14793 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw); 14794 #endif 14795 14796 switch (ret) { 14797 case 0: 14798 break; 14799 case -EINVAL: 14800 printf("invalid bandwidth\n"); 14801 break; 14802 case -ENODEV: 14803 printf("invalid port_id %d\n", res->port_id); 14804 break; 14805 case -ENOTSUP: 14806 printf("function not implemented\n"); 14807 break; 14808 default: 14809 printf("programming error: (%s)\n", strerror(-ret)); 14810 } 14811 } 14812 14813 cmdline_parse_inst_t cmd_tc_min_bw = { 14814 .f = cmd_tc_min_bw_parsed, 14815 .data = NULL, 14816 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>", 14817 .tokens = { 14818 (void *)&cmd_vf_tc_bw_set, 14819 (void *)&cmd_vf_tc_bw_tc, 14820 (void *)&cmd_vf_tc_bw_tx, 14821 (void *)&cmd_vf_tc_bw_min_bw, 14822 (void *)&cmd_vf_tc_bw_port_id, 14823 (void *)&cmd_vf_tc_bw_bw_list, 14824 NULL, 14825 }, 14826 }; 14827 14828 /* TC max bandwidth setting */ 14829 static void 14830 cmd_vf_tc_max_bw_parsed( 14831 void *parsed_result, 14832 __attribute__((unused)) struct cmdline *cl, 14833 __attribute__((unused)) void *data) 14834 { 14835 struct cmd_vf_tc_bw_result *res = parsed_result; 14836 int ret = -ENOTSUP; 14837 14838 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14839 return; 14840 14841 #ifdef RTE_LIBRTE_I40E_PMD 14842 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id, 14843 res->tc_no, res->bw); 14844 #endif 14845 14846 switch (ret) { 14847 case 0: 14848 break; 14849 case -EINVAL: 14850 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n", 14851 res->vf_id, res->tc_no, res->bw); 14852 break; 14853 case -ENODEV: 14854 printf("invalid port_id %d\n", res->port_id); 14855 break; 14856 case -ENOTSUP: 14857 printf("function not implemented\n"); 14858 break; 14859 default: 14860 printf("programming error: (%s)\n", strerror(-ret)); 14861 } 14862 } 14863 14864 cmdline_parse_inst_t cmd_vf_tc_max_bw = { 14865 .f = cmd_vf_tc_max_bw_parsed, 14866 .data = NULL, 14867 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>" 14868 " <bandwidth>", 14869 .tokens = { 14870 (void *)&cmd_vf_tc_bw_set, 14871 (void *)&cmd_vf_tc_bw_vf, 14872 (void *)&cmd_vf_tc_bw_tc, 14873 (void *)&cmd_vf_tc_bw_tx, 14874 (void *)&cmd_vf_tc_bw_max_bw, 14875 (void *)&cmd_vf_tc_bw_port_id, 14876 (void *)&cmd_vf_tc_bw_vf_id, 14877 (void *)&cmd_vf_tc_bw_tc_no, 14878 (void *)&cmd_vf_tc_bw_bw, 14879 NULL, 14880 }, 14881 }; 14882 14883 14884 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 14885 14886 /* *** Set Port default Traffic Management Hierarchy *** */ 14887 struct cmd_set_port_tm_hierarchy_default_result { 14888 cmdline_fixed_string_t set; 14889 cmdline_fixed_string_t port; 14890 cmdline_fixed_string_t tm; 14891 cmdline_fixed_string_t hierarchy; 14892 cmdline_fixed_string_t def; 14893 portid_t port_id; 14894 }; 14895 14896 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set = 14897 TOKEN_STRING_INITIALIZER( 14898 struct cmd_set_port_tm_hierarchy_default_result, set, "set"); 14899 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port = 14900 TOKEN_STRING_INITIALIZER( 14901 struct cmd_set_port_tm_hierarchy_default_result, port, "port"); 14902 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm = 14903 TOKEN_STRING_INITIALIZER( 14904 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm"); 14905 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy = 14906 TOKEN_STRING_INITIALIZER( 14907 struct cmd_set_port_tm_hierarchy_default_result, 14908 hierarchy, "hierarchy"); 14909 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default = 14910 TOKEN_STRING_INITIALIZER( 14911 struct cmd_set_port_tm_hierarchy_default_result, 14912 def, "default"); 14913 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id = 14914 TOKEN_NUM_INITIALIZER( 14915 struct cmd_set_port_tm_hierarchy_default_result, 14916 port_id, UINT16); 14917 14918 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result, 14919 __attribute__((unused)) struct cmdline *cl, 14920 __attribute__((unused)) void *data) 14921 { 14922 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result; 14923 struct rte_port *p; 14924 portid_t port_id = res->port_id; 14925 14926 if (port_id_is_invalid(port_id, ENABLED_WARN)) 14927 return; 14928 14929 p = &ports[port_id]; 14930 14931 /* Forward mode: tm */ 14932 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) { 14933 printf(" softnicfwd mode not enabled(error)\n"); 14934 return; 14935 } 14936 14937 /* Set the default tm hierarchy */ 14938 p->softport.default_tm_hierarchy_enable = 1; 14939 } 14940 14941 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = { 14942 .f = cmd_set_port_tm_hierarchy_default_parsed, 14943 .data = NULL, 14944 .help_str = "set port tm hierarchy default <port_id>", 14945 .tokens = { 14946 (void *)&cmd_set_port_tm_hierarchy_default_set, 14947 (void *)&cmd_set_port_tm_hierarchy_default_port, 14948 (void *)&cmd_set_port_tm_hierarchy_default_tm, 14949 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy, 14950 (void *)&cmd_set_port_tm_hierarchy_default_default, 14951 (void *)&cmd_set_port_tm_hierarchy_default_port_id, 14952 NULL, 14953 }, 14954 }; 14955 #endif 14956 14957 /** Set VXLAN encapsulation details */ 14958 struct cmd_set_vxlan_result { 14959 cmdline_fixed_string_t set; 14960 cmdline_fixed_string_t vxlan; 14961 cmdline_fixed_string_t pos_token; 14962 cmdline_fixed_string_t ip_version; 14963 uint32_t vlan_present:1; 14964 uint32_t vni; 14965 uint16_t udp_src; 14966 uint16_t udp_dst; 14967 cmdline_ipaddr_t ip_src; 14968 cmdline_ipaddr_t ip_dst; 14969 uint16_t tci; 14970 struct ether_addr eth_src; 14971 struct ether_addr eth_dst; 14972 }; 14973 14974 cmdline_parse_token_string_t cmd_set_vxlan_set = 14975 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set"); 14976 cmdline_parse_token_string_t cmd_set_vxlan_vxlan = 14977 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan"); 14978 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan = 14979 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 14980 "vxlan-with-vlan"); 14981 cmdline_parse_token_string_t cmd_set_vxlan_ip_version = 14982 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 14983 "ip-version"); 14984 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value = 14985 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version, 14986 "ipv4#ipv6"); 14987 cmdline_parse_token_string_t cmd_set_vxlan_vni = 14988 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 14989 "vni"); 14990 cmdline_parse_token_num_t cmd_set_vxlan_vni_value = 14991 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32); 14992 cmdline_parse_token_string_t cmd_set_vxlan_udp_src = 14993 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 14994 "udp-src"); 14995 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value = 14996 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16); 14997 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst = 14998 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 14999 "udp-dst"); 15000 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value = 15001 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16); 15002 cmdline_parse_token_string_t cmd_set_vxlan_ip_src = 15003 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15004 "ip-src"); 15005 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value = 15006 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src); 15007 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst = 15008 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15009 "ip-dst"); 15010 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value = 15011 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst); 15012 cmdline_parse_token_string_t cmd_set_vxlan_vlan = 15013 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15014 "vlan-tci"); 15015 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value = 15016 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16); 15017 cmdline_parse_token_string_t cmd_set_vxlan_eth_src = 15018 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15019 "eth-src"); 15020 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value = 15021 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src); 15022 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst = 15023 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15024 "eth-dst"); 15025 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value = 15026 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst); 15027 15028 static void cmd_set_vxlan_parsed(void *parsed_result, 15029 __attribute__((unused)) struct cmdline *cl, 15030 __attribute__((unused)) void *data) 15031 { 15032 struct cmd_set_vxlan_result *res = parsed_result; 15033 union { 15034 uint32_t vxlan_id; 15035 uint8_t vni[4]; 15036 } id = { 15037 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff), 15038 }; 15039 15040 if (strcmp(res->vxlan, "vxlan") == 0) 15041 vxlan_encap_conf.select_vlan = 0; 15042 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0) 15043 vxlan_encap_conf.select_vlan = 1; 15044 if (strcmp(res->ip_version, "ipv4") == 0) 15045 vxlan_encap_conf.select_ipv4 = 1; 15046 else if (strcmp(res->ip_version, "ipv6") == 0) 15047 vxlan_encap_conf.select_ipv4 = 0; 15048 else 15049 return; 15050 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3); 15051 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 15052 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 15053 if (vxlan_encap_conf.select_ipv4) { 15054 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src); 15055 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst); 15056 } else { 15057 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src); 15058 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst); 15059 } 15060 if (vxlan_encap_conf.select_vlan) 15061 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15062 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes, 15063 ETHER_ADDR_LEN); 15064 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15065 ETHER_ADDR_LEN); 15066 } 15067 15068 cmdline_parse_inst_t cmd_set_vxlan = { 15069 .f = cmd_set_vxlan_parsed, 15070 .data = NULL, 15071 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src" 15072 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>" 15073 " eth-src <eth-src> eth-dst <eth-dst>", 15074 .tokens = { 15075 (void *)&cmd_set_vxlan_set, 15076 (void *)&cmd_set_vxlan_vxlan, 15077 (void *)&cmd_set_vxlan_ip_version, 15078 (void *)&cmd_set_vxlan_ip_version_value, 15079 (void *)&cmd_set_vxlan_vni, 15080 (void *)&cmd_set_vxlan_vni_value, 15081 (void *)&cmd_set_vxlan_udp_src, 15082 (void *)&cmd_set_vxlan_udp_src_value, 15083 (void *)&cmd_set_vxlan_udp_dst, 15084 (void *)&cmd_set_vxlan_udp_dst_value, 15085 (void *)&cmd_set_vxlan_ip_src, 15086 (void *)&cmd_set_vxlan_ip_src_value, 15087 (void *)&cmd_set_vxlan_ip_dst, 15088 (void *)&cmd_set_vxlan_ip_dst_value, 15089 (void *)&cmd_set_vxlan_eth_src, 15090 (void *)&cmd_set_vxlan_eth_src_value, 15091 (void *)&cmd_set_vxlan_eth_dst, 15092 (void *)&cmd_set_vxlan_eth_dst_value, 15093 NULL, 15094 }, 15095 }; 15096 15097 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = { 15098 .f = cmd_set_vxlan_parsed, 15099 .data = NULL, 15100 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>" 15101 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst" 15102 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst" 15103 " <eth-dst>", 15104 .tokens = { 15105 (void *)&cmd_set_vxlan_set, 15106 (void *)&cmd_set_vxlan_vxlan_with_vlan, 15107 (void *)&cmd_set_vxlan_ip_version, 15108 (void *)&cmd_set_vxlan_ip_version_value, 15109 (void *)&cmd_set_vxlan_vni, 15110 (void *)&cmd_set_vxlan_vni_value, 15111 (void *)&cmd_set_vxlan_udp_src, 15112 (void *)&cmd_set_vxlan_udp_src_value, 15113 (void *)&cmd_set_vxlan_udp_dst, 15114 (void *)&cmd_set_vxlan_udp_dst_value, 15115 (void *)&cmd_set_vxlan_ip_src, 15116 (void *)&cmd_set_vxlan_ip_src_value, 15117 (void *)&cmd_set_vxlan_ip_dst, 15118 (void *)&cmd_set_vxlan_ip_dst_value, 15119 (void *)&cmd_set_vxlan_vlan, 15120 (void *)&cmd_set_vxlan_vlan_value, 15121 (void *)&cmd_set_vxlan_eth_src, 15122 (void *)&cmd_set_vxlan_eth_src_value, 15123 (void *)&cmd_set_vxlan_eth_dst, 15124 (void *)&cmd_set_vxlan_eth_dst_value, 15125 NULL, 15126 }, 15127 }; 15128 15129 /** Set NVGRE encapsulation details */ 15130 struct cmd_set_nvgre_result { 15131 cmdline_fixed_string_t set; 15132 cmdline_fixed_string_t nvgre; 15133 cmdline_fixed_string_t pos_token; 15134 cmdline_fixed_string_t ip_version; 15135 uint32_t tni; 15136 cmdline_ipaddr_t ip_src; 15137 cmdline_ipaddr_t ip_dst; 15138 uint16_t tci; 15139 struct ether_addr eth_src; 15140 struct ether_addr eth_dst; 15141 }; 15142 15143 cmdline_parse_token_string_t cmd_set_nvgre_set = 15144 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set"); 15145 cmdline_parse_token_string_t cmd_set_nvgre_nvgre = 15146 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre"); 15147 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan = 15148 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, 15149 "nvgre-with-vlan"); 15150 cmdline_parse_token_string_t cmd_set_nvgre_ip_version = 15151 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15152 "ip-version"); 15153 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value = 15154 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version, 15155 "ipv4#ipv6"); 15156 cmdline_parse_token_string_t cmd_set_nvgre_tni = 15157 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15158 "tni"); 15159 cmdline_parse_token_num_t cmd_set_nvgre_tni_value = 15160 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32); 15161 cmdline_parse_token_string_t cmd_set_nvgre_ip_src = 15162 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15163 "ip-src"); 15164 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value = 15165 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src); 15166 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst = 15167 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15168 "ip-dst"); 15169 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value = 15170 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst); 15171 cmdline_parse_token_string_t cmd_set_nvgre_vlan = 15172 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15173 "vlan-tci"); 15174 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value = 15175 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16); 15176 cmdline_parse_token_string_t cmd_set_nvgre_eth_src = 15177 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15178 "eth-src"); 15179 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value = 15180 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src); 15181 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst = 15182 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15183 "eth-dst"); 15184 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value = 15185 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst); 15186 15187 static void cmd_set_nvgre_parsed(void *parsed_result, 15188 __attribute__((unused)) struct cmdline *cl, 15189 __attribute__((unused)) void *data) 15190 { 15191 struct cmd_set_nvgre_result *res = parsed_result; 15192 union { 15193 uint32_t nvgre_tni; 15194 uint8_t tni[4]; 15195 } id = { 15196 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff), 15197 }; 15198 15199 if (strcmp(res->nvgre, "nvgre") == 0) 15200 nvgre_encap_conf.select_vlan = 0; 15201 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0) 15202 nvgre_encap_conf.select_vlan = 1; 15203 if (strcmp(res->ip_version, "ipv4") == 0) 15204 nvgre_encap_conf.select_ipv4 = 1; 15205 else if (strcmp(res->ip_version, "ipv6") == 0) 15206 nvgre_encap_conf.select_ipv4 = 0; 15207 else 15208 return; 15209 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3); 15210 if (nvgre_encap_conf.select_ipv4) { 15211 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src); 15212 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst); 15213 } else { 15214 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src); 15215 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst); 15216 } 15217 if (nvgre_encap_conf.select_vlan) 15218 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15219 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes, 15220 ETHER_ADDR_LEN); 15221 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15222 ETHER_ADDR_LEN); 15223 } 15224 15225 cmdline_parse_inst_t cmd_set_nvgre = { 15226 .f = cmd_set_nvgre_parsed, 15227 .data = NULL, 15228 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src" 15229 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15230 " eth-dst <eth-dst>", 15231 .tokens = { 15232 (void *)&cmd_set_nvgre_set, 15233 (void *)&cmd_set_nvgre_nvgre, 15234 (void *)&cmd_set_nvgre_ip_version, 15235 (void *)&cmd_set_nvgre_ip_version_value, 15236 (void *)&cmd_set_nvgre_tni, 15237 (void *)&cmd_set_nvgre_tni_value, 15238 (void *)&cmd_set_nvgre_ip_src, 15239 (void *)&cmd_set_nvgre_ip_src_value, 15240 (void *)&cmd_set_nvgre_ip_dst, 15241 (void *)&cmd_set_nvgre_ip_dst_value, 15242 (void *)&cmd_set_nvgre_eth_src, 15243 (void *)&cmd_set_nvgre_eth_src_value, 15244 (void *)&cmd_set_nvgre_eth_dst, 15245 (void *)&cmd_set_nvgre_eth_dst_value, 15246 NULL, 15247 }, 15248 }; 15249 15250 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = { 15251 .f = cmd_set_nvgre_parsed, 15252 .data = NULL, 15253 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>" 15254 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 15255 " eth-src <eth-src> eth-dst <eth-dst>", 15256 .tokens = { 15257 (void *)&cmd_set_nvgre_set, 15258 (void *)&cmd_set_nvgre_nvgre_with_vlan, 15259 (void *)&cmd_set_nvgre_ip_version, 15260 (void *)&cmd_set_nvgre_ip_version_value, 15261 (void *)&cmd_set_nvgre_tni, 15262 (void *)&cmd_set_nvgre_tni_value, 15263 (void *)&cmd_set_nvgre_ip_src, 15264 (void *)&cmd_set_nvgre_ip_src_value, 15265 (void *)&cmd_set_nvgre_ip_dst, 15266 (void *)&cmd_set_nvgre_ip_dst_value, 15267 (void *)&cmd_set_nvgre_vlan, 15268 (void *)&cmd_set_nvgre_vlan_value, 15269 (void *)&cmd_set_nvgre_eth_src, 15270 (void *)&cmd_set_nvgre_eth_src_value, 15271 (void *)&cmd_set_nvgre_eth_dst, 15272 (void *)&cmd_set_nvgre_eth_dst_value, 15273 NULL, 15274 }, 15275 }; 15276 15277 /* Strict link priority scheduling mode setting */ 15278 static void 15279 cmd_strict_link_prio_parsed( 15280 void *parsed_result, 15281 __attribute__((unused)) struct cmdline *cl, 15282 __attribute__((unused)) void *data) 15283 { 15284 struct cmd_vf_tc_bw_result *res = parsed_result; 15285 int ret = -ENOTSUP; 15286 15287 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 15288 return; 15289 15290 #ifdef RTE_LIBRTE_I40E_PMD 15291 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map); 15292 #endif 15293 15294 switch (ret) { 15295 case 0: 15296 break; 15297 case -EINVAL: 15298 printf("invalid tc_bitmap 0x%x\n", res->tc_map); 15299 break; 15300 case -ENODEV: 15301 printf("invalid port_id %d\n", res->port_id); 15302 break; 15303 case -ENOTSUP: 15304 printf("function not implemented\n"); 15305 break; 15306 default: 15307 printf("programming error: (%s)\n", strerror(-ret)); 15308 } 15309 } 15310 15311 cmdline_parse_inst_t cmd_strict_link_prio = { 15312 .f = cmd_strict_link_prio_parsed, 15313 .data = NULL, 15314 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>", 15315 .tokens = { 15316 (void *)&cmd_vf_tc_bw_set, 15317 (void *)&cmd_vf_tc_bw_tx, 15318 (void *)&cmd_vf_tc_bw_strict_link_prio, 15319 (void *)&cmd_vf_tc_bw_port_id, 15320 (void *)&cmd_vf_tc_bw_tc_map, 15321 NULL, 15322 }, 15323 }; 15324 15325 /* Load dynamic device personalization*/ 15326 struct cmd_ddp_add_result { 15327 cmdline_fixed_string_t ddp; 15328 cmdline_fixed_string_t add; 15329 portid_t port_id; 15330 char filepath[]; 15331 }; 15332 15333 cmdline_parse_token_string_t cmd_ddp_add_ddp = 15334 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp"); 15335 cmdline_parse_token_string_t cmd_ddp_add_add = 15336 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add"); 15337 cmdline_parse_token_num_t cmd_ddp_add_port_id = 15338 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16); 15339 cmdline_parse_token_string_t cmd_ddp_add_filepath = 15340 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL); 15341 15342 static void 15343 cmd_ddp_add_parsed( 15344 void *parsed_result, 15345 __attribute__((unused)) struct cmdline *cl, 15346 __attribute__((unused)) void *data) 15347 { 15348 struct cmd_ddp_add_result *res = parsed_result; 15349 uint8_t *buff; 15350 uint32_t size; 15351 char *filepath; 15352 char *file_fld[2]; 15353 int file_num; 15354 int ret = -ENOTSUP; 15355 15356 if (!all_ports_stopped()) { 15357 printf("Please stop all ports first\n"); 15358 return; 15359 } 15360 15361 filepath = strdup(res->filepath); 15362 if (filepath == NULL) { 15363 printf("Failed to allocate memory\n"); 15364 return; 15365 } 15366 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ','); 15367 15368 buff = open_file(file_fld[0], &size); 15369 if (!buff) { 15370 free((void *)filepath); 15371 return; 15372 } 15373 15374 #ifdef RTE_LIBRTE_I40E_PMD 15375 if (ret == -ENOTSUP) 15376 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 15377 buff, size, 15378 RTE_PMD_I40E_PKG_OP_WR_ADD); 15379 #endif 15380 15381 if (ret == -EEXIST) 15382 printf("Profile has already existed.\n"); 15383 else if (ret < 0) 15384 printf("Failed to load profile.\n"); 15385 else if (file_num == 2) 15386 save_file(file_fld[1], buff, size); 15387 15388 close_file(buff); 15389 free((void *)filepath); 15390 } 15391 15392 cmdline_parse_inst_t cmd_ddp_add = { 15393 .f = cmd_ddp_add_parsed, 15394 .data = NULL, 15395 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>", 15396 .tokens = { 15397 (void *)&cmd_ddp_add_ddp, 15398 (void *)&cmd_ddp_add_add, 15399 (void *)&cmd_ddp_add_port_id, 15400 (void *)&cmd_ddp_add_filepath, 15401 NULL, 15402 }, 15403 }; 15404 15405 /* Delete dynamic device personalization*/ 15406 struct cmd_ddp_del_result { 15407 cmdline_fixed_string_t ddp; 15408 cmdline_fixed_string_t del; 15409 portid_t port_id; 15410 char filepath[]; 15411 }; 15412 15413 cmdline_parse_token_string_t cmd_ddp_del_ddp = 15414 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp"); 15415 cmdline_parse_token_string_t cmd_ddp_del_del = 15416 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del"); 15417 cmdline_parse_token_num_t cmd_ddp_del_port_id = 15418 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16); 15419 cmdline_parse_token_string_t cmd_ddp_del_filepath = 15420 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL); 15421 15422 static void 15423 cmd_ddp_del_parsed( 15424 void *parsed_result, 15425 __attribute__((unused)) struct cmdline *cl, 15426 __attribute__((unused)) void *data) 15427 { 15428 struct cmd_ddp_del_result *res = parsed_result; 15429 uint8_t *buff; 15430 uint32_t size; 15431 int ret = -ENOTSUP; 15432 15433 if (!all_ports_stopped()) { 15434 printf("Please stop all ports first\n"); 15435 return; 15436 } 15437 15438 buff = open_file(res->filepath, &size); 15439 if (!buff) 15440 return; 15441 15442 #ifdef RTE_LIBRTE_I40E_PMD 15443 if (ret == -ENOTSUP) 15444 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 15445 buff, size, 15446 RTE_PMD_I40E_PKG_OP_WR_DEL); 15447 #endif 15448 15449 if (ret == -EACCES) 15450 printf("Profile does not exist.\n"); 15451 else if (ret < 0) 15452 printf("Failed to delete profile.\n"); 15453 15454 close_file(buff); 15455 } 15456 15457 cmdline_parse_inst_t cmd_ddp_del = { 15458 .f = cmd_ddp_del_parsed, 15459 .data = NULL, 15460 .help_str = "ddp del <port_id> <backup_profile_path>", 15461 .tokens = { 15462 (void *)&cmd_ddp_del_ddp, 15463 (void *)&cmd_ddp_del_del, 15464 (void *)&cmd_ddp_del_port_id, 15465 (void *)&cmd_ddp_del_filepath, 15466 NULL, 15467 }, 15468 }; 15469 15470 /* Get dynamic device personalization profile info */ 15471 struct cmd_ddp_info_result { 15472 cmdline_fixed_string_t ddp; 15473 cmdline_fixed_string_t get; 15474 cmdline_fixed_string_t info; 15475 char filepath[]; 15476 }; 15477 15478 cmdline_parse_token_string_t cmd_ddp_info_ddp = 15479 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp"); 15480 cmdline_parse_token_string_t cmd_ddp_info_get = 15481 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get"); 15482 cmdline_parse_token_string_t cmd_ddp_info_info = 15483 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info"); 15484 cmdline_parse_token_string_t cmd_ddp_info_filepath = 15485 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL); 15486 15487 static void 15488 cmd_ddp_info_parsed( 15489 void *parsed_result, 15490 __attribute__((unused)) struct cmdline *cl, 15491 __attribute__((unused)) void *data) 15492 { 15493 struct cmd_ddp_info_result *res = parsed_result; 15494 uint8_t *pkg; 15495 uint32_t pkg_size; 15496 int ret = -ENOTSUP; 15497 #ifdef RTE_LIBRTE_I40E_PMD 15498 uint32_t i, j, n; 15499 uint8_t *buff; 15500 uint32_t buff_size = 0; 15501 struct rte_pmd_i40e_profile_info info; 15502 uint32_t dev_num = 0; 15503 struct rte_pmd_i40e_ddp_device_id *devs; 15504 uint32_t proto_num = 0; 15505 struct rte_pmd_i40e_proto_info *proto = NULL; 15506 uint32_t pctype_num = 0; 15507 struct rte_pmd_i40e_ptype_info *pctype; 15508 uint32_t ptype_num = 0; 15509 struct rte_pmd_i40e_ptype_info *ptype; 15510 uint8_t proto_id; 15511 15512 #endif 15513 15514 pkg = open_file(res->filepath, &pkg_size); 15515 if (!pkg) 15516 return; 15517 15518 #ifdef RTE_LIBRTE_I40E_PMD 15519 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15520 (uint8_t *)&info, sizeof(info), 15521 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER); 15522 if (!ret) { 15523 printf("Global Track id: 0x%x\n", info.track_id); 15524 printf("Global Version: %d.%d.%d.%d\n", 15525 info.version.major, 15526 info.version.minor, 15527 info.version.update, 15528 info.version.draft); 15529 printf("Global Package name: %s\n\n", info.name); 15530 } 15531 15532 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15533 (uint8_t *)&info, sizeof(info), 15534 RTE_PMD_I40E_PKG_INFO_HEADER); 15535 if (!ret) { 15536 printf("i40e Profile Track id: 0x%x\n", info.track_id); 15537 printf("i40e Profile Version: %d.%d.%d.%d\n", 15538 info.version.major, 15539 info.version.minor, 15540 info.version.update, 15541 info.version.draft); 15542 printf("i40e Profile name: %s\n\n", info.name); 15543 } 15544 15545 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15546 (uint8_t *)&buff_size, sizeof(buff_size), 15547 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE); 15548 if (!ret && buff_size) { 15549 buff = (uint8_t *)malloc(buff_size); 15550 if (buff) { 15551 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15552 buff, buff_size, 15553 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES); 15554 if (!ret) 15555 printf("Package Notes:\n%s\n\n", buff); 15556 free(buff); 15557 } 15558 } 15559 15560 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15561 (uint8_t *)&dev_num, sizeof(dev_num), 15562 RTE_PMD_I40E_PKG_INFO_DEVID_NUM); 15563 if (!ret && dev_num) { 15564 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id); 15565 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size); 15566 if (devs) { 15567 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15568 (uint8_t *)devs, buff_size, 15569 RTE_PMD_I40E_PKG_INFO_DEVID_LIST); 15570 if (!ret) { 15571 printf("List of supported devices:\n"); 15572 for (i = 0; i < dev_num; i++) { 15573 printf(" %04X:%04X %04X:%04X\n", 15574 devs[i].vendor_dev_id >> 16, 15575 devs[i].vendor_dev_id & 0xFFFF, 15576 devs[i].sub_vendor_dev_id >> 16, 15577 devs[i].sub_vendor_dev_id & 0xFFFF); 15578 } 15579 printf("\n"); 15580 } 15581 free(devs); 15582 } 15583 } 15584 15585 /* get information about protocols and packet types */ 15586 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15587 (uint8_t *)&proto_num, sizeof(proto_num), 15588 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM); 15589 if (ret || !proto_num) 15590 goto no_print_return; 15591 15592 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info); 15593 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size); 15594 if (!proto) 15595 goto no_print_return; 15596 15597 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto, 15598 buff_size, 15599 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST); 15600 if (!ret) { 15601 printf("List of used protocols:\n"); 15602 for (i = 0; i < proto_num; i++) 15603 printf(" %2u: %s\n", proto[i].proto_id, 15604 proto[i].name); 15605 printf("\n"); 15606 } 15607 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 15608 (uint8_t *)&pctype_num, sizeof(pctype_num), 15609 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM); 15610 if (ret || !pctype_num) 15611 goto no_print_pctypes; 15612 15613 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info); 15614 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 15615 if (!pctype) 15616 goto no_print_pctypes; 15617 15618 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype, 15619 buff_size, 15620 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST); 15621 if (ret) { 15622 free(pctype); 15623 goto no_print_pctypes; 15624 } 15625 15626 printf("List of defined packet classification types:\n"); 15627 for (i = 0; i < pctype_num; i++) { 15628 printf(" %2u:", pctype[i].ptype_id); 15629 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 15630 proto_id = pctype[i].protocols[j]; 15631 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 15632 for (n = 0; n < proto_num; n++) { 15633 if (proto[n].proto_id == proto_id) { 15634 printf(" %s", proto[n].name); 15635 break; 15636 } 15637 } 15638 } 15639 } 15640 printf("\n"); 15641 } 15642 printf("\n"); 15643 free(pctype); 15644 15645 no_print_pctypes: 15646 15647 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num, 15648 sizeof(ptype_num), 15649 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM); 15650 if (ret || !ptype_num) 15651 goto no_print_return; 15652 15653 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info); 15654 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 15655 if (!ptype) 15656 goto no_print_return; 15657 15658 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype, 15659 buff_size, 15660 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST); 15661 if (ret) { 15662 free(ptype); 15663 goto no_print_return; 15664 } 15665 printf("List of defined packet types:\n"); 15666 for (i = 0; i < ptype_num; i++) { 15667 printf(" %2u:", ptype[i].ptype_id); 15668 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 15669 proto_id = ptype[i].protocols[j]; 15670 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 15671 for (n = 0; n < proto_num; n++) { 15672 if (proto[n].proto_id == proto_id) { 15673 printf(" %s", proto[n].name); 15674 break; 15675 } 15676 } 15677 } 15678 } 15679 printf("\n"); 15680 } 15681 free(ptype); 15682 printf("\n"); 15683 15684 ret = 0; 15685 no_print_return: 15686 if (proto) 15687 free(proto); 15688 #endif 15689 if (ret == -ENOTSUP) 15690 printf("Function not supported in PMD driver\n"); 15691 close_file(pkg); 15692 } 15693 15694 cmdline_parse_inst_t cmd_ddp_get_info = { 15695 .f = cmd_ddp_info_parsed, 15696 .data = NULL, 15697 .help_str = "ddp get info <profile_path>", 15698 .tokens = { 15699 (void *)&cmd_ddp_info_ddp, 15700 (void *)&cmd_ddp_info_get, 15701 (void *)&cmd_ddp_info_info, 15702 (void *)&cmd_ddp_info_filepath, 15703 NULL, 15704 }, 15705 }; 15706 15707 /* Get dynamic device personalization profile info list*/ 15708 #define PROFILE_INFO_SIZE 48 15709 #define MAX_PROFILE_NUM 16 15710 15711 struct cmd_ddp_get_list_result { 15712 cmdline_fixed_string_t ddp; 15713 cmdline_fixed_string_t get; 15714 cmdline_fixed_string_t list; 15715 portid_t port_id; 15716 }; 15717 15718 cmdline_parse_token_string_t cmd_ddp_get_list_ddp = 15719 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp"); 15720 cmdline_parse_token_string_t cmd_ddp_get_list_get = 15721 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get"); 15722 cmdline_parse_token_string_t cmd_ddp_get_list_list = 15723 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list"); 15724 cmdline_parse_token_num_t cmd_ddp_get_list_port_id = 15725 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16); 15726 15727 static void 15728 cmd_ddp_get_list_parsed( 15729 __attribute__((unused)) void *parsed_result, 15730 __attribute__((unused)) struct cmdline *cl, 15731 __attribute__((unused)) void *data) 15732 { 15733 #ifdef RTE_LIBRTE_I40E_PMD 15734 struct cmd_ddp_get_list_result *res = parsed_result; 15735 struct rte_pmd_i40e_profile_list *p_list; 15736 struct rte_pmd_i40e_profile_info *p_info; 15737 uint32_t p_num; 15738 uint32_t size; 15739 uint32_t i; 15740 #endif 15741 int ret = -ENOTSUP; 15742 15743 #ifdef RTE_LIBRTE_I40E_PMD 15744 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4; 15745 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size); 15746 if (!p_list) 15747 printf("%s: Failed to malloc buffer\n", __func__); 15748 15749 if (ret == -ENOTSUP) 15750 ret = rte_pmd_i40e_get_ddp_list(res->port_id, 15751 (uint8_t *)p_list, size); 15752 15753 if (!ret) { 15754 p_num = p_list->p_count; 15755 printf("Profile number is: %d\n\n", p_num); 15756 15757 for (i = 0; i < p_num; i++) { 15758 p_info = &p_list->p_info[i]; 15759 printf("Profile %d:\n", i); 15760 printf("Track id: 0x%x\n", p_info->track_id); 15761 printf("Version: %d.%d.%d.%d\n", 15762 p_info->version.major, 15763 p_info->version.minor, 15764 p_info->version.update, 15765 p_info->version.draft); 15766 printf("Profile name: %s\n\n", p_info->name); 15767 } 15768 } 15769 15770 free(p_list); 15771 #endif 15772 15773 if (ret < 0) 15774 printf("Failed to get ddp list\n"); 15775 } 15776 15777 cmdline_parse_inst_t cmd_ddp_get_list = { 15778 .f = cmd_ddp_get_list_parsed, 15779 .data = NULL, 15780 .help_str = "ddp get list <port_id>", 15781 .tokens = { 15782 (void *)&cmd_ddp_get_list_ddp, 15783 (void *)&cmd_ddp_get_list_get, 15784 (void *)&cmd_ddp_get_list_list, 15785 (void *)&cmd_ddp_get_list_port_id, 15786 NULL, 15787 }, 15788 }; 15789 15790 /* Configure input set */ 15791 struct cmd_cfg_input_set_result { 15792 cmdline_fixed_string_t port; 15793 cmdline_fixed_string_t cfg; 15794 portid_t port_id; 15795 cmdline_fixed_string_t pctype; 15796 uint8_t pctype_id; 15797 cmdline_fixed_string_t inset_type; 15798 cmdline_fixed_string_t opt; 15799 cmdline_fixed_string_t field; 15800 uint8_t field_idx; 15801 }; 15802 15803 static void 15804 cmd_cfg_input_set_parsed( 15805 __attribute__((unused)) void *parsed_result, 15806 __attribute__((unused)) struct cmdline *cl, 15807 __attribute__((unused)) void *data) 15808 { 15809 #ifdef RTE_LIBRTE_I40E_PMD 15810 struct cmd_cfg_input_set_result *res = parsed_result; 15811 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 15812 struct rte_pmd_i40e_inset inset; 15813 #endif 15814 int ret = -ENOTSUP; 15815 15816 if (!all_ports_stopped()) { 15817 printf("Please stop all ports first\n"); 15818 return; 15819 } 15820 15821 #ifdef RTE_LIBRTE_I40E_PMD 15822 if (!strcmp(res->inset_type, "hash_inset")) 15823 inset_type = INSET_HASH; 15824 else if (!strcmp(res->inset_type, "fdir_inset")) 15825 inset_type = INSET_FDIR; 15826 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 15827 inset_type = INSET_FDIR_FLX; 15828 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id, 15829 &inset, inset_type); 15830 if (ret) { 15831 printf("Failed to get input set.\n"); 15832 return; 15833 } 15834 15835 if (!strcmp(res->opt, "get")) { 15836 ret = rte_pmd_i40e_inset_field_get(inset.inset, 15837 res->field_idx); 15838 if (ret) 15839 printf("Field index %d is enabled.\n", res->field_idx); 15840 else 15841 printf("Field index %d is disabled.\n", res->field_idx); 15842 return; 15843 } else if (!strcmp(res->opt, "set")) 15844 ret = rte_pmd_i40e_inset_field_set(&inset.inset, 15845 res->field_idx); 15846 else if (!strcmp(res->opt, "clear")) 15847 ret = rte_pmd_i40e_inset_field_clear(&inset.inset, 15848 res->field_idx); 15849 if (ret) { 15850 printf("Failed to configure input set field.\n"); 15851 return; 15852 } 15853 15854 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 15855 &inset, inset_type); 15856 if (ret) { 15857 printf("Failed to set input set.\n"); 15858 return; 15859 } 15860 #endif 15861 15862 if (ret == -ENOTSUP) 15863 printf("Function not supported\n"); 15864 } 15865 15866 cmdline_parse_token_string_t cmd_cfg_input_set_port = 15867 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 15868 port, "port"); 15869 cmdline_parse_token_string_t cmd_cfg_input_set_cfg = 15870 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 15871 cfg, "config"); 15872 cmdline_parse_token_num_t cmd_cfg_input_set_port_id = 15873 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 15874 port_id, UINT16); 15875 cmdline_parse_token_string_t cmd_cfg_input_set_pctype = 15876 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 15877 pctype, "pctype"); 15878 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id = 15879 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 15880 pctype_id, UINT8); 15881 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type = 15882 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 15883 inset_type, 15884 "hash_inset#fdir_inset#fdir_flx_inset"); 15885 cmdline_parse_token_string_t cmd_cfg_input_set_opt = 15886 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 15887 opt, "get#set#clear"); 15888 cmdline_parse_token_string_t cmd_cfg_input_set_field = 15889 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 15890 field, "field"); 15891 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx = 15892 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 15893 field_idx, UINT8); 15894 15895 cmdline_parse_inst_t cmd_cfg_input_set = { 15896 .f = cmd_cfg_input_set_parsed, 15897 .data = NULL, 15898 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 15899 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>", 15900 .tokens = { 15901 (void *)&cmd_cfg_input_set_port, 15902 (void *)&cmd_cfg_input_set_cfg, 15903 (void *)&cmd_cfg_input_set_port_id, 15904 (void *)&cmd_cfg_input_set_pctype, 15905 (void *)&cmd_cfg_input_set_pctype_id, 15906 (void *)&cmd_cfg_input_set_inset_type, 15907 (void *)&cmd_cfg_input_set_opt, 15908 (void *)&cmd_cfg_input_set_field, 15909 (void *)&cmd_cfg_input_set_field_idx, 15910 NULL, 15911 }, 15912 }; 15913 15914 /* Clear input set */ 15915 struct cmd_clear_input_set_result { 15916 cmdline_fixed_string_t port; 15917 cmdline_fixed_string_t cfg; 15918 portid_t port_id; 15919 cmdline_fixed_string_t pctype; 15920 uint8_t pctype_id; 15921 cmdline_fixed_string_t inset_type; 15922 cmdline_fixed_string_t clear; 15923 cmdline_fixed_string_t all; 15924 }; 15925 15926 static void 15927 cmd_clear_input_set_parsed( 15928 __attribute__((unused)) void *parsed_result, 15929 __attribute__((unused)) struct cmdline *cl, 15930 __attribute__((unused)) void *data) 15931 { 15932 #ifdef RTE_LIBRTE_I40E_PMD 15933 struct cmd_clear_input_set_result *res = parsed_result; 15934 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 15935 struct rte_pmd_i40e_inset inset; 15936 #endif 15937 int ret = -ENOTSUP; 15938 15939 if (!all_ports_stopped()) { 15940 printf("Please stop all ports first\n"); 15941 return; 15942 } 15943 15944 #ifdef RTE_LIBRTE_I40E_PMD 15945 if (!strcmp(res->inset_type, "hash_inset")) 15946 inset_type = INSET_HASH; 15947 else if (!strcmp(res->inset_type, "fdir_inset")) 15948 inset_type = INSET_FDIR; 15949 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 15950 inset_type = INSET_FDIR_FLX; 15951 15952 memset(&inset, 0, sizeof(inset)); 15953 15954 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 15955 &inset, inset_type); 15956 if (ret) { 15957 printf("Failed to clear input set.\n"); 15958 return; 15959 } 15960 15961 #endif 15962 15963 if (ret == -ENOTSUP) 15964 printf("Function not supported\n"); 15965 } 15966 15967 cmdline_parse_token_string_t cmd_clear_input_set_port = 15968 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 15969 port, "port"); 15970 cmdline_parse_token_string_t cmd_clear_input_set_cfg = 15971 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 15972 cfg, "config"); 15973 cmdline_parse_token_num_t cmd_clear_input_set_port_id = 15974 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 15975 port_id, UINT16); 15976 cmdline_parse_token_string_t cmd_clear_input_set_pctype = 15977 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 15978 pctype, "pctype"); 15979 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id = 15980 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 15981 pctype_id, UINT8); 15982 cmdline_parse_token_string_t cmd_clear_input_set_inset_type = 15983 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 15984 inset_type, 15985 "hash_inset#fdir_inset#fdir_flx_inset"); 15986 cmdline_parse_token_string_t cmd_clear_input_set_clear = 15987 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 15988 clear, "clear"); 15989 cmdline_parse_token_string_t cmd_clear_input_set_all = 15990 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 15991 all, "all"); 15992 15993 cmdline_parse_inst_t cmd_clear_input_set = { 15994 .f = cmd_clear_input_set_parsed, 15995 .data = NULL, 15996 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 15997 "fdir_inset|fdir_flx_inset clear all", 15998 .tokens = { 15999 (void *)&cmd_clear_input_set_port, 16000 (void *)&cmd_clear_input_set_cfg, 16001 (void *)&cmd_clear_input_set_port_id, 16002 (void *)&cmd_clear_input_set_pctype, 16003 (void *)&cmd_clear_input_set_pctype_id, 16004 (void *)&cmd_clear_input_set_inset_type, 16005 (void *)&cmd_clear_input_set_clear, 16006 (void *)&cmd_clear_input_set_all, 16007 NULL, 16008 }, 16009 }; 16010 16011 /* show vf stats */ 16012 16013 /* Common result structure for show vf stats */ 16014 struct cmd_show_vf_stats_result { 16015 cmdline_fixed_string_t show; 16016 cmdline_fixed_string_t vf; 16017 cmdline_fixed_string_t stats; 16018 portid_t port_id; 16019 uint16_t vf_id; 16020 }; 16021 16022 /* Common CLI fields show vf stats*/ 16023 cmdline_parse_token_string_t cmd_show_vf_stats_show = 16024 TOKEN_STRING_INITIALIZER 16025 (struct cmd_show_vf_stats_result, 16026 show, "show"); 16027 cmdline_parse_token_string_t cmd_show_vf_stats_vf = 16028 TOKEN_STRING_INITIALIZER 16029 (struct cmd_show_vf_stats_result, 16030 vf, "vf"); 16031 cmdline_parse_token_string_t cmd_show_vf_stats_stats = 16032 TOKEN_STRING_INITIALIZER 16033 (struct cmd_show_vf_stats_result, 16034 stats, "stats"); 16035 cmdline_parse_token_num_t cmd_show_vf_stats_port_id = 16036 TOKEN_NUM_INITIALIZER 16037 (struct cmd_show_vf_stats_result, 16038 port_id, UINT16); 16039 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id = 16040 TOKEN_NUM_INITIALIZER 16041 (struct cmd_show_vf_stats_result, 16042 vf_id, UINT16); 16043 16044 static void 16045 cmd_show_vf_stats_parsed( 16046 void *parsed_result, 16047 __attribute__((unused)) struct cmdline *cl, 16048 __attribute__((unused)) void *data) 16049 { 16050 struct cmd_show_vf_stats_result *res = parsed_result; 16051 struct rte_eth_stats stats; 16052 int ret = -ENOTSUP; 16053 static const char *nic_stats_border = "########################"; 16054 16055 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16056 return; 16057 16058 memset(&stats, 0, sizeof(stats)); 16059 16060 #ifdef RTE_LIBRTE_I40E_PMD 16061 if (ret == -ENOTSUP) 16062 ret = rte_pmd_i40e_get_vf_stats(res->port_id, 16063 res->vf_id, 16064 &stats); 16065 #endif 16066 #ifdef RTE_LIBRTE_BNXT_PMD 16067 if (ret == -ENOTSUP) 16068 ret = rte_pmd_bnxt_get_vf_stats(res->port_id, 16069 res->vf_id, 16070 &stats); 16071 #endif 16072 16073 switch (ret) { 16074 case 0: 16075 break; 16076 case -EINVAL: 16077 printf("invalid vf_id %d\n", res->vf_id); 16078 break; 16079 case -ENODEV: 16080 printf("invalid port_id %d\n", res->port_id); 16081 break; 16082 case -ENOTSUP: 16083 printf("function not implemented\n"); 16084 break; 16085 default: 16086 printf("programming error: (%s)\n", strerror(-ret)); 16087 } 16088 16089 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n", 16090 nic_stats_border, res->port_id, res->vf_id, nic_stats_border); 16091 16092 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " 16093 "%-"PRIu64"\n", 16094 stats.ipackets, stats.imissed, stats.ibytes); 16095 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); 16096 printf(" RX-nombuf: %-10"PRIu64"\n", 16097 stats.rx_nombuf); 16098 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " 16099 "%-"PRIu64"\n", 16100 stats.opackets, stats.oerrors, stats.obytes); 16101 16102 printf(" %s############################%s\n", 16103 nic_stats_border, nic_stats_border); 16104 } 16105 16106 cmdline_parse_inst_t cmd_show_vf_stats = { 16107 .f = cmd_show_vf_stats_parsed, 16108 .data = NULL, 16109 .help_str = "show vf stats <port_id> <vf_id>", 16110 .tokens = { 16111 (void *)&cmd_show_vf_stats_show, 16112 (void *)&cmd_show_vf_stats_vf, 16113 (void *)&cmd_show_vf_stats_stats, 16114 (void *)&cmd_show_vf_stats_port_id, 16115 (void *)&cmd_show_vf_stats_vf_id, 16116 NULL, 16117 }, 16118 }; 16119 16120 /* clear vf stats */ 16121 16122 /* Common result structure for clear vf stats */ 16123 struct cmd_clear_vf_stats_result { 16124 cmdline_fixed_string_t clear; 16125 cmdline_fixed_string_t vf; 16126 cmdline_fixed_string_t stats; 16127 portid_t port_id; 16128 uint16_t vf_id; 16129 }; 16130 16131 /* Common CLI fields clear vf stats*/ 16132 cmdline_parse_token_string_t cmd_clear_vf_stats_clear = 16133 TOKEN_STRING_INITIALIZER 16134 (struct cmd_clear_vf_stats_result, 16135 clear, "clear"); 16136 cmdline_parse_token_string_t cmd_clear_vf_stats_vf = 16137 TOKEN_STRING_INITIALIZER 16138 (struct cmd_clear_vf_stats_result, 16139 vf, "vf"); 16140 cmdline_parse_token_string_t cmd_clear_vf_stats_stats = 16141 TOKEN_STRING_INITIALIZER 16142 (struct cmd_clear_vf_stats_result, 16143 stats, "stats"); 16144 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id = 16145 TOKEN_NUM_INITIALIZER 16146 (struct cmd_clear_vf_stats_result, 16147 port_id, UINT16); 16148 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id = 16149 TOKEN_NUM_INITIALIZER 16150 (struct cmd_clear_vf_stats_result, 16151 vf_id, UINT16); 16152 16153 static void 16154 cmd_clear_vf_stats_parsed( 16155 void *parsed_result, 16156 __attribute__((unused)) struct cmdline *cl, 16157 __attribute__((unused)) void *data) 16158 { 16159 struct cmd_clear_vf_stats_result *res = parsed_result; 16160 int ret = -ENOTSUP; 16161 16162 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16163 return; 16164 16165 #ifdef RTE_LIBRTE_I40E_PMD 16166 if (ret == -ENOTSUP) 16167 ret = rte_pmd_i40e_reset_vf_stats(res->port_id, 16168 res->vf_id); 16169 #endif 16170 #ifdef RTE_LIBRTE_BNXT_PMD 16171 if (ret == -ENOTSUP) 16172 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id, 16173 res->vf_id); 16174 #endif 16175 16176 switch (ret) { 16177 case 0: 16178 break; 16179 case -EINVAL: 16180 printf("invalid vf_id %d\n", res->vf_id); 16181 break; 16182 case -ENODEV: 16183 printf("invalid port_id %d\n", res->port_id); 16184 break; 16185 case -ENOTSUP: 16186 printf("function not implemented\n"); 16187 break; 16188 default: 16189 printf("programming error: (%s)\n", strerror(-ret)); 16190 } 16191 } 16192 16193 cmdline_parse_inst_t cmd_clear_vf_stats = { 16194 .f = cmd_clear_vf_stats_parsed, 16195 .data = NULL, 16196 .help_str = "clear vf stats <port_id> <vf_id>", 16197 .tokens = { 16198 (void *)&cmd_clear_vf_stats_clear, 16199 (void *)&cmd_clear_vf_stats_vf, 16200 (void *)&cmd_clear_vf_stats_stats, 16201 (void *)&cmd_clear_vf_stats_port_id, 16202 (void *)&cmd_clear_vf_stats_vf_id, 16203 NULL, 16204 }, 16205 }; 16206 16207 /* port config pctype mapping reset */ 16208 16209 /* Common result structure for port config pctype mapping reset */ 16210 struct cmd_pctype_mapping_reset_result { 16211 cmdline_fixed_string_t port; 16212 cmdline_fixed_string_t config; 16213 portid_t port_id; 16214 cmdline_fixed_string_t pctype; 16215 cmdline_fixed_string_t mapping; 16216 cmdline_fixed_string_t reset; 16217 }; 16218 16219 /* Common CLI fields for port config pctype mapping reset*/ 16220 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port = 16221 TOKEN_STRING_INITIALIZER 16222 (struct cmd_pctype_mapping_reset_result, 16223 port, "port"); 16224 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config = 16225 TOKEN_STRING_INITIALIZER 16226 (struct cmd_pctype_mapping_reset_result, 16227 config, "config"); 16228 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id = 16229 TOKEN_NUM_INITIALIZER 16230 (struct cmd_pctype_mapping_reset_result, 16231 port_id, UINT16); 16232 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype = 16233 TOKEN_STRING_INITIALIZER 16234 (struct cmd_pctype_mapping_reset_result, 16235 pctype, "pctype"); 16236 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping = 16237 TOKEN_STRING_INITIALIZER 16238 (struct cmd_pctype_mapping_reset_result, 16239 mapping, "mapping"); 16240 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset = 16241 TOKEN_STRING_INITIALIZER 16242 (struct cmd_pctype_mapping_reset_result, 16243 reset, "reset"); 16244 16245 static void 16246 cmd_pctype_mapping_reset_parsed( 16247 void *parsed_result, 16248 __attribute__((unused)) struct cmdline *cl, 16249 __attribute__((unused)) void *data) 16250 { 16251 struct cmd_pctype_mapping_reset_result *res = parsed_result; 16252 int ret = -ENOTSUP; 16253 16254 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16255 return; 16256 16257 #ifdef RTE_LIBRTE_I40E_PMD 16258 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id); 16259 #endif 16260 16261 switch (ret) { 16262 case 0: 16263 break; 16264 case -ENODEV: 16265 printf("invalid port_id %d\n", res->port_id); 16266 break; 16267 case -ENOTSUP: 16268 printf("function not implemented\n"); 16269 break; 16270 default: 16271 printf("programming error: (%s)\n", strerror(-ret)); 16272 } 16273 } 16274 16275 cmdline_parse_inst_t cmd_pctype_mapping_reset = { 16276 .f = cmd_pctype_mapping_reset_parsed, 16277 .data = NULL, 16278 .help_str = "port config <port_id> pctype mapping reset", 16279 .tokens = { 16280 (void *)&cmd_pctype_mapping_reset_port, 16281 (void *)&cmd_pctype_mapping_reset_config, 16282 (void *)&cmd_pctype_mapping_reset_port_id, 16283 (void *)&cmd_pctype_mapping_reset_pctype, 16284 (void *)&cmd_pctype_mapping_reset_mapping, 16285 (void *)&cmd_pctype_mapping_reset_reset, 16286 NULL, 16287 }, 16288 }; 16289 16290 /* show port pctype mapping */ 16291 16292 /* Common result structure for show port pctype mapping */ 16293 struct cmd_pctype_mapping_get_result { 16294 cmdline_fixed_string_t show; 16295 cmdline_fixed_string_t port; 16296 portid_t port_id; 16297 cmdline_fixed_string_t pctype; 16298 cmdline_fixed_string_t mapping; 16299 }; 16300 16301 /* Common CLI fields for pctype mapping get */ 16302 cmdline_parse_token_string_t cmd_pctype_mapping_get_show = 16303 TOKEN_STRING_INITIALIZER 16304 (struct cmd_pctype_mapping_get_result, 16305 show, "show"); 16306 cmdline_parse_token_string_t cmd_pctype_mapping_get_port = 16307 TOKEN_STRING_INITIALIZER 16308 (struct cmd_pctype_mapping_get_result, 16309 port, "port"); 16310 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id = 16311 TOKEN_NUM_INITIALIZER 16312 (struct cmd_pctype_mapping_get_result, 16313 port_id, UINT16); 16314 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype = 16315 TOKEN_STRING_INITIALIZER 16316 (struct cmd_pctype_mapping_get_result, 16317 pctype, "pctype"); 16318 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping = 16319 TOKEN_STRING_INITIALIZER 16320 (struct cmd_pctype_mapping_get_result, 16321 mapping, "mapping"); 16322 16323 static void 16324 cmd_pctype_mapping_get_parsed( 16325 void *parsed_result, 16326 __attribute__((unused)) struct cmdline *cl, 16327 __attribute__((unused)) void *data) 16328 { 16329 struct cmd_pctype_mapping_get_result *res = parsed_result; 16330 int ret = -ENOTSUP; 16331 #ifdef RTE_LIBRTE_I40E_PMD 16332 struct rte_pmd_i40e_flow_type_mapping 16333 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 16334 int i, j, first_pctype; 16335 #endif 16336 16337 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16338 return; 16339 16340 #ifdef RTE_LIBRTE_I40E_PMD 16341 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping); 16342 #endif 16343 16344 switch (ret) { 16345 case 0: 16346 break; 16347 case -ENODEV: 16348 printf("invalid port_id %d\n", res->port_id); 16349 return; 16350 case -ENOTSUP: 16351 printf("function not implemented\n"); 16352 return; 16353 default: 16354 printf("programming error: (%s)\n", strerror(-ret)); 16355 return; 16356 } 16357 16358 #ifdef RTE_LIBRTE_I40E_PMD 16359 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) { 16360 if (mapping[i].pctype != 0ULL) { 16361 first_pctype = 1; 16362 16363 printf("pctype: "); 16364 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) { 16365 if (mapping[i].pctype & (1ULL << j)) { 16366 printf(first_pctype ? 16367 "%02d" : ",%02d", j); 16368 first_pctype = 0; 16369 } 16370 } 16371 printf(" -> flowtype: %02d\n", mapping[i].flow_type); 16372 } 16373 } 16374 #endif 16375 } 16376 16377 cmdline_parse_inst_t cmd_pctype_mapping_get = { 16378 .f = cmd_pctype_mapping_get_parsed, 16379 .data = NULL, 16380 .help_str = "show port <port_id> pctype mapping", 16381 .tokens = { 16382 (void *)&cmd_pctype_mapping_get_show, 16383 (void *)&cmd_pctype_mapping_get_port, 16384 (void *)&cmd_pctype_mapping_get_port_id, 16385 (void *)&cmd_pctype_mapping_get_pctype, 16386 (void *)&cmd_pctype_mapping_get_mapping, 16387 NULL, 16388 }, 16389 }; 16390 16391 /* port config pctype mapping update */ 16392 16393 /* Common result structure for port config pctype mapping update */ 16394 struct cmd_pctype_mapping_update_result { 16395 cmdline_fixed_string_t port; 16396 cmdline_fixed_string_t config; 16397 portid_t port_id; 16398 cmdline_fixed_string_t pctype; 16399 cmdline_fixed_string_t mapping; 16400 cmdline_fixed_string_t update; 16401 cmdline_fixed_string_t pctype_list; 16402 uint16_t flow_type; 16403 }; 16404 16405 /* Common CLI fields for pctype mapping update*/ 16406 cmdline_parse_token_string_t cmd_pctype_mapping_update_port = 16407 TOKEN_STRING_INITIALIZER 16408 (struct cmd_pctype_mapping_update_result, 16409 port, "port"); 16410 cmdline_parse_token_string_t cmd_pctype_mapping_update_config = 16411 TOKEN_STRING_INITIALIZER 16412 (struct cmd_pctype_mapping_update_result, 16413 config, "config"); 16414 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id = 16415 TOKEN_NUM_INITIALIZER 16416 (struct cmd_pctype_mapping_update_result, 16417 port_id, UINT16); 16418 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype = 16419 TOKEN_STRING_INITIALIZER 16420 (struct cmd_pctype_mapping_update_result, 16421 pctype, "pctype"); 16422 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping = 16423 TOKEN_STRING_INITIALIZER 16424 (struct cmd_pctype_mapping_update_result, 16425 mapping, "mapping"); 16426 cmdline_parse_token_string_t cmd_pctype_mapping_update_update = 16427 TOKEN_STRING_INITIALIZER 16428 (struct cmd_pctype_mapping_update_result, 16429 update, "update"); 16430 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type = 16431 TOKEN_STRING_INITIALIZER 16432 (struct cmd_pctype_mapping_update_result, 16433 pctype_list, NULL); 16434 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type = 16435 TOKEN_NUM_INITIALIZER 16436 (struct cmd_pctype_mapping_update_result, 16437 flow_type, UINT16); 16438 16439 static void 16440 cmd_pctype_mapping_update_parsed( 16441 void *parsed_result, 16442 __attribute__((unused)) struct cmdline *cl, 16443 __attribute__((unused)) void *data) 16444 { 16445 struct cmd_pctype_mapping_update_result *res = parsed_result; 16446 int ret = -ENOTSUP; 16447 #ifdef RTE_LIBRTE_I40E_PMD 16448 struct rte_pmd_i40e_flow_type_mapping mapping; 16449 unsigned int i; 16450 unsigned int nb_item; 16451 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX]; 16452 #endif 16453 16454 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16455 return; 16456 16457 #ifdef RTE_LIBRTE_I40E_PMD 16458 nb_item = parse_item_list(res->pctype_list, "pctypes", 16459 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1); 16460 mapping.flow_type = res->flow_type; 16461 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++) 16462 mapping.pctype |= (1ULL << pctype_list[i]); 16463 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id, 16464 &mapping, 16465 1, 16466 0); 16467 #endif 16468 16469 switch (ret) { 16470 case 0: 16471 break; 16472 case -EINVAL: 16473 printf("invalid pctype or flow type\n"); 16474 break; 16475 case -ENODEV: 16476 printf("invalid port_id %d\n", res->port_id); 16477 break; 16478 case -ENOTSUP: 16479 printf("function not implemented\n"); 16480 break; 16481 default: 16482 printf("programming error: (%s)\n", strerror(-ret)); 16483 } 16484 } 16485 16486 cmdline_parse_inst_t cmd_pctype_mapping_update = { 16487 .f = cmd_pctype_mapping_update_parsed, 16488 .data = NULL, 16489 .help_str = "port config <port_id> pctype mapping update" 16490 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>", 16491 .tokens = { 16492 (void *)&cmd_pctype_mapping_update_port, 16493 (void *)&cmd_pctype_mapping_update_config, 16494 (void *)&cmd_pctype_mapping_update_port_id, 16495 (void *)&cmd_pctype_mapping_update_pctype, 16496 (void *)&cmd_pctype_mapping_update_mapping, 16497 (void *)&cmd_pctype_mapping_update_update, 16498 (void *)&cmd_pctype_mapping_update_pc_type, 16499 (void *)&cmd_pctype_mapping_update_flow_type, 16500 NULL, 16501 }, 16502 }; 16503 16504 /* ptype mapping get */ 16505 16506 /* Common result structure for ptype mapping get */ 16507 struct cmd_ptype_mapping_get_result { 16508 cmdline_fixed_string_t ptype; 16509 cmdline_fixed_string_t mapping; 16510 cmdline_fixed_string_t get; 16511 portid_t port_id; 16512 uint8_t valid_only; 16513 }; 16514 16515 /* Common CLI fields for ptype mapping get */ 16516 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype = 16517 TOKEN_STRING_INITIALIZER 16518 (struct cmd_ptype_mapping_get_result, 16519 ptype, "ptype"); 16520 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping = 16521 TOKEN_STRING_INITIALIZER 16522 (struct cmd_ptype_mapping_get_result, 16523 mapping, "mapping"); 16524 cmdline_parse_token_string_t cmd_ptype_mapping_get_get = 16525 TOKEN_STRING_INITIALIZER 16526 (struct cmd_ptype_mapping_get_result, 16527 get, "get"); 16528 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id = 16529 TOKEN_NUM_INITIALIZER 16530 (struct cmd_ptype_mapping_get_result, 16531 port_id, UINT16); 16532 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only = 16533 TOKEN_NUM_INITIALIZER 16534 (struct cmd_ptype_mapping_get_result, 16535 valid_only, UINT8); 16536 16537 static void 16538 cmd_ptype_mapping_get_parsed( 16539 void *parsed_result, 16540 __attribute__((unused)) struct cmdline *cl, 16541 __attribute__((unused)) void *data) 16542 { 16543 struct cmd_ptype_mapping_get_result *res = parsed_result; 16544 int ret = -ENOTSUP; 16545 #ifdef RTE_LIBRTE_I40E_PMD 16546 int max_ptype_num = 256; 16547 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; 16548 uint16_t count; 16549 int i; 16550 #endif 16551 16552 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16553 return; 16554 16555 #ifdef RTE_LIBRTE_I40E_PMD 16556 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, 16557 mapping, 16558 max_ptype_num, 16559 &count, 16560 res->valid_only); 16561 #endif 16562 16563 switch (ret) { 16564 case 0: 16565 break; 16566 case -ENODEV: 16567 printf("invalid port_id %d\n", res->port_id); 16568 break; 16569 case -ENOTSUP: 16570 printf("function not implemented\n"); 16571 break; 16572 default: 16573 printf("programming error: (%s)\n", strerror(-ret)); 16574 } 16575 16576 #ifdef RTE_LIBRTE_I40E_PMD 16577 if (!ret) { 16578 for (i = 0; i < count; i++) 16579 printf("%3d\t0x%08x\n", 16580 mapping[i].hw_ptype, mapping[i].sw_ptype); 16581 } 16582 #endif 16583 } 16584 16585 cmdline_parse_inst_t cmd_ptype_mapping_get = { 16586 .f = cmd_ptype_mapping_get_parsed, 16587 .data = NULL, 16588 .help_str = "ptype mapping get <port_id> <valid_only>", 16589 .tokens = { 16590 (void *)&cmd_ptype_mapping_get_ptype, 16591 (void *)&cmd_ptype_mapping_get_mapping, 16592 (void *)&cmd_ptype_mapping_get_get, 16593 (void *)&cmd_ptype_mapping_get_port_id, 16594 (void *)&cmd_ptype_mapping_get_valid_only, 16595 NULL, 16596 }, 16597 }; 16598 16599 /* ptype mapping replace */ 16600 16601 /* Common result structure for ptype mapping replace */ 16602 struct cmd_ptype_mapping_replace_result { 16603 cmdline_fixed_string_t ptype; 16604 cmdline_fixed_string_t mapping; 16605 cmdline_fixed_string_t replace; 16606 portid_t port_id; 16607 uint32_t target; 16608 uint8_t mask; 16609 uint32_t pkt_type; 16610 }; 16611 16612 /* Common CLI fields for ptype mapping replace */ 16613 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype = 16614 TOKEN_STRING_INITIALIZER 16615 (struct cmd_ptype_mapping_replace_result, 16616 ptype, "ptype"); 16617 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping = 16618 TOKEN_STRING_INITIALIZER 16619 (struct cmd_ptype_mapping_replace_result, 16620 mapping, "mapping"); 16621 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace = 16622 TOKEN_STRING_INITIALIZER 16623 (struct cmd_ptype_mapping_replace_result, 16624 replace, "replace"); 16625 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id = 16626 TOKEN_NUM_INITIALIZER 16627 (struct cmd_ptype_mapping_replace_result, 16628 port_id, UINT16); 16629 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target = 16630 TOKEN_NUM_INITIALIZER 16631 (struct cmd_ptype_mapping_replace_result, 16632 target, UINT32); 16633 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask = 16634 TOKEN_NUM_INITIALIZER 16635 (struct cmd_ptype_mapping_replace_result, 16636 mask, UINT8); 16637 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type = 16638 TOKEN_NUM_INITIALIZER 16639 (struct cmd_ptype_mapping_replace_result, 16640 pkt_type, UINT32); 16641 16642 static void 16643 cmd_ptype_mapping_replace_parsed( 16644 void *parsed_result, 16645 __attribute__((unused)) struct cmdline *cl, 16646 __attribute__((unused)) void *data) 16647 { 16648 struct cmd_ptype_mapping_replace_result *res = parsed_result; 16649 int ret = -ENOTSUP; 16650 16651 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16652 return; 16653 16654 #ifdef RTE_LIBRTE_I40E_PMD 16655 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id, 16656 res->target, 16657 res->mask, 16658 res->pkt_type); 16659 #endif 16660 16661 switch (ret) { 16662 case 0: 16663 break; 16664 case -EINVAL: 16665 printf("invalid ptype 0x%8x or 0x%8x\n", 16666 res->target, res->pkt_type); 16667 break; 16668 case -ENODEV: 16669 printf("invalid port_id %d\n", res->port_id); 16670 break; 16671 case -ENOTSUP: 16672 printf("function not implemented\n"); 16673 break; 16674 default: 16675 printf("programming error: (%s)\n", strerror(-ret)); 16676 } 16677 } 16678 16679 cmdline_parse_inst_t cmd_ptype_mapping_replace = { 16680 .f = cmd_ptype_mapping_replace_parsed, 16681 .data = NULL, 16682 .help_str = 16683 "ptype mapping replace <port_id> <target> <mask> <pkt_type>", 16684 .tokens = { 16685 (void *)&cmd_ptype_mapping_replace_ptype, 16686 (void *)&cmd_ptype_mapping_replace_mapping, 16687 (void *)&cmd_ptype_mapping_replace_replace, 16688 (void *)&cmd_ptype_mapping_replace_port_id, 16689 (void *)&cmd_ptype_mapping_replace_target, 16690 (void *)&cmd_ptype_mapping_replace_mask, 16691 (void *)&cmd_ptype_mapping_replace_pkt_type, 16692 NULL, 16693 }, 16694 }; 16695 16696 /* ptype mapping reset */ 16697 16698 /* Common result structure for ptype mapping reset */ 16699 struct cmd_ptype_mapping_reset_result { 16700 cmdline_fixed_string_t ptype; 16701 cmdline_fixed_string_t mapping; 16702 cmdline_fixed_string_t reset; 16703 portid_t port_id; 16704 }; 16705 16706 /* Common CLI fields for ptype mapping reset*/ 16707 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype = 16708 TOKEN_STRING_INITIALIZER 16709 (struct cmd_ptype_mapping_reset_result, 16710 ptype, "ptype"); 16711 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping = 16712 TOKEN_STRING_INITIALIZER 16713 (struct cmd_ptype_mapping_reset_result, 16714 mapping, "mapping"); 16715 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset = 16716 TOKEN_STRING_INITIALIZER 16717 (struct cmd_ptype_mapping_reset_result, 16718 reset, "reset"); 16719 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id = 16720 TOKEN_NUM_INITIALIZER 16721 (struct cmd_ptype_mapping_reset_result, 16722 port_id, UINT16); 16723 16724 static void 16725 cmd_ptype_mapping_reset_parsed( 16726 void *parsed_result, 16727 __attribute__((unused)) struct cmdline *cl, 16728 __attribute__((unused)) void *data) 16729 { 16730 struct cmd_ptype_mapping_reset_result *res = parsed_result; 16731 int ret = -ENOTSUP; 16732 16733 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16734 return; 16735 16736 #ifdef RTE_LIBRTE_I40E_PMD 16737 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id); 16738 #endif 16739 16740 switch (ret) { 16741 case 0: 16742 break; 16743 case -ENODEV: 16744 printf("invalid port_id %d\n", res->port_id); 16745 break; 16746 case -ENOTSUP: 16747 printf("function not implemented\n"); 16748 break; 16749 default: 16750 printf("programming error: (%s)\n", strerror(-ret)); 16751 } 16752 } 16753 16754 cmdline_parse_inst_t cmd_ptype_mapping_reset = { 16755 .f = cmd_ptype_mapping_reset_parsed, 16756 .data = NULL, 16757 .help_str = "ptype mapping reset <port_id>", 16758 .tokens = { 16759 (void *)&cmd_ptype_mapping_reset_ptype, 16760 (void *)&cmd_ptype_mapping_reset_mapping, 16761 (void *)&cmd_ptype_mapping_reset_reset, 16762 (void *)&cmd_ptype_mapping_reset_port_id, 16763 NULL, 16764 }, 16765 }; 16766 16767 /* ptype mapping update */ 16768 16769 /* Common result structure for ptype mapping update */ 16770 struct cmd_ptype_mapping_update_result { 16771 cmdline_fixed_string_t ptype; 16772 cmdline_fixed_string_t mapping; 16773 cmdline_fixed_string_t reset; 16774 portid_t port_id; 16775 uint8_t hw_ptype; 16776 uint32_t sw_ptype; 16777 }; 16778 16779 /* Common CLI fields for ptype mapping update*/ 16780 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype = 16781 TOKEN_STRING_INITIALIZER 16782 (struct cmd_ptype_mapping_update_result, 16783 ptype, "ptype"); 16784 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping = 16785 TOKEN_STRING_INITIALIZER 16786 (struct cmd_ptype_mapping_update_result, 16787 mapping, "mapping"); 16788 cmdline_parse_token_string_t cmd_ptype_mapping_update_update = 16789 TOKEN_STRING_INITIALIZER 16790 (struct cmd_ptype_mapping_update_result, 16791 reset, "update"); 16792 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id = 16793 TOKEN_NUM_INITIALIZER 16794 (struct cmd_ptype_mapping_update_result, 16795 port_id, UINT16); 16796 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype = 16797 TOKEN_NUM_INITIALIZER 16798 (struct cmd_ptype_mapping_update_result, 16799 hw_ptype, UINT8); 16800 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype = 16801 TOKEN_NUM_INITIALIZER 16802 (struct cmd_ptype_mapping_update_result, 16803 sw_ptype, UINT32); 16804 16805 static void 16806 cmd_ptype_mapping_update_parsed( 16807 void *parsed_result, 16808 __attribute__((unused)) struct cmdline *cl, 16809 __attribute__((unused)) void *data) 16810 { 16811 struct cmd_ptype_mapping_update_result *res = parsed_result; 16812 int ret = -ENOTSUP; 16813 #ifdef RTE_LIBRTE_I40E_PMD 16814 struct rte_pmd_i40e_ptype_mapping mapping; 16815 #endif 16816 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16817 return; 16818 16819 #ifdef RTE_LIBRTE_I40E_PMD 16820 mapping.hw_ptype = res->hw_ptype; 16821 mapping.sw_ptype = res->sw_ptype; 16822 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id, 16823 &mapping, 16824 1, 16825 0); 16826 #endif 16827 16828 switch (ret) { 16829 case 0: 16830 break; 16831 case -EINVAL: 16832 printf("invalid ptype 0x%8x\n", res->sw_ptype); 16833 break; 16834 case -ENODEV: 16835 printf("invalid port_id %d\n", res->port_id); 16836 break; 16837 case -ENOTSUP: 16838 printf("function not implemented\n"); 16839 break; 16840 default: 16841 printf("programming error: (%s)\n", strerror(-ret)); 16842 } 16843 } 16844 16845 cmdline_parse_inst_t cmd_ptype_mapping_update = { 16846 .f = cmd_ptype_mapping_update_parsed, 16847 .data = NULL, 16848 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>", 16849 .tokens = { 16850 (void *)&cmd_ptype_mapping_update_ptype, 16851 (void *)&cmd_ptype_mapping_update_mapping, 16852 (void *)&cmd_ptype_mapping_update_update, 16853 (void *)&cmd_ptype_mapping_update_port_id, 16854 (void *)&cmd_ptype_mapping_update_hw_ptype, 16855 (void *)&cmd_ptype_mapping_update_sw_ptype, 16856 NULL, 16857 }, 16858 }; 16859 16860 /* Common result structure for file commands */ 16861 struct cmd_cmdfile_result { 16862 cmdline_fixed_string_t load; 16863 cmdline_fixed_string_t filename; 16864 }; 16865 16866 /* Common CLI fields for file commands */ 16867 cmdline_parse_token_string_t cmd_load_cmdfile = 16868 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load"); 16869 cmdline_parse_token_string_t cmd_load_cmdfile_filename = 16870 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL); 16871 16872 static void 16873 cmd_load_from_file_parsed( 16874 void *parsed_result, 16875 __attribute__((unused)) struct cmdline *cl, 16876 __attribute__((unused)) void *data) 16877 { 16878 struct cmd_cmdfile_result *res = parsed_result; 16879 16880 cmdline_read_from_file(res->filename); 16881 } 16882 16883 cmdline_parse_inst_t cmd_load_from_file = { 16884 .f = cmd_load_from_file_parsed, 16885 .data = NULL, 16886 .help_str = "load <filename>", 16887 .tokens = { 16888 (void *)&cmd_load_cmdfile, 16889 (void *)&cmd_load_cmdfile_filename, 16890 NULL, 16891 }, 16892 }; 16893 16894 /* Get Rx offloads capabilities */ 16895 struct cmd_rx_offload_get_capa_result { 16896 cmdline_fixed_string_t show; 16897 cmdline_fixed_string_t port; 16898 portid_t port_id; 16899 cmdline_fixed_string_t rx_offload; 16900 cmdline_fixed_string_t capabilities; 16901 }; 16902 16903 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show = 16904 TOKEN_STRING_INITIALIZER 16905 (struct cmd_rx_offload_get_capa_result, 16906 show, "show"); 16907 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port = 16908 TOKEN_STRING_INITIALIZER 16909 (struct cmd_rx_offload_get_capa_result, 16910 port, "port"); 16911 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id = 16912 TOKEN_NUM_INITIALIZER 16913 (struct cmd_rx_offload_get_capa_result, 16914 port_id, UINT16); 16915 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload = 16916 TOKEN_STRING_INITIALIZER 16917 (struct cmd_rx_offload_get_capa_result, 16918 rx_offload, "rx_offload"); 16919 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities = 16920 TOKEN_STRING_INITIALIZER 16921 (struct cmd_rx_offload_get_capa_result, 16922 capabilities, "capabilities"); 16923 16924 static void 16925 print_rx_offloads(uint64_t offloads) 16926 { 16927 uint64_t single_offload; 16928 int begin; 16929 int end; 16930 int bit; 16931 16932 if (offloads == 0) 16933 return; 16934 16935 begin = __builtin_ctzll(offloads); 16936 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 16937 16938 single_offload = 1 << begin; 16939 for (bit = begin; bit < end; bit++) { 16940 if (offloads & single_offload) 16941 printf(" %s", 16942 rte_eth_dev_rx_offload_name(single_offload)); 16943 single_offload <<= 1; 16944 } 16945 } 16946 16947 static void 16948 cmd_rx_offload_get_capa_parsed( 16949 void *parsed_result, 16950 __attribute__((unused)) struct cmdline *cl, 16951 __attribute__((unused)) void *data) 16952 { 16953 struct cmd_rx_offload_get_capa_result *res = parsed_result; 16954 struct rte_eth_dev_info dev_info; 16955 portid_t port_id = res->port_id; 16956 uint64_t queue_offloads; 16957 uint64_t port_offloads; 16958 16959 rte_eth_dev_info_get(port_id, &dev_info); 16960 queue_offloads = dev_info.rx_queue_offload_capa; 16961 port_offloads = dev_info.rx_offload_capa ^ queue_offloads; 16962 16963 printf("Rx Offloading Capabilities of port %d :\n", port_id); 16964 printf(" Per Queue :"); 16965 print_rx_offloads(queue_offloads); 16966 16967 printf("\n"); 16968 printf(" Per Port :"); 16969 print_rx_offloads(port_offloads); 16970 printf("\n\n"); 16971 } 16972 16973 cmdline_parse_inst_t cmd_rx_offload_get_capa = { 16974 .f = cmd_rx_offload_get_capa_parsed, 16975 .data = NULL, 16976 .help_str = "show port <port_id> rx_offload capabilities", 16977 .tokens = { 16978 (void *)&cmd_rx_offload_get_capa_show, 16979 (void *)&cmd_rx_offload_get_capa_port, 16980 (void *)&cmd_rx_offload_get_capa_port_id, 16981 (void *)&cmd_rx_offload_get_capa_rx_offload, 16982 (void *)&cmd_rx_offload_get_capa_capabilities, 16983 NULL, 16984 } 16985 }; 16986 16987 /* Get Rx offloads configuration */ 16988 struct cmd_rx_offload_get_configuration_result { 16989 cmdline_fixed_string_t show; 16990 cmdline_fixed_string_t port; 16991 portid_t port_id; 16992 cmdline_fixed_string_t rx_offload; 16993 cmdline_fixed_string_t configuration; 16994 }; 16995 16996 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show = 16997 TOKEN_STRING_INITIALIZER 16998 (struct cmd_rx_offload_get_configuration_result, 16999 show, "show"); 17000 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port = 17001 TOKEN_STRING_INITIALIZER 17002 (struct cmd_rx_offload_get_configuration_result, 17003 port, "port"); 17004 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id = 17005 TOKEN_NUM_INITIALIZER 17006 (struct cmd_rx_offload_get_configuration_result, 17007 port_id, UINT16); 17008 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload = 17009 TOKEN_STRING_INITIALIZER 17010 (struct cmd_rx_offload_get_configuration_result, 17011 rx_offload, "rx_offload"); 17012 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration = 17013 TOKEN_STRING_INITIALIZER 17014 (struct cmd_rx_offload_get_configuration_result, 17015 configuration, "configuration"); 17016 17017 static void 17018 cmd_rx_offload_get_configuration_parsed( 17019 void *parsed_result, 17020 __attribute__((unused)) struct cmdline *cl, 17021 __attribute__((unused)) void *data) 17022 { 17023 struct cmd_rx_offload_get_configuration_result *res = parsed_result; 17024 struct rte_eth_dev_info dev_info; 17025 portid_t port_id = res->port_id; 17026 struct rte_port *port = &ports[port_id]; 17027 uint64_t port_offloads; 17028 uint64_t queue_offloads; 17029 uint16_t nb_rx_queues; 17030 int q; 17031 17032 printf("Rx Offloading Configuration of port %d :\n", port_id); 17033 17034 port_offloads = port->dev_conf.rxmode.offloads; 17035 printf(" Port :"); 17036 print_rx_offloads(port_offloads); 17037 printf("\n"); 17038 17039 rte_eth_dev_info_get(port_id, &dev_info); 17040 nb_rx_queues = dev_info.nb_rx_queues; 17041 for (q = 0; q < nb_rx_queues; q++) { 17042 queue_offloads = port->rx_conf[q].offloads; 17043 printf(" Queue[%2d] :", q); 17044 print_rx_offloads(queue_offloads); 17045 printf("\n"); 17046 } 17047 printf("\n"); 17048 } 17049 17050 cmdline_parse_inst_t cmd_rx_offload_get_configuration = { 17051 .f = cmd_rx_offload_get_configuration_parsed, 17052 .data = NULL, 17053 .help_str = "show port <port_id> rx_offload configuration", 17054 .tokens = { 17055 (void *)&cmd_rx_offload_get_configuration_show, 17056 (void *)&cmd_rx_offload_get_configuration_port, 17057 (void *)&cmd_rx_offload_get_configuration_port_id, 17058 (void *)&cmd_rx_offload_get_configuration_rx_offload, 17059 (void *)&cmd_rx_offload_get_configuration_configuration, 17060 NULL, 17061 } 17062 }; 17063 17064 /* Enable/Disable a per port offloading */ 17065 struct cmd_config_per_port_rx_offload_result { 17066 cmdline_fixed_string_t port; 17067 cmdline_fixed_string_t config; 17068 portid_t port_id; 17069 cmdline_fixed_string_t rx_offload; 17070 cmdline_fixed_string_t offload; 17071 cmdline_fixed_string_t on_off; 17072 }; 17073 17074 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port = 17075 TOKEN_STRING_INITIALIZER 17076 (struct cmd_config_per_port_rx_offload_result, 17077 port, "port"); 17078 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config = 17079 TOKEN_STRING_INITIALIZER 17080 (struct cmd_config_per_port_rx_offload_result, 17081 config, "config"); 17082 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id = 17083 TOKEN_NUM_INITIALIZER 17084 (struct cmd_config_per_port_rx_offload_result, 17085 port_id, UINT16); 17086 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload = 17087 TOKEN_STRING_INITIALIZER 17088 (struct cmd_config_per_port_rx_offload_result, 17089 rx_offload, "rx_offload"); 17090 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload = 17091 TOKEN_STRING_INITIALIZER 17092 (struct cmd_config_per_port_rx_offload_result, 17093 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 17094 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 17095 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 17096 "crc_strip#scatter#timestamp#security#keep_crc"); 17097 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off = 17098 TOKEN_STRING_INITIALIZER 17099 (struct cmd_config_per_port_rx_offload_result, 17100 on_off, "on#off"); 17101 17102 static uint64_t 17103 search_rx_offload(const char *name) 17104 { 17105 uint64_t single_offload; 17106 const char *single_name; 17107 int found = 0; 17108 unsigned int bit; 17109 17110 single_offload = 1; 17111 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 17112 single_name = rte_eth_dev_rx_offload_name(single_offload); 17113 if (!strcasecmp(single_name, name)) { 17114 found = 1; 17115 break; 17116 } else if (!strcasecmp(single_name, "UNKNOWN")) 17117 break; 17118 else if (single_name == NULL) 17119 break; 17120 single_offload <<= 1; 17121 } 17122 17123 if (found) 17124 return single_offload; 17125 17126 return 0; 17127 } 17128 17129 static void 17130 cmd_config_per_port_rx_offload_parsed(void *parsed_result, 17131 __attribute__((unused)) struct cmdline *cl, 17132 __attribute__((unused)) void *data) 17133 { 17134 struct cmd_config_per_port_rx_offload_result *res = parsed_result; 17135 portid_t port_id = res->port_id; 17136 struct rte_eth_dev_info dev_info; 17137 struct rte_port *port = &ports[port_id]; 17138 uint64_t single_offload; 17139 uint16_t nb_rx_queues; 17140 int q; 17141 17142 if (port->port_status != RTE_PORT_STOPPED) { 17143 printf("Error: Can't config offload when Port %d " 17144 "is not stopped\n", port_id); 17145 return; 17146 } 17147 17148 single_offload = search_rx_offload(res->offload); 17149 if (single_offload == 0) { 17150 printf("Unknown offload name: %s\n", res->offload); 17151 return; 17152 } 17153 17154 rte_eth_dev_info_get(port_id, &dev_info); 17155 nb_rx_queues = dev_info.nb_rx_queues; 17156 if (!strcmp(res->on_off, "on")) { 17157 port->dev_conf.rxmode.offloads |= single_offload; 17158 for (q = 0; q < nb_rx_queues; q++) 17159 port->rx_conf[q].offloads |= single_offload; 17160 } else { 17161 port->dev_conf.rxmode.offloads &= ~single_offload; 17162 for (q = 0; q < nb_rx_queues; q++) 17163 port->rx_conf[q].offloads &= ~single_offload; 17164 } 17165 17166 cmd_reconfig_device_queue(port_id, 1, 1); 17167 } 17168 17169 cmdline_parse_inst_t cmd_config_per_port_rx_offload = { 17170 .f = cmd_config_per_port_rx_offload_parsed, 17171 .data = NULL, 17172 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|" 17173 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 17174 "macsec_strip|header_split|vlan_filter|vlan_extend|" 17175 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc " 17176 "on|off", 17177 .tokens = { 17178 (void *)&cmd_config_per_port_rx_offload_result_port, 17179 (void *)&cmd_config_per_port_rx_offload_result_config, 17180 (void *)&cmd_config_per_port_rx_offload_result_port_id, 17181 (void *)&cmd_config_per_port_rx_offload_result_rx_offload, 17182 (void *)&cmd_config_per_port_rx_offload_result_offload, 17183 (void *)&cmd_config_per_port_rx_offload_result_on_off, 17184 NULL, 17185 } 17186 }; 17187 17188 /* Enable/Disable a per queue offloading */ 17189 struct cmd_config_per_queue_rx_offload_result { 17190 cmdline_fixed_string_t port; 17191 portid_t port_id; 17192 cmdline_fixed_string_t rxq; 17193 uint16_t queue_id; 17194 cmdline_fixed_string_t rx_offload; 17195 cmdline_fixed_string_t offload; 17196 cmdline_fixed_string_t on_off; 17197 }; 17198 17199 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port = 17200 TOKEN_STRING_INITIALIZER 17201 (struct cmd_config_per_queue_rx_offload_result, 17202 port, "port"); 17203 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id = 17204 TOKEN_NUM_INITIALIZER 17205 (struct cmd_config_per_queue_rx_offload_result, 17206 port_id, UINT16); 17207 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq = 17208 TOKEN_STRING_INITIALIZER 17209 (struct cmd_config_per_queue_rx_offload_result, 17210 rxq, "rxq"); 17211 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id = 17212 TOKEN_NUM_INITIALIZER 17213 (struct cmd_config_per_queue_rx_offload_result, 17214 queue_id, UINT16); 17215 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload = 17216 TOKEN_STRING_INITIALIZER 17217 (struct cmd_config_per_queue_rx_offload_result, 17218 rx_offload, "rx_offload"); 17219 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload = 17220 TOKEN_STRING_INITIALIZER 17221 (struct cmd_config_per_queue_rx_offload_result, 17222 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 17223 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 17224 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 17225 "crc_strip#scatter#timestamp#security#keep_crc"); 17226 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off = 17227 TOKEN_STRING_INITIALIZER 17228 (struct cmd_config_per_queue_rx_offload_result, 17229 on_off, "on#off"); 17230 17231 static void 17232 cmd_config_per_queue_rx_offload_parsed(void *parsed_result, 17233 __attribute__((unused)) struct cmdline *cl, 17234 __attribute__((unused)) void *data) 17235 { 17236 struct cmd_config_per_queue_rx_offload_result *res = parsed_result; 17237 struct rte_eth_dev_info dev_info; 17238 portid_t port_id = res->port_id; 17239 uint16_t queue_id = res->queue_id; 17240 struct rte_port *port = &ports[port_id]; 17241 uint64_t single_offload; 17242 17243 if (port->port_status != RTE_PORT_STOPPED) { 17244 printf("Error: Can't config offload when Port %d " 17245 "is not stopped\n", port_id); 17246 return; 17247 } 17248 17249 rte_eth_dev_info_get(port_id, &dev_info); 17250 if (queue_id >= dev_info.nb_rx_queues) { 17251 printf("Error: input queue_id should be 0 ... " 17252 "%d\n", dev_info.nb_rx_queues - 1); 17253 return; 17254 } 17255 17256 single_offload = search_rx_offload(res->offload); 17257 if (single_offload == 0) { 17258 printf("Unknown offload name: %s\n", res->offload); 17259 return; 17260 } 17261 17262 if (!strcmp(res->on_off, "on")) 17263 port->rx_conf[queue_id].offloads |= single_offload; 17264 else 17265 port->rx_conf[queue_id].offloads &= ~single_offload; 17266 17267 cmd_reconfig_device_queue(port_id, 1, 1); 17268 } 17269 17270 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = { 17271 .f = cmd_config_per_queue_rx_offload_parsed, 17272 .data = NULL, 17273 .help_str = "port <port_id> rxq <queue_id> rx_offload " 17274 "vlan_strip|ipv4_cksum|" 17275 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 17276 "macsec_strip|header_split|vlan_filter|vlan_extend|" 17277 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc " 17278 "on|off", 17279 .tokens = { 17280 (void *)&cmd_config_per_queue_rx_offload_result_port, 17281 (void *)&cmd_config_per_queue_rx_offload_result_port_id, 17282 (void *)&cmd_config_per_queue_rx_offload_result_rxq, 17283 (void *)&cmd_config_per_queue_rx_offload_result_queue_id, 17284 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload, 17285 (void *)&cmd_config_per_queue_rx_offload_result_offload, 17286 (void *)&cmd_config_per_queue_rx_offload_result_on_off, 17287 NULL, 17288 } 17289 }; 17290 17291 /* Get Tx offloads capabilities */ 17292 struct cmd_tx_offload_get_capa_result { 17293 cmdline_fixed_string_t show; 17294 cmdline_fixed_string_t port; 17295 portid_t port_id; 17296 cmdline_fixed_string_t tx_offload; 17297 cmdline_fixed_string_t capabilities; 17298 }; 17299 17300 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show = 17301 TOKEN_STRING_INITIALIZER 17302 (struct cmd_tx_offload_get_capa_result, 17303 show, "show"); 17304 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port = 17305 TOKEN_STRING_INITIALIZER 17306 (struct cmd_tx_offload_get_capa_result, 17307 port, "port"); 17308 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id = 17309 TOKEN_NUM_INITIALIZER 17310 (struct cmd_tx_offload_get_capa_result, 17311 port_id, UINT16); 17312 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload = 17313 TOKEN_STRING_INITIALIZER 17314 (struct cmd_tx_offload_get_capa_result, 17315 tx_offload, "tx_offload"); 17316 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities = 17317 TOKEN_STRING_INITIALIZER 17318 (struct cmd_tx_offload_get_capa_result, 17319 capabilities, "capabilities"); 17320 17321 static void 17322 print_tx_offloads(uint64_t offloads) 17323 { 17324 uint64_t single_offload; 17325 int begin; 17326 int end; 17327 int bit; 17328 17329 if (offloads == 0) 17330 return; 17331 17332 begin = __builtin_ctzll(offloads); 17333 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 17334 17335 single_offload = 1 << begin; 17336 for (bit = begin; bit < end; bit++) { 17337 if (offloads & single_offload) 17338 printf(" %s", 17339 rte_eth_dev_tx_offload_name(single_offload)); 17340 single_offload <<= 1; 17341 } 17342 } 17343 17344 static void 17345 cmd_tx_offload_get_capa_parsed( 17346 void *parsed_result, 17347 __attribute__((unused)) struct cmdline *cl, 17348 __attribute__((unused)) void *data) 17349 { 17350 struct cmd_tx_offload_get_capa_result *res = parsed_result; 17351 struct rte_eth_dev_info dev_info; 17352 portid_t port_id = res->port_id; 17353 uint64_t queue_offloads; 17354 uint64_t port_offloads; 17355 17356 rte_eth_dev_info_get(port_id, &dev_info); 17357 queue_offloads = dev_info.tx_queue_offload_capa; 17358 port_offloads = dev_info.tx_offload_capa ^ queue_offloads; 17359 17360 printf("Tx Offloading Capabilities of port %d :\n", port_id); 17361 printf(" Per Queue :"); 17362 print_tx_offloads(queue_offloads); 17363 17364 printf("\n"); 17365 printf(" Per Port :"); 17366 print_tx_offloads(port_offloads); 17367 printf("\n\n"); 17368 } 17369 17370 cmdline_parse_inst_t cmd_tx_offload_get_capa = { 17371 .f = cmd_tx_offload_get_capa_parsed, 17372 .data = NULL, 17373 .help_str = "show port <port_id> tx_offload capabilities", 17374 .tokens = { 17375 (void *)&cmd_tx_offload_get_capa_show, 17376 (void *)&cmd_tx_offload_get_capa_port, 17377 (void *)&cmd_tx_offload_get_capa_port_id, 17378 (void *)&cmd_tx_offload_get_capa_tx_offload, 17379 (void *)&cmd_tx_offload_get_capa_capabilities, 17380 NULL, 17381 } 17382 }; 17383 17384 /* Get Tx offloads configuration */ 17385 struct cmd_tx_offload_get_configuration_result { 17386 cmdline_fixed_string_t show; 17387 cmdline_fixed_string_t port; 17388 portid_t port_id; 17389 cmdline_fixed_string_t tx_offload; 17390 cmdline_fixed_string_t configuration; 17391 }; 17392 17393 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show = 17394 TOKEN_STRING_INITIALIZER 17395 (struct cmd_tx_offload_get_configuration_result, 17396 show, "show"); 17397 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port = 17398 TOKEN_STRING_INITIALIZER 17399 (struct cmd_tx_offload_get_configuration_result, 17400 port, "port"); 17401 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id = 17402 TOKEN_NUM_INITIALIZER 17403 (struct cmd_tx_offload_get_configuration_result, 17404 port_id, UINT16); 17405 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload = 17406 TOKEN_STRING_INITIALIZER 17407 (struct cmd_tx_offload_get_configuration_result, 17408 tx_offload, "tx_offload"); 17409 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration = 17410 TOKEN_STRING_INITIALIZER 17411 (struct cmd_tx_offload_get_configuration_result, 17412 configuration, "configuration"); 17413 17414 static void 17415 cmd_tx_offload_get_configuration_parsed( 17416 void *parsed_result, 17417 __attribute__((unused)) struct cmdline *cl, 17418 __attribute__((unused)) void *data) 17419 { 17420 struct cmd_tx_offload_get_configuration_result *res = parsed_result; 17421 struct rte_eth_dev_info dev_info; 17422 portid_t port_id = res->port_id; 17423 struct rte_port *port = &ports[port_id]; 17424 uint64_t port_offloads; 17425 uint64_t queue_offloads; 17426 uint16_t nb_tx_queues; 17427 int q; 17428 17429 printf("Tx Offloading Configuration of port %d :\n", port_id); 17430 17431 port_offloads = port->dev_conf.txmode.offloads; 17432 printf(" Port :"); 17433 print_tx_offloads(port_offloads); 17434 printf("\n"); 17435 17436 rte_eth_dev_info_get(port_id, &dev_info); 17437 nb_tx_queues = dev_info.nb_tx_queues; 17438 for (q = 0; q < nb_tx_queues; q++) { 17439 queue_offloads = port->tx_conf[q].offloads; 17440 printf(" Queue[%2d] :", q); 17441 print_tx_offloads(queue_offloads); 17442 printf("\n"); 17443 } 17444 printf("\n"); 17445 } 17446 17447 cmdline_parse_inst_t cmd_tx_offload_get_configuration = { 17448 .f = cmd_tx_offload_get_configuration_parsed, 17449 .data = NULL, 17450 .help_str = "show port <port_id> tx_offload configuration", 17451 .tokens = { 17452 (void *)&cmd_tx_offload_get_configuration_show, 17453 (void *)&cmd_tx_offload_get_configuration_port, 17454 (void *)&cmd_tx_offload_get_configuration_port_id, 17455 (void *)&cmd_tx_offload_get_configuration_tx_offload, 17456 (void *)&cmd_tx_offload_get_configuration_configuration, 17457 NULL, 17458 } 17459 }; 17460 17461 /* Enable/Disable a per port offloading */ 17462 struct cmd_config_per_port_tx_offload_result { 17463 cmdline_fixed_string_t port; 17464 cmdline_fixed_string_t config; 17465 portid_t port_id; 17466 cmdline_fixed_string_t tx_offload; 17467 cmdline_fixed_string_t offload; 17468 cmdline_fixed_string_t on_off; 17469 }; 17470 17471 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port = 17472 TOKEN_STRING_INITIALIZER 17473 (struct cmd_config_per_port_tx_offload_result, 17474 port, "port"); 17475 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config = 17476 TOKEN_STRING_INITIALIZER 17477 (struct cmd_config_per_port_tx_offload_result, 17478 config, "config"); 17479 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id = 17480 TOKEN_NUM_INITIALIZER 17481 (struct cmd_config_per_port_tx_offload_result, 17482 port_id, UINT16); 17483 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload = 17484 TOKEN_STRING_INITIALIZER 17485 (struct cmd_config_per_port_tx_offload_result, 17486 tx_offload, "tx_offload"); 17487 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload = 17488 TOKEN_STRING_INITIALIZER 17489 (struct cmd_config_per_port_tx_offload_result, 17490 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 17491 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 17492 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 17493 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 17494 "mt_lockfree#multi_segs#mbuf_fast_free#security"); 17495 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off = 17496 TOKEN_STRING_INITIALIZER 17497 (struct cmd_config_per_port_tx_offload_result, 17498 on_off, "on#off"); 17499 17500 static uint64_t 17501 search_tx_offload(const char *name) 17502 { 17503 uint64_t single_offload; 17504 const char *single_name; 17505 int found = 0; 17506 unsigned int bit; 17507 17508 single_offload = 1; 17509 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 17510 single_name = rte_eth_dev_tx_offload_name(single_offload); 17511 if (!strcasecmp(single_name, name)) { 17512 found = 1; 17513 break; 17514 } else if (!strcasecmp(single_name, "UNKNOWN")) 17515 break; 17516 else if (single_name == NULL) 17517 break; 17518 single_offload <<= 1; 17519 } 17520 17521 if (found) 17522 return single_offload; 17523 17524 return 0; 17525 } 17526 17527 static void 17528 cmd_config_per_port_tx_offload_parsed(void *parsed_result, 17529 __attribute__((unused)) struct cmdline *cl, 17530 __attribute__((unused)) void *data) 17531 { 17532 struct cmd_config_per_port_tx_offload_result *res = parsed_result; 17533 portid_t port_id = res->port_id; 17534 struct rte_eth_dev_info dev_info; 17535 struct rte_port *port = &ports[port_id]; 17536 uint64_t single_offload; 17537 uint16_t nb_tx_queues; 17538 int q; 17539 17540 if (port->port_status != RTE_PORT_STOPPED) { 17541 printf("Error: Can't config offload when Port %d " 17542 "is not stopped\n", port_id); 17543 return; 17544 } 17545 17546 single_offload = search_tx_offload(res->offload); 17547 if (single_offload == 0) { 17548 printf("Unknown offload name: %s\n", res->offload); 17549 return; 17550 } 17551 17552 rte_eth_dev_info_get(port_id, &dev_info); 17553 nb_tx_queues = dev_info.nb_tx_queues; 17554 if (!strcmp(res->on_off, "on")) { 17555 port->dev_conf.txmode.offloads |= single_offload; 17556 for (q = 0; q < nb_tx_queues; q++) 17557 port->tx_conf[q].offloads |= single_offload; 17558 } else { 17559 port->dev_conf.txmode.offloads &= ~single_offload; 17560 for (q = 0; q < nb_tx_queues; q++) 17561 port->tx_conf[q].offloads &= ~single_offload; 17562 } 17563 17564 cmd_reconfig_device_queue(port_id, 1, 1); 17565 } 17566 17567 cmdline_parse_inst_t cmd_config_per_port_tx_offload = { 17568 .f = cmd_config_per_port_tx_offload_parsed, 17569 .data = NULL, 17570 .help_str = "port config <port_id> tx_offload " 17571 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 17572 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 17573 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 17574 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 17575 "mt_lockfree|multi_segs|mbuf_fast_free|security " 17576 "on|off", 17577 .tokens = { 17578 (void *)&cmd_config_per_port_tx_offload_result_port, 17579 (void *)&cmd_config_per_port_tx_offload_result_config, 17580 (void *)&cmd_config_per_port_tx_offload_result_port_id, 17581 (void *)&cmd_config_per_port_tx_offload_result_tx_offload, 17582 (void *)&cmd_config_per_port_tx_offload_result_offload, 17583 (void *)&cmd_config_per_port_tx_offload_result_on_off, 17584 NULL, 17585 } 17586 }; 17587 17588 /* Enable/Disable a per queue offloading */ 17589 struct cmd_config_per_queue_tx_offload_result { 17590 cmdline_fixed_string_t port; 17591 portid_t port_id; 17592 cmdline_fixed_string_t txq; 17593 uint16_t queue_id; 17594 cmdline_fixed_string_t tx_offload; 17595 cmdline_fixed_string_t offload; 17596 cmdline_fixed_string_t on_off; 17597 }; 17598 17599 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port = 17600 TOKEN_STRING_INITIALIZER 17601 (struct cmd_config_per_queue_tx_offload_result, 17602 port, "port"); 17603 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id = 17604 TOKEN_NUM_INITIALIZER 17605 (struct cmd_config_per_queue_tx_offload_result, 17606 port_id, UINT16); 17607 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq = 17608 TOKEN_STRING_INITIALIZER 17609 (struct cmd_config_per_queue_tx_offload_result, 17610 txq, "txq"); 17611 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id = 17612 TOKEN_NUM_INITIALIZER 17613 (struct cmd_config_per_queue_tx_offload_result, 17614 queue_id, UINT16); 17615 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload = 17616 TOKEN_STRING_INITIALIZER 17617 (struct cmd_config_per_queue_tx_offload_result, 17618 tx_offload, "tx_offload"); 17619 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload = 17620 TOKEN_STRING_INITIALIZER 17621 (struct cmd_config_per_queue_tx_offload_result, 17622 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 17623 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 17624 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 17625 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 17626 "mt_lockfree#multi_segs#mbuf_fast_free#security"); 17627 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off = 17628 TOKEN_STRING_INITIALIZER 17629 (struct cmd_config_per_queue_tx_offload_result, 17630 on_off, "on#off"); 17631 17632 static void 17633 cmd_config_per_queue_tx_offload_parsed(void *parsed_result, 17634 __attribute__((unused)) struct cmdline *cl, 17635 __attribute__((unused)) void *data) 17636 { 17637 struct cmd_config_per_queue_tx_offload_result *res = parsed_result; 17638 struct rte_eth_dev_info dev_info; 17639 portid_t port_id = res->port_id; 17640 uint16_t queue_id = res->queue_id; 17641 struct rte_port *port = &ports[port_id]; 17642 uint64_t single_offload; 17643 17644 if (port->port_status != RTE_PORT_STOPPED) { 17645 printf("Error: Can't config offload when Port %d " 17646 "is not stopped\n", port_id); 17647 return; 17648 } 17649 17650 rte_eth_dev_info_get(port_id, &dev_info); 17651 if (queue_id >= dev_info.nb_tx_queues) { 17652 printf("Error: input queue_id should be 0 ... " 17653 "%d\n", dev_info.nb_tx_queues - 1); 17654 return; 17655 } 17656 17657 single_offload = search_tx_offload(res->offload); 17658 if (single_offload == 0) { 17659 printf("Unknown offload name: %s\n", res->offload); 17660 return; 17661 } 17662 17663 if (!strcmp(res->on_off, "on")) 17664 port->tx_conf[queue_id].offloads |= single_offload; 17665 else 17666 port->tx_conf[queue_id].offloads &= ~single_offload; 17667 17668 cmd_reconfig_device_queue(port_id, 1, 1); 17669 } 17670 17671 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = { 17672 .f = cmd_config_per_queue_tx_offload_parsed, 17673 .data = NULL, 17674 .help_str = "port <port_id> txq <queue_id> tx_offload " 17675 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 17676 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 17677 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 17678 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 17679 "mt_lockfree|multi_segs|mbuf_fast_free|security " 17680 "on|off", 17681 .tokens = { 17682 (void *)&cmd_config_per_queue_tx_offload_result_port, 17683 (void *)&cmd_config_per_queue_tx_offload_result_port_id, 17684 (void *)&cmd_config_per_queue_tx_offload_result_txq, 17685 (void *)&cmd_config_per_queue_tx_offload_result_queue_id, 17686 (void *)&cmd_config_per_queue_tx_offload_result_txoffload, 17687 (void *)&cmd_config_per_queue_tx_offload_result_offload, 17688 (void *)&cmd_config_per_queue_tx_offload_result_on_off, 17689 NULL, 17690 } 17691 }; 17692 17693 /* ******************************************************************************** */ 17694 17695 /* list of instructions */ 17696 cmdline_parse_ctx_t main_ctx[] = { 17697 (cmdline_parse_inst_t *)&cmd_help_brief, 17698 (cmdline_parse_inst_t *)&cmd_help_long, 17699 (cmdline_parse_inst_t *)&cmd_quit, 17700 (cmdline_parse_inst_t *)&cmd_load_from_file, 17701 (cmdline_parse_inst_t *)&cmd_showport, 17702 (cmdline_parse_inst_t *)&cmd_showqueue, 17703 (cmdline_parse_inst_t *)&cmd_showportall, 17704 (cmdline_parse_inst_t *)&cmd_showcfg, 17705 (cmdline_parse_inst_t *)&cmd_start, 17706 (cmdline_parse_inst_t *)&cmd_start_tx_first, 17707 (cmdline_parse_inst_t *)&cmd_start_tx_first_n, 17708 (cmdline_parse_inst_t *)&cmd_set_link_up, 17709 (cmdline_parse_inst_t *)&cmd_set_link_down, 17710 (cmdline_parse_inst_t *)&cmd_reset, 17711 (cmdline_parse_inst_t *)&cmd_set_numbers, 17712 (cmdline_parse_inst_t *)&cmd_set_log, 17713 (cmdline_parse_inst_t *)&cmd_set_txpkts, 17714 (cmdline_parse_inst_t *)&cmd_set_txsplit, 17715 (cmdline_parse_inst_t *)&cmd_set_fwd_list, 17716 (cmdline_parse_inst_t *)&cmd_set_fwd_mask, 17717 (cmdline_parse_inst_t *)&cmd_set_fwd_mode, 17718 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode, 17719 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, 17720 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one, 17721 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all, 17722 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one, 17723 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, 17724 (cmdline_parse_inst_t *)&cmd_set_flush_rx, 17725 (cmdline_parse_inst_t *)&cmd_set_link_check, 17726 (cmdline_parse_inst_t *)&cmd_set_bypass_mode, 17727 (cmdline_parse_inst_t *)&cmd_set_bypass_event, 17728 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, 17729 (cmdline_parse_inst_t *)&cmd_show_bypass_config, 17730 #ifdef RTE_LIBRTE_PMD_BOND 17731 (cmdline_parse_inst_t *) &cmd_set_bonding_mode, 17732 (cmdline_parse_inst_t *) &cmd_show_bonding_config, 17733 (cmdline_parse_inst_t *) &cmd_set_bonding_primary, 17734 (cmdline_parse_inst_t *) &cmd_add_bonding_slave, 17735 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, 17736 (cmdline_parse_inst_t *) &cmd_create_bonded_device, 17737 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr, 17738 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy, 17739 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period, 17740 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues, 17741 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy, 17742 #endif 17743 (cmdline_parse_inst_t *)&cmd_vlan_offload, 17744 (cmdline_parse_inst_t *)&cmd_vlan_tpid, 17745 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all, 17746 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter, 17747 (cmdline_parse_inst_t *)&cmd_tx_vlan_set, 17748 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq, 17749 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, 17750 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, 17751 (cmdline_parse_inst_t *)&cmd_csum_set, 17752 (cmdline_parse_inst_t *)&cmd_csum_show, 17753 (cmdline_parse_inst_t *)&cmd_csum_tunnel, 17754 (cmdline_parse_inst_t *)&cmd_tso_set, 17755 (cmdline_parse_inst_t *)&cmd_tso_show, 17756 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, 17757 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, 17758 (cmdline_parse_inst_t *)&cmd_gro_enable, 17759 (cmdline_parse_inst_t *)&cmd_gro_flush, 17760 (cmdline_parse_inst_t *)&cmd_gro_show, 17761 (cmdline_parse_inst_t *)&cmd_gso_enable, 17762 (cmdline_parse_inst_t *)&cmd_gso_size, 17763 (cmdline_parse_inst_t *)&cmd_gso_show, 17764 (cmdline_parse_inst_t *)&cmd_link_flow_control_set, 17765 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, 17766 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx, 17767 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw, 17768 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw, 17769 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt, 17770 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, 17771 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, 17772 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, 17773 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, 17774 (cmdline_parse_inst_t *)&cmd_config_dcb, 17775 (cmdline_parse_inst_t *)&cmd_read_reg, 17776 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field, 17777 (cmdline_parse_inst_t *)&cmd_read_reg_bit, 17778 (cmdline_parse_inst_t *)&cmd_write_reg, 17779 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field, 17780 (cmdline_parse_inst_t *)&cmd_write_reg_bit, 17781 (cmdline_parse_inst_t *)&cmd_read_rxd_txd, 17782 (cmdline_parse_inst_t *)&cmd_stop, 17783 (cmdline_parse_inst_t *)&cmd_mac_addr, 17784 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, 17785 (cmdline_parse_inst_t *)&cmd_set_qmap, 17786 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, 17787 (cmdline_parse_inst_t *)&cmd_operate_port, 17788 (cmdline_parse_inst_t *)&cmd_operate_specific_port, 17789 (cmdline_parse_inst_t *)&cmd_operate_attach_port, 17790 (cmdline_parse_inst_t *)&cmd_operate_detach_port, 17791 (cmdline_parse_inst_t *)&cmd_config_speed_all, 17792 (cmdline_parse_inst_t *)&cmd_config_speed_specific, 17793 (cmdline_parse_inst_t *)&cmd_config_loopback_all, 17794 (cmdline_parse_inst_t *)&cmd_config_loopback_specific, 17795 (cmdline_parse_inst_t *)&cmd_config_rx_tx, 17796 (cmdline_parse_inst_t *)&cmd_config_mtu, 17797 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, 17798 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, 17799 (cmdline_parse_inst_t *)&cmd_config_rss, 17800 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size, 17801 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, 17802 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue, 17803 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue, 17804 (cmdline_parse_inst_t *)&cmd_config_rss_reta, 17805 (cmdline_parse_inst_t *)&cmd_showport_reta, 17806 (cmdline_parse_inst_t *)&cmd_config_burst, 17807 (cmdline_parse_inst_t *)&cmd_config_thresh, 17808 (cmdline_parse_inst_t *)&cmd_config_threshold, 17809 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter, 17810 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, 17811 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, 17812 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter, 17813 (cmdline_parse_inst_t *)&cmd_queue_rate_limit, 17814 (cmdline_parse_inst_t *)&cmd_tunnel_filter, 17815 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, 17816 (cmdline_parse_inst_t *)&cmd_global_config, 17817 (cmdline_parse_inst_t *)&cmd_set_mirror_mask, 17818 (cmdline_parse_inst_t *)&cmd_set_mirror_link, 17819 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule, 17820 (cmdline_parse_inst_t *)&cmd_showport_rss_hash, 17821 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, 17822 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, 17823 (cmdline_parse_inst_t *)&cmd_dump, 17824 (cmdline_parse_inst_t *)&cmd_dump_one, 17825 (cmdline_parse_inst_t *)&cmd_ethertype_filter, 17826 (cmdline_parse_inst_t *)&cmd_syn_filter, 17827 (cmdline_parse_inst_t *)&cmd_2tuple_filter, 17828 (cmdline_parse_inst_t *)&cmd_5tuple_filter, 17829 (cmdline_parse_inst_t *)&cmd_flex_filter, 17830 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director, 17831 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director, 17832 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director, 17833 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director, 17834 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director, 17835 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director, 17836 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director, 17837 (cmdline_parse_inst_t *)&cmd_flush_flow_director, 17838 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask, 17839 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask, 17840 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask, 17841 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask, 17842 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload, 17843 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port, 17844 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port, 17845 (cmdline_parse_inst_t *)&cmd_get_hash_global_config, 17846 (cmdline_parse_inst_t *)&cmd_set_hash_global_config, 17847 (cmdline_parse_inst_t *)&cmd_set_hash_input_set, 17848 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set, 17849 (cmdline_parse_inst_t *)&cmd_flow, 17850 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap, 17851 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, 17852 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, 17853 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, 17854 (cmdline_parse_inst_t *)&cmd_create_port_meter, 17855 (cmdline_parse_inst_t *)&cmd_enable_port_meter, 17856 (cmdline_parse_inst_t *)&cmd_disable_port_meter, 17857 (cmdline_parse_inst_t *)&cmd_del_port_meter, 17858 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, 17859 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, 17860 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, 17861 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, 17862 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, 17863 (cmdline_parse_inst_t *)&cmd_mcast_addr, 17864 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all, 17865 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific, 17866 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all, 17867 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific, 17868 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en, 17869 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis, 17870 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis, 17871 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis, 17872 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add, 17873 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del, 17874 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, 17875 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, 17876 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, 17877 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, 17878 (cmdline_parse_inst_t *)&cmd_set_tx_loopback, 17879 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, 17880 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, 17881 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on, 17882 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off, 17883 (cmdline_parse_inst_t *)&cmd_set_macsec_sc, 17884 (cmdline_parse_inst_t *)&cmd_set_macsec_sa, 17885 (cmdline_parse_inst_t *)&cmd_set_vf_traffic, 17886 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, 17887 (cmdline_parse_inst_t *)&cmd_vf_rate_limit, 17888 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, 17889 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, 17890 (cmdline_parse_inst_t *)&cmd_set_vf_promisc, 17891 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti, 17892 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast, 17893 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag, 17894 (cmdline_parse_inst_t *)&cmd_vf_max_bw, 17895 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw, 17896 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw, 17897 (cmdline_parse_inst_t *)&cmd_strict_link_prio, 17898 (cmdline_parse_inst_t *)&cmd_tc_min_bw, 17899 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 17900 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default, 17901 #endif 17902 (cmdline_parse_inst_t *)&cmd_set_vxlan, 17903 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan, 17904 (cmdline_parse_inst_t *)&cmd_set_nvgre, 17905 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan, 17906 (cmdline_parse_inst_t *)&cmd_ddp_add, 17907 (cmdline_parse_inst_t *)&cmd_ddp_del, 17908 (cmdline_parse_inst_t *)&cmd_ddp_get_list, 17909 (cmdline_parse_inst_t *)&cmd_ddp_get_info, 17910 (cmdline_parse_inst_t *)&cmd_cfg_input_set, 17911 (cmdline_parse_inst_t *)&cmd_clear_input_set, 17912 (cmdline_parse_inst_t *)&cmd_show_vf_stats, 17913 (cmdline_parse_inst_t *)&cmd_clear_vf_stats, 17914 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, 17915 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, 17916 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, 17917 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update, 17918 17919 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get, 17920 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset, 17921 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update, 17922 (cmdline_parse_inst_t *)&cmd_queue_region, 17923 (cmdline_parse_inst_t *)&cmd_region_flowtype, 17924 (cmdline_parse_inst_t *)&cmd_user_priority_region, 17925 (cmdline_parse_inst_t *)&cmd_flush_queue_region, 17926 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all, 17927 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap, 17928 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap, 17929 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap, 17930 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type, 17931 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats, 17932 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile, 17933 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile, 17934 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper, 17935 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper, 17936 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile, 17937 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile, 17938 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile, 17939 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node, 17940 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node, 17941 (cmdline_parse_inst_t *)&cmd_del_port_tm_node, 17942 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent, 17943 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node, 17944 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node, 17945 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, 17946 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port, 17947 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa, 17948 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration, 17949 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload, 17950 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload, 17951 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa, 17952 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration, 17953 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload, 17954 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload, 17955 #ifdef RTE_LIBRTE_BPF 17956 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse, 17957 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse, 17958 #endif 17959 NULL, 17960 }; 17961 17962 /* read cmdline commands from file */ 17963 void 17964 cmdline_read_from_file(const char *filename) 17965 { 17966 struct cmdline *cl; 17967 17968 cl = cmdline_file_new(main_ctx, "testpmd> ", filename); 17969 if (cl == NULL) { 17970 printf("Failed to create file based cmdline context: %s\n", 17971 filename); 17972 return; 17973 } 17974 17975 cmdline_interact(cl); 17976 cmdline_quit(cl); 17977 17978 cmdline_free(cl); 17979 17980 printf("Read CLI commands from %s\n", filename); 17981 } 17982 17983 /* prompt function, called from main on MASTER lcore */ 17984 void 17985 prompt(void) 17986 { 17987 /* initialize non-constant commands */ 17988 cmd_set_fwd_mode_init(); 17989 cmd_set_fwd_retry_mode_init(); 17990 17991 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); 17992 if (testpmd_cl == NULL) 17993 return; 17994 cmdline_interact(testpmd_cl); 17995 cmdline_stdin_exit(testpmd_cl); 17996 } 17997 17998 void 17999 prompt_exit(void) 18000 { 18001 if (testpmd_cl != NULL) 18002 cmdline_quit(testpmd_cl); 18003 } 18004 18005 static void 18006 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) 18007 { 18008 if (id == (portid_t)RTE_PORT_ALL) { 18009 portid_t pid; 18010 18011 RTE_ETH_FOREACH_DEV(pid) { 18012 /* check if need_reconfig has been set to 1 */ 18013 if (ports[pid].need_reconfig == 0) 18014 ports[pid].need_reconfig = dev; 18015 /* check if need_reconfig_queues has been set to 1 */ 18016 if (ports[pid].need_reconfig_queues == 0) 18017 ports[pid].need_reconfig_queues = queue; 18018 } 18019 } else if (!port_id_is_invalid(id, DISABLED_WARN)) { 18020 /* check if need_reconfig has been set to 1 */ 18021 if (ports[id].need_reconfig == 0) 18022 ports[id].need_reconfig = dev; 18023 /* check if need_reconfig_queues has been set to 1 */ 18024 if (ports[id].need_reconfig_queues == 0) 18025 ports[id].need_reconfig_queues = queue; 18026 } 18027 } 18028