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|summary|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 (port_id) rss-hash [key]\n" 179 " Display the RSS hash functions and RSS hash key of port\n\n" 180 181 "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n" 182 " Clear information for port_id, or all.\n\n" 183 184 "show (rxq|txq) info (port_id) (queue_id)\n" 185 " Display information for configured RX/TX queue.\n\n" 186 187 "show config (rxtx|cores|fwd|txpkts)\n" 188 " Display the given configuration.\n\n" 189 190 "read rxd (port_id) (queue_id) (rxd_id)\n" 191 " Display an RX descriptor of a port RX queue.\n\n" 192 193 "read txd (port_id) (queue_id) (txd_id)\n" 194 " Display a TX descriptor of a port TX queue.\n\n" 195 196 "ddp get list (port_id)\n" 197 " Get ddp profile info list\n\n" 198 199 "ddp get info (profile_path)\n" 200 " Get ddp profile information.\n\n" 201 202 "show vf stats (port_id) (vf_id)\n" 203 " Display a VF's statistics.\n\n" 204 205 "clear vf stats (port_id) (vf_id)\n" 206 " Reset a VF's statistics.\n\n" 207 208 "show port (port_id) pctype mapping\n" 209 " Get flow ptype to pctype mapping on a port\n\n" 210 211 "show port meter stats (port_id) (meter_id) (clear)\n" 212 " Get meter stats on a port\n\n" 213 "show port tm cap (port_id)\n" 214 " Display the port TM capability.\n\n" 215 216 "show port tm level cap (port_id) (level_id)\n" 217 " Display the port TM hierarchical level capability.\n\n" 218 219 "show port tm node cap (port_id) (node_id)\n" 220 " Display the port TM node capability.\n\n" 221 222 "show port tm node type (port_id) (node_id)\n" 223 " Display the port TM node type.\n\n" 224 225 "show port tm node stats (port_id) (node_id) (clear)\n" 226 " Display the port TM node stats.\n\n" 227 228 "show fwd stats all\n" 229 " Display statistics for all fwd engines.\n\n" 230 231 "clear fwd stats all\n" 232 " Clear statistics for all fwd engines.\n\n" 233 ); 234 } 235 236 if (show_all || !strcmp(res->section, "config")) { 237 cmdline_printf( 238 cl, 239 "\n" 240 "Configuration:\n" 241 "--------------\n" 242 "Configuration changes only become active when" 243 " forwarding is started/restarted.\n\n" 244 245 "set default\n" 246 " Reset forwarding to the default configuration.\n\n" 247 248 "set verbose (level)\n" 249 " Set the debug verbosity level X.\n\n" 250 251 "set log global|(type) (level)\n" 252 " Set the log level.\n\n" 253 254 "set nbport (num)\n" 255 " Set number of ports.\n\n" 256 257 "set nbcore (num)\n" 258 " Set number of cores.\n\n" 259 260 "set coremask (mask)\n" 261 " Set the forwarding cores hexadecimal mask.\n\n" 262 263 "set portmask (mask)\n" 264 " Set the forwarding ports hexadecimal mask.\n\n" 265 266 "set burst (num)\n" 267 " Set number of packets per burst.\n\n" 268 269 "set burst tx delay (microseconds) retry (num)\n" 270 " Set the transmit delay time and number of retries," 271 " effective when retry is enabled.\n\n" 272 273 "set txpkts (x[,y]*)\n" 274 " Set the length of each segment of TXONLY" 275 " and optionally CSUM packets.\n\n" 276 277 "set txsplit (off|on|rand)\n" 278 " Set the split policy for the TX packets." 279 " Right now only applicable for CSUM and TXONLY" 280 " modes\n\n" 281 282 "set corelist (x[,y]*)\n" 283 " Set the list of forwarding cores.\n\n" 284 285 "set portlist (x[,y]*)\n" 286 " Set the list of forwarding ports.\n\n" 287 288 "set port setup on (iterator|event)\n" 289 " Select how attached port is retrieved for setup.\n\n" 290 291 "set tx loopback (port_id) (on|off)\n" 292 " Enable or disable tx loopback.\n\n" 293 294 "set all queues drop (port_id) (on|off)\n" 295 " Set drop enable bit for all queues.\n\n" 296 297 "set vf split drop (port_id) (vf_id) (on|off)\n" 298 " Set split drop enable bit for a VF from the PF.\n\n" 299 300 "set vf mac antispoof (port_id) (vf_id) (on|off).\n" 301 " Set MAC antispoof for a VF from the PF.\n\n" 302 303 "set macsec offload (port_id) on encrypt (on|off) replay-protect (on|off)\n" 304 " Enable MACsec offload.\n\n" 305 306 "set macsec offload (port_id) off\n" 307 " Disable MACsec offload.\n\n" 308 309 "set macsec sc (tx|rx) (port_id) (mac) (pi)\n" 310 " Configure MACsec secure connection (SC).\n\n" 311 312 "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) (key)\n" 313 " Configure MACsec secure association (SA).\n\n" 314 315 "set vf broadcast (port_id) (vf_id) (on|off)\n" 316 " Set VF broadcast for a VF from the PF.\n\n" 317 318 "vlan set strip (on|off) (port_id)\n" 319 " Set the VLAN strip on a port.\n\n" 320 321 "vlan set stripq (on|off) (port_id,queue_id)\n" 322 " Set the VLAN strip for a queue on a port.\n\n" 323 324 "set vf vlan stripq (port_id) (vf_id) (on|off)\n" 325 " Set the VLAN strip for all queues in a pool for a VF from the PF.\n\n" 326 327 "set vf vlan insert (port_id) (vf_id) (vlan_id)\n" 328 " Set VLAN insert for a VF from the PF.\n\n" 329 330 "set vf vlan antispoof (port_id) (vf_id) (on|off)\n" 331 " Set VLAN antispoof for a VF from the PF.\n\n" 332 333 "set vf vlan tag (port_id) (vf_id) (on|off)\n" 334 " Set VLAN tag for a VF from the PF.\n\n" 335 336 "set vf tx max-bandwidth (port_id) (vf_id) (bandwidth)\n" 337 " Set a VF's max bandwidth(Mbps).\n\n" 338 339 "set vf tc tx min-bandwidth (port_id) (vf_id) (bw1, bw2, ...)\n" 340 " Set all TCs' min bandwidth(%%) on a VF.\n\n" 341 342 "set vf tc tx max-bandwidth (port_id) (vf_id) (tc_no) (bandwidth)\n" 343 " Set a TC's max bandwidth(Mbps) on a VF.\n\n" 344 345 "set tx strict-link-priority (port_id) (tc_bitmap)\n" 346 " Set some TCs' strict link priority mode on a physical port.\n\n" 347 348 "set tc tx min-bandwidth (port_id) (bw1, bw2, ...)\n" 349 " Set all TCs' min bandwidth(%%) for all PF and VFs.\n\n" 350 351 "vlan set filter (on|off) (port_id)\n" 352 " Set the VLAN filter on a port.\n\n" 353 354 "vlan set qinq (on|off) (port_id)\n" 355 " Set the VLAN QinQ (extended queue in queue)" 356 " on a port.\n\n" 357 358 "vlan set (inner|outer) tpid (value) (port_id)\n" 359 " Set the VLAN TPID for Packet Filtering on" 360 " a port\n\n" 361 362 "rx_vlan add (vlan_id|all) (port_id)\n" 363 " Add a vlan_id, or all identifiers, to the set" 364 " of VLAN identifiers filtered by port_id.\n\n" 365 366 "rx_vlan rm (vlan_id|all) (port_id)\n" 367 " Remove a vlan_id, or all identifiers, from the set" 368 " of VLAN identifiers filtered by port_id.\n\n" 369 370 "rx_vlan add (vlan_id) port (port_id) vf (vf_mask)\n" 371 " Add a vlan_id, to the set of VLAN identifiers" 372 "filtered for VF(s) from port_id.\n\n" 373 374 "rx_vlan rm (vlan_id) port (port_id) vf (vf_mask)\n" 375 " Remove a vlan_id, to the set of VLAN identifiers" 376 "filtered for VF(s) from port_id.\n\n" 377 378 "tunnel_filter add (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 " add a tunnel filter of a port.\n\n" 382 383 "tunnel_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) " 384 "(inner_vlan) (vxlan|nvgre|ipingre) (imac-ivlan|imac-ivlan-tenid|" 385 "imac-tenid|imac|omac-imac-tenid|oip|iip) (tenant_id) (queue_id)\n" 386 " remove a tunnel filter of a port.\n\n" 387 388 "rx_vxlan_port add (udp_port) (port_id)\n" 389 " Add an UDP port for VXLAN packet filter on a port\n\n" 390 391 "rx_vxlan_port rm (udp_port) (port_id)\n" 392 " Remove an UDP port for VXLAN packet filter on a port\n\n" 393 394 "tx_vlan set (port_id) vlan_id[, vlan_id_outer]\n" 395 " Set hardware insertion of VLAN IDs (single or double VLAN " 396 "depends on the number of VLAN IDs) in packets sent on a port.\n\n" 397 398 "tx_vlan set pvid port_id vlan_id (on|off)\n" 399 " Set port based TX VLAN insertion.\n\n" 400 401 "tx_vlan reset (port_id)\n" 402 " Disable hardware insertion of a VLAN header in" 403 " packets sent on a port.\n\n" 404 405 "csum set (ip|udp|tcp|sctp|outer-ip|outer-udp) (hw|sw) (port_id)\n" 406 " Select hardware or software calculation of the" 407 " checksum when transmitting a packet using the" 408 " csum forward engine.\n" 409 " ip|udp|tcp|sctp always concern the inner layer.\n" 410 " outer-ip concerns the outer IP layer in" 411 " outer-udp concerns the outer UDP layer in" 412 " case the packet is recognized as a tunnel packet by" 413 " the forward engine (vxlan, gre and ipip are supported)\n" 414 " Please check the NIC datasheet for HW limits.\n\n" 415 416 "csum parse-tunnel (on|off) (tx_port_id)\n" 417 " If disabled, treat tunnel packets as non-tunneled" 418 " packets (treat inner headers as payload). The port\n" 419 " argument is the port used for TX in csum forward" 420 " engine.\n\n" 421 422 "csum show (port_id)\n" 423 " Display tx checksum offload configuration\n\n" 424 425 "tso set (segsize) (portid)\n" 426 " Enable TCP Segmentation Offload in csum forward" 427 " engine.\n" 428 " Please check the NIC datasheet for HW limits.\n\n" 429 430 "tso show (portid)" 431 " Display the status of TCP Segmentation Offload.\n\n" 432 433 "set port (port_id) gro on|off\n" 434 " Enable or disable Generic Receive Offload in" 435 " csum forwarding engine.\n\n" 436 437 "show port (port_id) gro\n" 438 " Display GRO configuration.\n\n" 439 440 "set gro flush (cycles)\n" 441 " Set the cycle to flush GROed packets from" 442 " reassembly tables.\n\n" 443 444 "set port (port_id) gso (on|off)" 445 " Enable or disable Generic Segmentation Offload in" 446 " csum forwarding engine.\n\n" 447 448 "set gso segsz (length)\n" 449 " Set max packet length for output GSO segments," 450 " including packet header and payload.\n\n" 451 452 "show port (port_id) gso\n" 453 " Show GSO configuration.\n\n" 454 455 "set fwd (%s)\n" 456 " Set packet forwarding mode.\n\n" 457 458 "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n" 459 " Add a MAC address on port_id.\n\n" 460 461 "mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)\n" 462 " Remove a MAC address from port_id.\n\n" 463 464 "mac_addr set (port_id) (XX:XX:XX:XX:XX:XX)\n" 465 " Set the default MAC address for port_id.\n\n" 466 467 "mac_addr add port (port_id) vf (vf_id) (mac_address)\n" 468 " Add a MAC address for a VF on the port.\n\n" 469 470 "set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)\n" 471 " Set the MAC address for a VF from the PF.\n\n" 472 473 "set eth-peer (port_id) (peer_addr)\n" 474 " set the peer address for certain port.\n\n" 475 476 "set port (port_id) uta (mac_address|all) (on|off)\n" 477 " Add/Remove a or all unicast hash filter(s)" 478 "from port X.\n\n" 479 480 "set promisc (port_id|all) (on|off)\n" 481 " Set the promiscuous mode on port_id, or all.\n\n" 482 483 "set allmulti (port_id|all) (on|off)\n" 484 " Set the allmulti mode on port_id, or all.\n\n" 485 486 "set vf promisc (port_id) (vf_id) (on|off)\n" 487 " Set unicast promiscuous mode for a VF from the PF.\n\n" 488 489 "set vf allmulti (port_id) (vf_id) (on|off)\n" 490 " Set multicast promiscuous mode for a VF from the PF.\n\n" 491 492 "set flow_ctrl rx (on|off) tx (on|off) (high_water)" 493 " (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd" 494 " (on|off) autoneg (on|off) (port_id)\n" 495 "set flow_ctrl rx (on|off) (portid)\n" 496 "set flow_ctrl tx (on|off) (portid)\n" 497 "set flow_ctrl high_water (high_water) (portid)\n" 498 "set flow_ctrl low_water (low_water) (portid)\n" 499 "set flow_ctrl pause_time (pause_time) (portid)\n" 500 "set flow_ctrl send_xon (send_xon) (portid)\n" 501 "set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n" 502 "set flow_ctrl autoneg (on|off) (port_id)\n" 503 " Set the link flow control parameter on a port.\n\n" 504 505 "set pfc_ctrl rx (on|off) tx (on|off) (high_water)" 506 " (low_water) (pause_time) (priority) (port_id)\n" 507 " Set the priority flow control parameter on a" 508 " port.\n\n" 509 510 "set stat_qmap (tx|rx) (port_id) (queue_id) (qmapping)\n" 511 " Set statistics mapping (qmapping 0..15) for RX/TX" 512 " queue on port.\n" 513 " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2" 514 " on port 0 to mapping 5.\n\n" 515 516 "set xstats-hide-zero on|off\n" 517 " Set the option to hide the zero values" 518 " for xstats display.\n" 519 520 "set port (port_id) vf (vf_id) rx|tx on|off\n" 521 " Enable/Disable a VF receive/tranmit from a port\n\n" 522 523 "set port (port_id) vf (vf_id) (mac_addr)" 524 " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n" 525 " Add/Remove unicast or multicast MAC addr filter" 526 " for a VF.\n\n" 527 528 "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM" 529 "|MPE) (on|off)\n" 530 " AUPE:accepts untagged VLAN;" 531 "ROPE:accept unicast hash\n\n" 532 " BAM:accepts broadcast packets;" 533 "MPE:accepts all multicast packets\n\n" 534 " Enable/Disable a VF receive mode of a port\n\n" 535 536 "set port (port_id) queue (queue_id) rate (rate_num)\n" 537 " Set rate limit for a queue of a port\n\n" 538 539 "set port (port_id) vf (vf_id) rate (rate_num) " 540 "queue_mask (queue_mask_value)\n" 541 " Set rate limit for queues in VF of a port\n\n" 542 543 "set port (port_id) mirror-rule (rule_id)" 544 " (pool-mirror-up|pool-mirror-down|vlan-mirror)" 545 " (poolmask|vlanid[,vlanid]*) dst-pool (pool_id) (on|off)\n" 546 " Set pool or vlan type mirror rule on a port.\n" 547 " e.g., 'set port 0 mirror-rule 0 vlan-mirror 0,1" 548 " dst-pool 0 on' enable mirror traffic with vlan 0,1" 549 " to pool 0.\n\n" 550 551 "set port (port_id) mirror-rule (rule_id)" 552 " (uplink-mirror|downlink-mirror) dst-pool" 553 " (pool_id) (on|off)\n" 554 " Set uplink or downlink type mirror rule on a port.\n" 555 " e.g., 'set port 0 mirror-rule 0 uplink-mirror dst-pool" 556 " 0 on' enable mirror income traffic to pool 0.\n\n" 557 558 "reset port (port_id) mirror-rule (rule_id)\n" 559 " Reset a mirror rule.\n\n" 560 561 "set flush_rx (on|off)\n" 562 " Flush (default) or don't flush RX streams before" 563 " forwarding. Mainly used with PCAP drivers.\n\n" 564 565 "set bypass mode (normal|bypass|isolate) (port_id)\n" 566 " Set the bypass mode for the lowest port on bypass enabled" 567 " NIC.\n\n" 568 569 "set bypass event (timeout|os_on|os_off|power_on|power_off) " 570 "mode (normal|bypass|isolate) (port_id)\n" 571 " Set the event required to initiate specified bypass mode for" 572 " the lowest port on a bypass enabled NIC where:\n" 573 " timeout = enable bypass after watchdog timeout.\n" 574 " os_on = enable bypass when OS/board is powered on.\n" 575 " os_off = enable bypass when OS/board is powered off.\n" 576 " power_on = enable bypass when power supply is turned on.\n" 577 " power_off = enable bypass when power supply is turned off." 578 "\n\n" 579 580 "set bypass timeout (0|1.5|2|3|4|8|16|32)\n" 581 " Set the bypass watchdog timeout to 'n' seconds" 582 " where 0 = instant.\n\n" 583 584 "show bypass config (port_id)\n" 585 " Show the bypass configuration for a bypass enabled NIC" 586 " using the lowest port on the NIC.\n\n" 587 588 #ifdef RTE_LIBRTE_PMD_BOND 589 "create bonded device (mode) (socket)\n" 590 " Create a new bonded device with specific bonding mode and socket.\n\n" 591 592 "add bonding slave (slave_id) (port_id)\n" 593 " Add a slave device to a bonded device.\n\n" 594 595 "remove bonding slave (slave_id) (port_id)\n" 596 " Remove a slave device from a bonded device.\n\n" 597 598 "set bonding mode (value) (port_id)\n" 599 " Set the bonding mode on a bonded device.\n\n" 600 601 "set bonding primary (slave_id) (port_id)\n" 602 " Set the primary slave for a bonded device.\n\n" 603 604 "show bonding config (port_id)\n" 605 " Show the bonding config for port_id.\n\n" 606 607 "set bonding mac_addr (port_id) (address)\n" 608 " Set the MAC address of a bonded device.\n\n" 609 610 "set bonding mode IEEE802.3AD aggregator policy (port_id) (agg_name)" 611 " Set Aggregation mode for IEEE802.3AD (mode 4)" 612 613 "set bonding xmit_balance_policy (port_id) (l2|l23|l34)\n" 614 " Set the transmit balance policy for bonded device running in balance mode.\n\n" 615 616 "set bonding mon_period (port_id) (value)\n" 617 " Set the bonding link status monitoring polling period in ms.\n\n" 618 619 "set bonding lacp dedicated_queues <port_id> (enable|disable)\n" 620 " Enable/disable dedicated queues for LACP control traffic.\n\n" 621 622 #endif 623 "set link-up port (port_id)\n" 624 " Set link up for a port.\n\n" 625 626 "set link-down port (port_id)\n" 627 " Set link down for a port.\n\n" 628 629 "E-tag set insertion on port-tag-id (value)" 630 " port (port_id) vf (vf_id)\n" 631 " Enable E-tag insertion for a VF on a port\n\n" 632 633 "E-tag set insertion off port (port_id) vf (vf_id)\n" 634 " Disable E-tag insertion for a VF on a port\n\n" 635 636 "E-tag set stripping (on|off) port (port_id)\n" 637 " Enable/disable E-tag stripping on a port\n\n" 638 639 "E-tag set forwarding (on|off) port (port_id)\n" 640 " Enable/disable E-tag based forwarding" 641 " on a port\n\n" 642 643 "E-tag set filter add e-tag-id (value) dst-pool" 644 " (pool_id) port (port_id)\n" 645 " Add an E-tag forwarding filter on a port\n\n" 646 647 "E-tag set filter del e-tag-id (value) port (port_id)\n" 648 " Delete an E-tag forwarding filter on a port\n\n" 649 650 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 651 "set port tm hierarchy default (port_id)\n" 652 " Set default traffic Management hierarchy on a port\n\n" 653 654 #endif 655 "ddp add (port_id) (profile_path[,backup_profile_path])\n" 656 " Load a profile package on a port\n\n" 657 658 "ddp del (port_id) (backup_profile_path)\n" 659 " Delete a profile package from a port\n\n" 660 661 "ptype mapping get (port_id) (valid_only)\n" 662 " Get ptype mapping on a port\n\n" 663 664 "ptype mapping replace (port_id) (target) (mask) (pky_type)\n" 665 " Replace target with the pkt_type in ptype mapping\n\n" 666 667 "ptype mapping reset (port_id)\n" 668 " Reset ptype mapping on a port\n\n" 669 670 "ptype mapping update (port_id) (hw_ptype) (sw_ptype)\n" 671 " Update a ptype mapping item on a port\n\n" 672 673 "set port (port_id) queue-region region_id (value) " 674 "queue_start_index (value) queue_num (value)\n" 675 " Set a queue region on a port\n\n" 676 677 "set port (port_id) queue-region region_id (value) " 678 "flowtype (value)\n" 679 " Set a flowtype region index on a port\n\n" 680 681 "set port (port_id) queue-region UP (value) region_id (value)\n" 682 " Set the mapping of User Priority to " 683 "queue region on a port\n\n" 684 685 "set port (port_id) queue-region flush (on|off)\n" 686 " flush all queue region related configuration\n\n" 687 688 "show port meter cap (port_id)\n" 689 " Show port meter capability information\n\n" 690 691 "add port meter profile srtcm_rfc2697 (port_id) (profile_id) (cir) (cbs) (ebs)\n" 692 " meter profile add - srtcm rfc 2697\n\n" 693 694 "add port meter profile trtcm_rfc2698 (port_id) (profile_id) (cir) (pir) (cbs) (pbs)\n" 695 " meter profile add - trtcm rfc 2698\n\n" 696 697 "add port meter profile trtcm_rfc4115 (port_id) (profile_id) (cir) (eir) (cbs) (ebs)\n" 698 " meter profile add - trtcm rfc 4115\n\n" 699 700 "del port meter profile (port_id) (profile_id)\n" 701 " meter profile delete\n\n" 702 703 "create port meter (port_id) (mtr_id) (profile_id) (meter_enable)\n" 704 "(g_action) (y_action) (r_action) (stats_mask) (shared)\n" 705 "(use_pre_meter_color) [(dscp_tbl_entry0) (dscp_tbl_entry1)...\n" 706 "(dscp_tbl_entry63)]\n" 707 " meter create\n\n" 708 709 "enable port meter (port_id) (mtr_id)\n" 710 " meter enable\n\n" 711 712 "disable port meter (port_id) (mtr_id)\n" 713 " meter disable\n\n" 714 715 "del port meter (port_id) (mtr_id)\n" 716 " meter delete\n\n" 717 718 "set port meter profile (port_id) (mtr_id) (profile_id)\n" 719 " meter update meter profile\n\n" 720 721 "set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0)\n" 722 "(dscp_tbl_entry1)...(dscp_tbl_entry63)]\n" 723 " update meter dscp table entries\n\n" 724 725 "set port meter policer action (port_id) (mtr_id) (action_mask)\n" 726 "(action0) [(action1) (action2)]\n" 727 " meter update policer action\n\n" 728 729 "set port meter stats mask (port_id) (mtr_id) (stats_mask)\n" 730 " meter update stats\n\n" 731 732 "show port (port_id) queue-region\n" 733 " show all queue region related configuration info\n\n" 734 735 "add port tm node shaper profile (port_id) (shaper_profile_id)" 736 " (cmit_tb_rate) (cmit_tb_size) (peak_tb_rate) (peak_tb_size)" 737 " (packet_length_adjust)\n" 738 " Add port tm node private shaper profile.\n\n" 739 740 "del port tm node shaper profile (port_id) (shaper_profile_id)\n" 741 " Delete port tm node private shaper profile.\n\n" 742 743 "add port tm node shared shaper (port_id) (shared_shaper_id)" 744 " (shaper_profile_id)\n" 745 " Add/update port tm node shared shaper.\n\n" 746 747 "del port tm node shared shaper (port_id) (shared_shaper_id)\n" 748 " Delete port tm node shared shaper.\n\n" 749 750 "set port tm node shaper profile (port_id) (node_id)" 751 " (shaper_profile_id)\n" 752 " Set port tm node shaper profile.\n\n" 753 754 "add port tm node wred profile (port_id) (wred_profile_id)" 755 " (color_g) (min_th_g) (max_th_g) (maxp_inv_g) (wq_log2_g)" 756 " (color_y) (min_th_y) (max_th_y) (maxp_inv_y) (wq_log2_y)" 757 " (color_r) (min_th_r) (max_th_r) (maxp_inv_r) (wq_log2_r)\n" 758 " Add port tm node wred profile.\n\n" 759 760 "del port tm node wred profile (port_id) (wred_profile_id)\n" 761 " Delete port tm node wred profile.\n\n" 762 763 "add port tm nonleaf node (port_id) (node_id) (parent_node_id)" 764 " (priority) (weight) (level_id) (shaper_profile_id)" 765 " (n_sp_priorities) (stats_mask) (n_shared_shapers)" 766 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 767 " Add port tm nonleaf node.\n\n" 768 769 "add port tm leaf node (port_id) (node_id) (parent_node_id)" 770 " (priority) (weight) (level_id) (shaper_profile_id)" 771 " (cman_mode) (wred_profile_id) (stats_mask) (n_shared_shapers)" 772 " [(shared_shaper_id_0) (shared_shaper_id_1)...]\n" 773 " Add port tm leaf node.\n\n" 774 775 "del port tm node (port_id) (node_id)\n" 776 " Delete port tm node.\n\n" 777 778 "set port tm node parent (port_id) (node_id) (parent_node_id)" 779 " (priority) (weight)\n" 780 " Set port tm node parent.\n\n" 781 782 "suspend port tm node (port_id) (node_id)" 783 " Suspend tm node.\n\n" 784 785 "resume port tm node (port_id) (node_id)" 786 " Resume tm node.\n\n" 787 788 "port tm hierarchy commit (port_id) (clean_on_fail)\n" 789 " Commit tm hierarchy.\n\n" 790 791 "vxlan ip-version (ipv4|ipv6) vni (vni) udp-src" 792 " (udp-src) udp-dst (udp-dst) ip-src (ip-src) ip-dst" 793 " (ip-dst) eth-src (eth-src) eth-dst (eth-dst)\n" 794 " Configure the VXLAN encapsulation for flows.\n\n" 795 796 "vxlan-with-vlan ip-version (ipv4|ipv6) vni (vni)" 797 " udp-src (udp-src) udp-dst (udp-dst) ip-src (ip-src)" 798 " ip-dst (ip-dst) vlan-tci (vlan-tci) eth-src (eth-src)" 799 " eth-dst (eth-dst)\n" 800 " Configure the VXLAN encapsulation for flows.\n\n" 801 802 "vxlan-tos-ttl ip-version (ipv4|ipv6) vni (vni) udp-src" 803 " (udp-src) udp-dst (udp-dst) ip-tos (ip-tos) ip-ttl (ip-ttl)" 804 " ip-src (ip-src) ip-dst (ip-dst) eth-src (eth-src)" 805 " eth-dst (eth-dst)\n" 806 " Configure the VXLAN encapsulation for flows.\n\n" 807 808 "nvgre ip-version (ipv4|ipv6) tni (tni) ip-src" 809 " (ip-src) ip-dst (ip-dst) eth-src (eth-src) eth-dst" 810 " (eth-dst)\n" 811 " Configure the NVGRE encapsulation for flows.\n\n" 812 813 "nvgre-with-vlan ip-version (ipv4|ipv6) tni (tni)" 814 " ip-src (ip-src) ip-dst (ip-dst) vlan-tci (vlan-tci)" 815 " eth-src (eth-src) eth-dst (eth-dst)\n" 816 " Configure the NVGRE encapsulation for flows.\n\n" 817 818 , list_pkt_forwarding_modes() 819 ); 820 } 821 822 if (show_all || !strcmp(res->section, "ports")) { 823 824 cmdline_printf( 825 cl, 826 "\n" 827 "Port Operations:\n" 828 "----------------\n\n" 829 830 "port start (port_id|all)\n" 831 " Start all ports or port_id.\n\n" 832 833 "port stop (port_id|all)\n" 834 " Stop all ports or port_id.\n\n" 835 836 "port close (port_id|all)\n" 837 " Close all ports or port_id.\n\n" 838 839 "port attach (ident)\n" 840 " Attach physical or virtual dev by pci address or virtual device name\n\n" 841 842 "port detach (port_id)\n" 843 " Detach physical or virtual dev by port_id\n\n" 844 845 "port config (port_id|all)" 846 " speed (10|100|1000|10000|25000|40000|50000|100000|auto)" 847 " duplex (half|full|auto)\n" 848 " Set speed and duplex for all ports or port_id\n\n" 849 850 "port config (port_id|all) loopback (mode)\n" 851 " Set loopback mode for all ports or port_id\n\n" 852 853 "port config all (rxq|txq|rxd|txd) (value)\n" 854 " Set number for rxq/txq/rxd/txd.\n\n" 855 856 "port config all max-pkt-len (value)\n" 857 " Set the max packet length.\n\n" 858 859 "port config all (crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|hw-vlan-filter|" 860 "hw-vlan-strip|hw-vlan-extend|drop-en)" 861 " (on|off)\n" 862 " Set crc-strip/scatter/rx-checksum/hardware-vlan/drop_en" 863 " for ports.\n\n" 864 865 "port config all rss (all|default|ip|tcp|udp|sctp|" 866 "ether|port|vxlan|geneve|nvgre|none|<flowtype_id>)\n" 867 " Set the RSS mode.\n\n" 868 869 "port config port-id rss reta (hash,queue)[,(hash,queue)]\n" 870 " Set the RSS redirection table.\n\n" 871 872 "port config (port_id) dcb vt (on|off) (traffic_class)" 873 " pfc (on|off)\n" 874 " Set the DCB mode.\n\n" 875 876 "port config all burst (value)\n" 877 " Set the number of packets per burst.\n\n" 878 879 "port config all (txpt|txht|txwt|rxpt|rxht|rxwt)" 880 " (value)\n" 881 " Set the ring prefetch/host/writeback threshold" 882 " for tx/rx queue.\n\n" 883 884 "port config all (txfreet|txrst|rxfreet) (value)\n" 885 " Set free threshold for rx/tx, or set" 886 " tx rs bit threshold.\n\n" 887 "port config mtu X value\n" 888 " Set the MTU of port X to a given value\n\n" 889 890 "port config (port_id) (rxq|txq) (queue_id) ring_size (value)\n" 891 " Set a rx/tx queue's ring size configuration, the new" 892 " value will take effect after command that (re-)start the port" 893 " or command that setup the specific queue\n\n" 894 895 "port (port_id) (rxq|txq) (queue_id) (start|stop)\n" 896 " Start/stop a rx/tx queue of port X. Only take effect" 897 " when port X is started\n\n" 898 899 "port (port_id) (rxq|txq) (queue_id) deferred_start (on|off)\n" 900 " Switch on/off a deferred start of port X rx/tx queue. Only" 901 " take effect when port X is stopped.\n\n" 902 903 "port (port_id) (rxq|txq) (queue_id) setup\n" 904 " Setup a rx/tx queue of port X.\n\n" 905 906 "port config (port_id|all) l2-tunnel E-tag ether-type" 907 " (value)\n" 908 " Set the value of E-tag ether-type.\n\n" 909 910 "port config (port_id|all) l2-tunnel E-tag" 911 " (enable|disable)\n" 912 " Enable/disable the E-tag support.\n\n" 913 914 "port config (port_id) pctype mapping reset\n" 915 " Reset flow type to pctype mapping on a port\n\n" 916 917 "port config (port_id) pctype mapping update" 918 " (pctype_id_0[,pctype_id_1]*) (flow_type_id)\n" 919 " Update a flow type to pctype mapping item on a port\n\n" 920 921 "port config (port_id) pctype (pctype_id) hash_inset|" 922 "fdir_inset|fdir_flx_inset get|set|clear field\n" 923 " (field_idx)\n" 924 " Configure RSS|FDIR|FDIR_FLX input set for some pctype\n\n" 925 926 "port config (port_id) pctype (pctype_id) hash_inset|" 927 "fdir_inset|fdir_flx_inset clear all" 928 " Clear RSS|FDIR|FDIR_FLX input set completely for some pctype\n\n" 929 930 "port config (port_id) udp_tunnel_port add|rm vxlan|geneve (udp_port)\n\n" 931 " Add/remove UDP tunnel port for tunneling offload\n\n" 932 ); 933 } 934 935 if (show_all || !strcmp(res->section, "registers")) { 936 937 cmdline_printf( 938 cl, 939 "\n" 940 "Registers:\n" 941 "----------\n\n" 942 943 "read reg (port_id) (address)\n" 944 " Display value of a port register.\n\n" 945 946 "read regfield (port_id) (address) (bit_x) (bit_y)\n" 947 " Display a port register bit field.\n\n" 948 949 "read regbit (port_id) (address) (bit_x)\n" 950 " Display a single port register bit.\n\n" 951 952 "write reg (port_id) (address) (value)\n" 953 " Set value of a port register.\n\n" 954 955 "write regfield (port_id) (address) (bit_x) (bit_y)" 956 " (value)\n" 957 " Set bit field of a port register.\n\n" 958 959 "write regbit (port_id) (address) (bit_x) (value)\n" 960 " Set single bit value of a port register.\n\n" 961 ); 962 } 963 if (show_all || !strcmp(res->section, "filters")) { 964 965 cmdline_printf( 966 cl, 967 "\n" 968 "filters:\n" 969 "--------\n\n" 970 971 "ethertype_filter (port_id) (add|del)" 972 " (mac_addr|mac_ignr) (mac_address) ethertype" 973 " (ether_type) (drop|fwd) queue (queue_id)\n" 974 " Add/Del an ethertype filter.\n\n" 975 976 "2tuple_filter (port_id) (add|del)" 977 " dst_port (dst_port_value) protocol (protocol_value)" 978 " mask (mask_value) tcp_flags (tcp_flags_value)" 979 " priority (prio_value) queue (queue_id)\n" 980 " Add/Del a 2tuple filter.\n\n" 981 982 "5tuple_filter (port_id) (add|del)" 983 " dst_ip (dst_address) src_ip (src_address)" 984 " dst_port (dst_port_value) src_port (src_port_value)" 985 " protocol (protocol_value)" 986 " mask (mask_value) tcp_flags (tcp_flags_value)" 987 " priority (prio_value) queue (queue_id)\n" 988 " Add/Del a 5tuple filter.\n\n" 989 990 "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)" 991 " Add/Del syn filter.\n\n" 992 993 "flex_filter (port_id) (add|del) len (len_value)" 994 " bytes (bytes_value) mask (mask_value)" 995 " priority (prio_value) queue (queue_id)\n" 996 " Add/Del a flex filter.\n\n" 997 998 "flow_director_filter (port_id) mode IP (add|del|update)" 999 " flow (ipv4-other|ipv4-frag|ipv6-other|ipv6-frag)" 1000 " src (src_ip_address) dst (dst_ip_address)" 1001 " tos (tos_value) proto (proto_value) ttl (ttl_value)" 1002 " vlan (vlan_value) flexbytes (flexbytes_value)" 1003 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 1004 " fd_id (fd_id_value)\n" 1005 " Add/Del an IP type flow director filter.\n\n" 1006 1007 "flow_director_filter (port_id) mode IP (add|del|update)" 1008 " flow (ipv4-tcp|ipv4-udp|ipv6-tcp|ipv6-udp)" 1009 " src (src_ip_address) (src_port)" 1010 " dst (dst_ip_address) (dst_port)" 1011 " tos (tos_value) ttl (ttl_value)" 1012 " vlan (vlan_value) flexbytes (flexbytes_value)" 1013 " (drop|fwd) pf|vf(vf_id) queue (queue_id)" 1014 " fd_id (fd_id_value)\n" 1015 " Add/Del an UDP/TCP type flow director filter.\n\n" 1016 1017 "flow_director_filter (port_id) mode IP (add|del|update)" 1018 " flow (ipv4-sctp|ipv6-sctp)" 1019 " src (src_ip_address) (src_port)" 1020 " dst (dst_ip_address) (dst_port)" 1021 " tag (verification_tag) " 1022 " tos (tos_value) ttl (ttl_value)" 1023 " vlan (vlan_value)" 1024 " flexbytes (flexbytes_value) (drop|fwd)" 1025 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 1026 " Add/Del a SCTP type flow director filter.\n\n" 1027 1028 "flow_director_filter (port_id) mode IP (add|del|update)" 1029 " flow l2_payload ether (ethertype)" 1030 " flexbytes (flexbytes_value) (drop|fwd)" 1031 " pf|vf(vf_id) queue (queue_id) fd_id (fd_id_value)\n" 1032 " Add/Del a l2 payload type flow director filter.\n\n" 1033 1034 "flow_director_filter (port_id) mode MAC-VLAN (add|del|update)" 1035 " mac (mac_address) vlan (vlan_value)" 1036 " flexbytes (flexbytes_value) (drop|fwd)" 1037 " queue (queue_id) fd_id (fd_id_value)\n" 1038 " Add/Del a MAC-VLAN flow director filter.\n\n" 1039 1040 "flow_director_filter (port_id) mode Tunnel (add|del|update)" 1041 " mac (mac_address) vlan (vlan_value)" 1042 " tunnel (NVGRE|VxLAN) tunnel-id (tunnel_id_value)" 1043 " flexbytes (flexbytes_value) (drop|fwd)" 1044 " queue (queue_id) fd_id (fd_id_value)\n" 1045 " Add/Del a Tunnel flow director filter.\n\n" 1046 1047 "flow_director_filter (port_id) mode raw (add|del|update)" 1048 " flow (flow_id) (drop|fwd) queue (queue_id)" 1049 " fd_id (fd_id_value) packet (packet file name)\n" 1050 " Add/Del a raw type flow director filter.\n\n" 1051 1052 "flush_flow_director (port_id)\n" 1053 " Flush all flow director entries of a device.\n\n" 1054 1055 "flow_director_mask (port_id) mode IP vlan (vlan_value)" 1056 " src_mask (ipv4_src) (ipv6_src) (src_port)" 1057 " dst_mask (ipv4_dst) (ipv6_dst) (dst_port)\n" 1058 " Set flow director IP mask.\n\n" 1059 1060 "flow_director_mask (port_id) mode MAC-VLAN" 1061 " vlan (vlan_value)\n" 1062 " Set flow director MAC-VLAN mask.\n\n" 1063 1064 "flow_director_mask (port_id) mode Tunnel" 1065 " vlan (vlan_value) mac (mac_value)" 1066 " tunnel-type (tunnel_type_value)" 1067 " tunnel-id (tunnel_id_value)\n" 1068 " Set flow director Tunnel mask.\n\n" 1069 1070 "flow_director_flex_mask (port_id)" 1071 " flow (none|ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 1072 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|l2_payload|all)" 1073 " (mask)\n" 1074 " Configure mask of flex payload.\n\n" 1075 1076 "flow_director_flex_payload (port_id)" 1077 " (raw|l2|l3|l4) (config)\n" 1078 " Configure flex payload selection.\n\n" 1079 1080 "get_sym_hash_ena_per_port (port_id)\n" 1081 " get symmetric hash enable configuration per port.\n\n" 1082 1083 "set_sym_hash_ena_per_port (port_id) (enable|disable)\n" 1084 " set symmetric hash enable configuration per port" 1085 " to enable or disable.\n\n" 1086 1087 "get_hash_global_config (port_id)\n" 1088 " Get the global configurations of hash filters.\n\n" 1089 1090 "set_hash_global_config (port_id) (toeplitz|simple_xor|default)" 1091 " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1092 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)" 1093 " (enable|disable)\n" 1094 " Set the global configurations of hash filters.\n\n" 1095 1096 "set_hash_input_set (port_id) (ipv4|ipv4-frag|" 1097 "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" 1098 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1099 "l2_payload|<flowtype_id>) (ovlan|ivlan|src-ipv4|dst-ipv4|" 1100 "src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|" 1101 "ipv6-next-header|udp-src-port|udp-dst-port|" 1102 "tcp-src-port|tcp-dst-port|sctp-src-port|" 1103 "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|" 1104 "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|" 1105 "fld-8th|none) (select|add)\n" 1106 " Set the input set for hash.\n\n" 1107 1108 "set_fdir_input_set (port_id) " 1109 "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 1110 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 1111 "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|" 1112 "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|" 1113 "ipv6-next-header|ipv6-hop-limits|udp-src-port|" 1114 "udp-dst-port|tcp-src-port|tcp-dst-port|" 1115 "sctp-src-port|sctp-dst-port|sctp-veri-tag|none)" 1116 " (select|add)\n" 1117 " Set the input set for FDir.\n\n" 1118 1119 "flow validate {port_id}" 1120 " [group {group_id}] [priority {level}]" 1121 " [ingress] [egress]" 1122 " pattern {item} [/ {item} [...]] / end" 1123 " actions {action} [/ {action} [...]] / end\n" 1124 " Check whether a flow rule can be created.\n\n" 1125 1126 "flow create {port_id}" 1127 " [group {group_id}] [priority {level}]" 1128 " [ingress] [egress]" 1129 " pattern {item} [/ {item} [...]] / end" 1130 " actions {action} [/ {action} [...]] / end\n" 1131 " Create a flow rule.\n\n" 1132 1133 "flow destroy {port_id} rule {rule_id} [...]\n" 1134 " Destroy specific flow rules.\n\n" 1135 1136 "flow flush {port_id}\n" 1137 " Destroy all flow rules.\n\n" 1138 1139 "flow query {port_id} {rule_id} {action}\n" 1140 " Query an existing flow rule.\n\n" 1141 1142 "flow list {port_id} [group {group_id}] [...]\n" 1143 " List existing flow rules sorted by priority," 1144 " filtered by group identifiers.\n\n" 1145 1146 "flow isolate {port_id} {boolean}\n" 1147 " Restrict ingress traffic to the defined" 1148 " flow rules\n\n" 1149 ); 1150 } 1151 } 1152 1153 cmdline_parse_token_string_t cmd_help_long_help = 1154 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, help, "help"); 1155 1156 cmdline_parse_token_string_t cmd_help_long_section = 1157 TOKEN_STRING_INITIALIZER(struct cmd_help_long_result, section, 1158 "all#control#display#config#" 1159 "ports#registers#filters"); 1160 1161 cmdline_parse_inst_t cmd_help_long = { 1162 .f = cmd_help_long_parsed, 1163 .data = NULL, 1164 .help_str = "help all|control|display|config|ports|register|filters: " 1165 "Show help", 1166 .tokens = { 1167 (void *)&cmd_help_long_help, 1168 (void *)&cmd_help_long_section, 1169 NULL, 1170 }, 1171 }; 1172 1173 1174 /* *** start/stop/close all ports *** */ 1175 struct cmd_operate_port_result { 1176 cmdline_fixed_string_t keyword; 1177 cmdline_fixed_string_t name; 1178 cmdline_fixed_string_t value; 1179 }; 1180 1181 static void cmd_operate_port_parsed(void *parsed_result, 1182 __attribute__((unused)) struct cmdline *cl, 1183 __attribute__((unused)) void *data) 1184 { 1185 struct cmd_operate_port_result *res = parsed_result; 1186 1187 if (!strcmp(res->name, "start")) 1188 start_port(RTE_PORT_ALL); 1189 else if (!strcmp(res->name, "stop")) 1190 stop_port(RTE_PORT_ALL); 1191 else if (!strcmp(res->name, "close")) 1192 close_port(RTE_PORT_ALL); 1193 else if (!strcmp(res->name, "reset")) 1194 reset_port(RTE_PORT_ALL); 1195 else 1196 printf("Unknown parameter\n"); 1197 } 1198 1199 cmdline_parse_token_string_t cmd_operate_port_all_cmd = 1200 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, keyword, 1201 "port"); 1202 cmdline_parse_token_string_t cmd_operate_port_all_port = 1203 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, name, 1204 "start#stop#close#reset"); 1205 cmdline_parse_token_string_t cmd_operate_port_all_all = 1206 TOKEN_STRING_INITIALIZER(struct cmd_operate_port_result, value, "all"); 1207 1208 cmdline_parse_inst_t cmd_operate_port = { 1209 .f = cmd_operate_port_parsed, 1210 .data = NULL, 1211 .help_str = "port start|stop|close all: Start/Stop/Close/Reset all ports", 1212 .tokens = { 1213 (void *)&cmd_operate_port_all_cmd, 1214 (void *)&cmd_operate_port_all_port, 1215 (void *)&cmd_operate_port_all_all, 1216 NULL, 1217 }, 1218 }; 1219 1220 /* *** start/stop/close specific port *** */ 1221 struct cmd_operate_specific_port_result { 1222 cmdline_fixed_string_t keyword; 1223 cmdline_fixed_string_t name; 1224 uint8_t value; 1225 }; 1226 1227 static void cmd_operate_specific_port_parsed(void *parsed_result, 1228 __attribute__((unused)) struct cmdline *cl, 1229 __attribute__((unused)) void *data) 1230 { 1231 struct cmd_operate_specific_port_result *res = parsed_result; 1232 1233 if (!strcmp(res->name, "start")) 1234 start_port(res->value); 1235 else if (!strcmp(res->name, "stop")) 1236 stop_port(res->value); 1237 else if (!strcmp(res->name, "close")) 1238 close_port(res->value); 1239 else if (!strcmp(res->name, "reset")) 1240 reset_port(res->value); 1241 else 1242 printf("Unknown parameter\n"); 1243 } 1244 1245 cmdline_parse_token_string_t cmd_operate_specific_port_cmd = 1246 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1247 keyword, "port"); 1248 cmdline_parse_token_string_t cmd_operate_specific_port_port = 1249 TOKEN_STRING_INITIALIZER(struct cmd_operate_specific_port_result, 1250 name, "start#stop#close#reset"); 1251 cmdline_parse_token_num_t cmd_operate_specific_port_id = 1252 TOKEN_NUM_INITIALIZER(struct cmd_operate_specific_port_result, 1253 value, UINT8); 1254 1255 cmdline_parse_inst_t cmd_operate_specific_port = { 1256 .f = cmd_operate_specific_port_parsed, 1257 .data = NULL, 1258 .help_str = "port start|stop|close <port_id>: Start/Stop/Close/Reset port_id", 1259 .tokens = { 1260 (void *)&cmd_operate_specific_port_cmd, 1261 (void *)&cmd_operate_specific_port_port, 1262 (void *)&cmd_operate_specific_port_id, 1263 NULL, 1264 }, 1265 }; 1266 1267 /* *** enable port setup (after attach) via iterator or event *** */ 1268 struct cmd_set_port_setup_on_result { 1269 cmdline_fixed_string_t set; 1270 cmdline_fixed_string_t port; 1271 cmdline_fixed_string_t setup; 1272 cmdline_fixed_string_t on; 1273 cmdline_fixed_string_t mode; 1274 }; 1275 1276 static void cmd_set_port_setup_on_parsed(void *parsed_result, 1277 __attribute__((unused)) struct cmdline *cl, 1278 __attribute__((unused)) void *data) 1279 { 1280 struct cmd_set_port_setup_on_result *res = parsed_result; 1281 1282 if (strcmp(res->mode, "event") == 0) 1283 setup_on_probe_event = true; 1284 else if (strcmp(res->mode, "iterator") == 0) 1285 setup_on_probe_event = false; 1286 else 1287 printf("Unknown mode\n"); 1288 } 1289 1290 cmdline_parse_token_string_t cmd_set_port_setup_on_set = 1291 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1292 set, "set"); 1293 cmdline_parse_token_string_t cmd_set_port_setup_on_port = 1294 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1295 port, "port"); 1296 cmdline_parse_token_string_t cmd_set_port_setup_on_setup = 1297 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1298 setup, "setup"); 1299 cmdline_parse_token_string_t cmd_set_port_setup_on_on = 1300 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1301 on, "on"); 1302 cmdline_parse_token_string_t cmd_set_port_setup_on_mode = 1303 TOKEN_STRING_INITIALIZER(struct cmd_set_port_setup_on_result, 1304 mode, "iterator#event"); 1305 1306 cmdline_parse_inst_t cmd_set_port_setup_on = { 1307 .f = cmd_set_port_setup_on_parsed, 1308 .data = NULL, 1309 .help_str = "set port setup on iterator|event", 1310 .tokens = { 1311 (void *)&cmd_set_port_setup_on_set, 1312 (void *)&cmd_set_port_setup_on_port, 1313 (void *)&cmd_set_port_setup_on_setup, 1314 (void *)&cmd_set_port_setup_on_on, 1315 (void *)&cmd_set_port_setup_on_mode, 1316 NULL, 1317 }, 1318 }; 1319 1320 /* *** attach a specified port *** */ 1321 struct cmd_operate_attach_port_result { 1322 cmdline_fixed_string_t port; 1323 cmdline_fixed_string_t keyword; 1324 cmdline_fixed_string_t identifier; 1325 }; 1326 1327 static void cmd_operate_attach_port_parsed(void *parsed_result, 1328 __attribute__((unused)) struct cmdline *cl, 1329 __attribute__((unused)) void *data) 1330 { 1331 struct cmd_operate_attach_port_result *res = parsed_result; 1332 1333 if (!strcmp(res->keyword, "attach")) 1334 attach_port(res->identifier); 1335 else 1336 printf("Unknown parameter\n"); 1337 } 1338 1339 cmdline_parse_token_string_t cmd_operate_attach_port_port = 1340 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1341 port, "port"); 1342 cmdline_parse_token_string_t cmd_operate_attach_port_keyword = 1343 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1344 keyword, "attach"); 1345 cmdline_parse_token_string_t cmd_operate_attach_port_identifier = 1346 TOKEN_STRING_INITIALIZER(struct cmd_operate_attach_port_result, 1347 identifier, NULL); 1348 1349 cmdline_parse_inst_t cmd_operate_attach_port = { 1350 .f = cmd_operate_attach_port_parsed, 1351 .data = NULL, 1352 .help_str = "port attach <identifier>: " 1353 "(identifier: pci address or virtual dev name)", 1354 .tokens = { 1355 (void *)&cmd_operate_attach_port_port, 1356 (void *)&cmd_operate_attach_port_keyword, 1357 (void *)&cmd_operate_attach_port_identifier, 1358 NULL, 1359 }, 1360 }; 1361 1362 /* *** detach a specified port *** */ 1363 struct cmd_operate_detach_port_result { 1364 cmdline_fixed_string_t port; 1365 cmdline_fixed_string_t keyword; 1366 portid_t port_id; 1367 }; 1368 1369 static void cmd_operate_detach_port_parsed(void *parsed_result, 1370 __attribute__((unused)) struct cmdline *cl, 1371 __attribute__((unused)) void *data) 1372 { 1373 struct cmd_operate_detach_port_result *res = parsed_result; 1374 1375 if (!strcmp(res->keyword, "detach")) 1376 detach_port_device(res->port_id); 1377 else 1378 printf("Unknown parameter\n"); 1379 } 1380 1381 cmdline_parse_token_string_t cmd_operate_detach_port_port = 1382 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1383 port, "port"); 1384 cmdline_parse_token_string_t cmd_operate_detach_port_keyword = 1385 TOKEN_STRING_INITIALIZER(struct cmd_operate_detach_port_result, 1386 keyword, "detach"); 1387 cmdline_parse_token_num_t cmd_operate_detach_port_port_id = 1388 TOKEN_NUM_INITIALIZER(struct cmd_operate_detach_port_result, 1389 port_id, UINT16); 1390 1391 cmdline_parse_inst_t cmd_operate_detach_port = { 1392 .f = cmd_operate_detach_port_parsed, 1393 .data = NULL, 1394 .help_str = "port detach <port_id>", 1395 .tokens = { 1396 (void *)&cmd_operate_detach_port_port, 1397 (void *)&cmd_operate_detach_port_keyword, 1398 (void *)&cmd_operate_detach_port_port_id, 1399 NULL, 1400 }, 1401 }; 1402 1403 /* *** configure speed for all ports *** */ 1404 struct cmd_config_speed_all { 1405 cmdline_fixed_string_t port; 1406 cmdline_fixed_string_t keyword; 1407 cmdline_fixed_string_t all; 1408 cmdline_fixed_string_t item1; 1409 cmdline_fixed_string_t item2; 1410 cmdline_fixed_string_t value1; 1411 cmdline_fixed_string_t value2; 1412 }; 1413 1414 static int 1415 parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed) 1416 { 1417 1418 int duplex; 1419 1420 if (!strcmp(duplexstr, "half")) { 1421 duplex = ETH_LINK_HALF_DUPLEX; 1422 } else if (!strcmp(duplexstr, "full")) { 1423 duplex = ETH_LINK_FULL_DUPLEX; 1424 } else if (!strcmp(duplexstr, "auto")) { 1425 duplex = ETH_LINK_FULL_DUPLEX; 1426 } else { 1427 printf("Unknown duplex parameter\n"); 1428 return -1; 1429 } 1430 1431 if (!strcmp(speedstr, "10")) { 1432 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1433 ETH_LINK_SPEED_10M_HD : ETH_LINK_SPEED_10M; 1434 } else if (!strcmp(speedstr, "100")) { 1435 *speed = (duplex == ETH_LINK_HALF_DUPLEX) ? 1436 ETH_LINK_SPEED_100M_HD : ETH_LINK_SPEED_100M; 1437 } else { 1438 if (duplex != ETH_LINK_FULL_DUPLEX) { 1439 printf("Invalid speed/duplex parameters\n"); 1440 return -1; 1441 } 1442 if (!strcmp(speedstr, "1000")) { 1443 *speed = ETH_LINK_SPEED_1G; 1444 } else if (!strcmp(speedstr, "10000")) { 1445 *speed = ETH_LINK_SPEED_10G; 1446 } else if (!strcmp(speedstr, "25000")) { 1447 *speed = ETH_LINK_SPEED_25G; 1448 } else if (!strcmp(speedstr, "40000")) { 1449 *speed = ETH_LINK_SPEED_40G; 1450 } else if (!strcmp(speedstr, "50000")) { 1451 *speed = ETH_LINK_SPEED_50G; 1452 } else if (!strcmp(speedstr, "100000")) { 1453 *speed = ETH_LINK_SPEED_100G; 1454 } else if (!strcmp(speedstr, "auto")) { 1455 *speed = ETH_LINK_SPEED_AUTONEG; 1456 } else { 1457 printf("Unknown speed parameter\n"); 1458 return -1; 1459 } 1460 } 1461 1462 return 0; 1463 } 1464 1465 static void 1466 cmd_config_speed_all_parsed(void *parsed_result, 1467 __attribute__((unused)) struct cmdline *cl, 1468 __attribute__((unused)) void *data) 1469 { 1470 struct cmd_config_speed_all *res = parsed_result; 1471 uint32_t link_speed; 1472 portid_t pid; 1473 1474 if (!all_ports_stopped()) { 1475 printf("Please stop all ports first\n"); 1476 return; 1477 } 1478 1479 if (parse_and_check_speed_duplex(res->value1, res->value2, 1480 &link_speed) < 0) 1481 return; 1482 1483 RTE_ETH_FOREACH_DEV(pid) { 1484 ports[pid].dev_conf.link_speeds = link_speed; 1485 } 1486 1487 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1488 } 1489 1490 cmdline_parse_token_string_t cmd_config_speed_all_port = 1491 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, port, "port"); 1492 cmdline_parse_token_string_t cmd_config_speed_all_keyword = 1493 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, keyword, 1494 "config"); 1495 cmdline_parse_token_string_t cmd_config_speed_all_all = 1496 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, all, "all"); 1497 cmdline_parse_token_string_t cmd_config_speed_all_item1 = 1498 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item1, "speed"); 1499 cmdline_parse_token_string_t cmd_config_speed_all_value1 = 1500 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value1, 1501 "10#100#1000#10000#25000#40000#50000#100000#auto"); 1502 cmdline_parse_token_string_t cmd_config_speed_all_item2 = 1503 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, item2, "duplex"); 1504 cmdline_parse_token_string_t cmd_config_speed_all_value2 = 1505 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_all, value2, 1506 "half#full#auto"); 1507 1508 cmdline_parse_inst_t cmd_config_speed_all = { 1509 .f = cmd_config_speed_all_parsed, 1510 .data = NULL, 1511 .help_str = "port config all speed " 1512 "10|100|1000|10000|25000|40000|50000|100000|auto duplex " 1513 "half|full|auto", 1514 .tokens = { 1515 (void *)&cmd_config_speed_all_port, 1516 (void *)&cmd_config_speed_all_keyword, 1517 (void *)&cmd_config_speed_all_all, 1518 (void *)&cmd_config_speed_all_item1, 1519 (void *)&cmd_config_speed_all_value1, 1520 (void *)&cmd_config_speed_all_item2, 1521 (void *)&cmd_config_speed_all_value2, 1522 NULL, 1523 }, 1524 }; 1525 1526 /* *** configure speed for specific port *** */ 1527 struct cmd_config_speed_specific { 1528 cmdline_fixed_string_t port; 1529 cmdline_fixed_string_t keyword; 1530 portid_t id; 1531 cmdline_fixed_string_t item1; 1532 cmdline_fixed_string_t item2; 1533 cmdline_fixed_string_t value1; 1534 cmdline_fixed_string_t value2; 1535 }; 1536 1537 static void 1538 cmd_config_speed_specific_parsed(void *parsed_result, 1539 __attribute__((unused)) struct cmdline *cl, 1540 __attribute__((unused)) void *data) 1541 { 1542 struct cmd_config_speed_specific *res = parsed_result; 1543 uint32_t link_speed; 1544 1545 if (!all_ports_stopped()) { 1546 printf("Please stop all ports first\n"); 1547 return; 1548 } 1549 1550 if (port_id_is_invalid(res->id, ENABLED_WARN)) 1551 return; 1552 1553 if (parse_and_check_speed_duplex(res->value1, res->value2, 1554 &link_speed) < 0) 1555 return; 1556 1557 ports[res->id].dev_conf.link_speeds = link_speed; 1558 1559 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1560 } 1561 1562 1563 cmdline_parse_token_string_t cmd_config_speed_specific_port = 1564 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, port, 1565 "port"); 1566 cmdline_parse_token_string_t cmd_config_speed_specific_keyword = 1567 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, keyword, 1568 "config"); 1569 cmdline_parse_token_num_t cmd_config_speed_specific_id = 1570 TOKEN_NUM_INITIALIZER(struct cmd_config_speed_specific, id, UINT16); 1571 cmdline_parse_token_string_t cmd_config_speed_specific_item1 = 1572 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item1, 1573 "speed"); 1574 cmdline_parse_token_string_t cmd_config_speed_specific_value1 = 1575 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value1, 1576 "10#100#1000#10000#25000#40000#50000#100000#auto"); 1577 cmdline_parse_token_string_t cmd_config_speed_specific_item2 = 1578 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, item2, 1579 "duplex"); 1580 cmdline_parse_token_string_t cmd_config_speed_specific_value2 = 1581 TOKEN_STRING_INITIALIZER(struct cmd_config_speed_specific, value2, 1582 "half#full#auto"); 1583 1584 cmdline_parse_inst_t cmd_config_speed_specific = { 1585 .f = cmd_config_speed_specific_parsed, 1586 .data = NULL, 1587 .help_str = "port config <port_id> speed " 1588 "10|100|1000|10000|25000|40000|50000|100000|auto duplex " 1589 "half|full|auto", 1590 .tokens = { 1591 (void *)&cmd_config_speed_specific_port, 1592 (void *)&cmd_config_speed_specific_keyword, 1593 (void *)&cmd_config_speed_specific_id, 1594 (void *)&cmd_config_speed_specific_item1, 1595 (void *)&cmd_config_speed_specific_value1, 1596 (void *)&cmd_config_speed_specific_item2, 1597 (void *)&cmd_config_speed_specific_value2, 1598 NULL, 1599 }, 1600 }; 1601 1602 /* *** configure loopback for all ports *** */ 1603 struct cmd_config_loopback_all { 1604 cmdline_fixed_string_t port; 1605 cmdline_fixed_string_t keyword; 1606 cmdline_fixed_string_t all; 1607 cmdline_fixed_string_t item; 1608 uint32_t mode; 1609 }; 1610 1611 static void 1612 cmd_config_loopback_all_parsed(void *parsed_result, 1613 __attribute__((unused)) struct cmdline *cl, 1614 __attribute__((unused)) void *data) 1615 { 1616 struct cmd_config_loopback_all *res = parsed_result; 1617 portid_t pid; 1618 1619 if (!all_ports_stopped()) { 1620 printf("Please stop all ports first\n"); 1621 return; 1622 } 1623 1624 RTE_ETH_FOREACH_DEV(pid) { 1625 ports[pid].dev_conf.lpbk_mode = res->mode; 1626 } 1627 1628 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1629 } 1630 1631 cmdline_parse_token_string_t cmd_config_loopback_all_port = 1632 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, port, "port"); 1633 cmdline_parse_token_string_t cmd_config_loopback_all_keyword = 1634 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, keyword, 1635 "config"); 1636 cmdline_parse_token_string_t cmd_config_loopback_all_all = 1637 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, all, "all"); 1638 cmdline_parse_token_string_t cmd_config_loopback_all_item = 1639 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_all, item, 1640 "loopback"); 1641 cmdline_parse_token_num_t cmd_config_loopback_all_mode = 1642 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_all, mode, UINT32); 1643 1644 cmdline_parse_inst_t cmd_config_loopback_all = { 1645 .f = cmd_config_loopback_all_parsed, 1646 .data = NULL, 1647 .help_str = "port config all loopback <mode>", 1648 .tokens = { 1649 (void *)&cmd_config_loopback_all_port, 1650 (void *)&cmd_config_loopback_all_keyword, 1651 (void *)&cmd_config_loopback_all_all, 1652 (void *)&cmd_config_loopback_all_item, 1653 (void *)&cmd_config_loopback_all_mode, 1654 NULL, 1655 }, 1656 }; 1657 1658 /* *** configure loopback for specific port *** */ 1659 struct cmd_config_loopback_specific { 1660 cmdline_fixed_string_t port; 1661 cmdline_fixed_string_t keyword; 1662 uint16_t port_id; 1663 cmdline_fixed_string_t item; 1664 uint32_t mode; 1665 }; 1666 1667 static void 1668 cmd_config_loopback_specific_parsed(void *parsed_result, 1669 __attribute__((unused)) struct cmdline *cl, 1670 __attribute__((unused)) void *data) 1671 { 1672 struct cmd_config_loopback_specific *res = parsed_result; 1673 1674 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 1675 return; 1676 1677 if (!port_is_stopped(res->port_id)) { 1678 printf("Please stop port %u first\n", res->port_id); 1679 return; 1680 } 1681 1682 ports[res->port_id].dev_conf.lpbk_mode = res->mode; 1683 1684 cmd_reconfig_device_queue(res->port_id, 1, 1); 1685 } 1686 1687 1688 cmdline_parse_token_string_t cmd_config_loopback_specific_port = 1689 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, port, 1690 "port"); 1691 cmdline_parse_token_string_t cmd_config_loopback_specific_keyword = 1692 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, keyword, 1693 "config"); 1694 cmdline_parse_token_num_t cmd_config_loopback_specific_id = 1695 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, port_id, 1696 UINT16); 1697 cmdline_parse_token_string_t cmd_config_loopback_specific_item = 1698 TOKEN_STRING_INITIALIZER(struct cmd_config_loopback_specific, item, 1699 "loopback"); 1700 cmdline_parse_token_num_t cmd_config_loopback_specific_mode = 1701 TOKEN_NUM_INITIALIZER(struct cmd_config_loopback_specific, mode, 1702 UINT32); 1703 1704 cmdline_parse_inst_t cmd_config_loopback_specific = { 1705 .f = cmd_config_loopback_specific_parsed, 1706 .data = NULL, 1707 .help_str = "port config <port_id> loopback <mode>", 1708 .tokens = { 1709 (void *)&cmd_config_loopback_specific_port, 1710 (void *)&cmd_config_loopback_specific_keyword, 1711 (void *)&cmd_config_loopback_specific_id, 1712 (void *)&cmd_config_loopback_specific_item, 1713 (void *)&cmd_config_loopback_specific_mode, 1714 NULL, 1715 }, 1716 }; 1717 1718 /* *** configure txq/rxq, txd/rxd *** */ 1719 struct cmd_config_rx_tx { 1720 cmdline_fixed_string_t port; 1721 cmdline_fixed_string_t keyword; 1722 cmdline_fixed_string_t all; 1723 cmdline_fixed_string_t name; 1724 uint16_t value; 1725 }; 1726 1727 static void 1728 cmd_config_rx_tx_parsed(void *parsed_result, 1729 __attribute__((unused)) struct cmdline *cl, 1730 __attribute__((unused)) void *data) 1731 { 1732 struct cmd_config_rx_tx *res = parsed_result; 1733 1734 if (!all_ports_stopped()) { 1735 printf("Please stop all ports first\n"); 1736 return; 1737 } 1738 if (!strcmp(res->name, "rxq")) { 1739 if (!res->value && !nb_txq) { 1740 printf("Warning: Either rx or tx queues should be non zero\n"); 1741 return; 1742 } 1743 if (check_nb_rxq(res->value) != 0) 1744 return; 1745 nb_rxq = res->value; 1746 } 1747 else if (!strcmp(res->name, "txq")) { 1748 if (!res->value && !nb_rxq) { 1749 printf("Warning: Either rx or tx queues should be non zero\n"); 1750 return; 1751 } 1752 if (check_nb_txq(res->value) != 0) 1753 return; 1754 nb_txq = res->value; 1755 } 1756 else if (!strcmp(res->name, "rxd")) { 1757 if (res->value <= 0 || res->value > RTE_TEST_RX_DESC_MAX) { 1758 printf("rxd %d invalid - must be > 0 && <= %d\n", 1759 res->value, RTE_TEST_RX_DESC_MAX); 1760 return; 1761 } 1762 nb_rxd = res->value; 1763 } else if (!strcmp(res->name, "txd")) { 1764 if (res->value <= 0 || res->value > RTE_TEST_TX_DESC_MAX) { 1765 printf("txd %d invalid - must be > 0 && <= %d\n", 1766 res->value, RTE_TEST_TX_DESC_MAX); 1767 return; 1768 } 1769 nb_txd = res->value; 1770 } else { 1771 printf("Unknown parameter\n"); 1772 return; 1773 } 1774 1775 fwd_config_setup(); 1776 1777 init_port_config(); 1778 1779 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1780 } 1781 1782 cmdline_parse_token_string_t cmd_config_rx_tx_port = 1783 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, port, "port"); 1784 cmdline_parse_token_string_t cmd_config_rx_tx_keyword = 1785 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, keyword, "config"); 1786 cmdline_parse_token_string_t cmd_config_rx_tx_all = 1787 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, all, "all"); 1788 cmdline_parse_token_string_t cmd_config_rx_tx_name = 1789 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_tx, name, 1790 "rxq#txq#rxd#txd"); 1791 cmdline_parse_token_num_t cmd_config_rx_tx_value = 1792 TOKEN_NUM_INITIALIZER(struct cmd_config_rx_tx, value, UINT16); 1793 1794 cmdline_parse_inst_t cmd_config_rx_tx = { 1795 .f = cmd_config_rx_tx_parsed, 1796 .data = NULL, 1797 .help_str = "port config all rxq|txq|rxd|txd <value>", 1798 .tokens = { 1799 (void *)&cmd_config_rx_tx_port, 1800 (void *)&cmd_config_rx_tx_keyword, 1801 (void *)&cmd_config_rx_tx_all, 1802 (void *)&cmd_config_rx_tx_name, 1803 (void *)&cmd_config_rx_tx_value, 1804 NULL, 1805 }, 1806 }; 1807 1808 /* *** config max packet length *** */ 1809 struct cmd_config_max_pkt_len_result { 1810 cmdline_fixed_string_t port; 1811 cmdline_fixed_string_t keyword; 1812 cmdline_fixed_string_t all; 1813 cmdline_fixed_string_t name; 1814 uint32_t value; 1815 }; 1816 1817 static void 1818 cmd_config_max_pkt_len_parsed(void *parsed_result, 1819 __attribute__((unused)) struct cmdline *cl, 1820 __attribute__((unused)) void *data) 1821 { 1822 struct cmd_config_max_pkt_len_result *res = parsed_result; 1823 portid_t pid; 1824 1825 if (!all_ports_stopped()) { 1826 printf("Please stop all ports first\n"); 1827 return; 1828 } 1829 1830 RTE_ETH_FOREACH_DEV(pid) { 1831 struct rte_port *port = &ports[pid]; 1832 uint64_t rx_offloads = port->dev_conf.rxmode.offloads; 1833 1834 if (!strcmp(res->name, "max-pkt-len")) { 1835 if (res->value < ETHER_MIN_LEN) { 1836 printf("max-pkt-len can not be less than %d\n", 1837 ETHER_MIN_LEN); 1838 return; 1839 } 1840 if (res->value == port->dev_conf.rxmode.max_rx_pkt_len) 1841 return; 1842 1843 port->dev_conf.rxmode.max_rx_pkt_len = res->value; 1844 if (res->value > ETHER_MAX_LEN) 1845 rx_offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; 1846 else 1847 rx_offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; 1848 port->dev_conf.rxmode.offloads = rx_offloads; 1849 } else { 1850 printf("Unknown parameter\n"); 1851 return; 1852 } 1853 } 1854 1855 init_port_config(); 1856 1857 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 1858 } 1859 1860 cmdline_parse_token_string_t cmd_config_max_pkt_len_port = 1861 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, port, 1862 "port"); 1863 cmdline_parse_token_string_t cmd_config_max_pkt_len_keyword = 1864 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, keyword, 1865 "config"); 1866 cmdline_parse_token_string_t cmd_config_max_pkt_len_all = 1867 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, all, 1868 "all"); 1869 cmdline_parse_token_string_t cmd_config_max_pkt_len_name = 1870 TOKEN_STRING_INITIALIZER(struct cmd_config_max_pkt_len_result, name, 1871 "max-pkt-len"); 1872 cmdline_parse_token_num_t cmd_config_max_pkt_len_value = 1873 TOKEN_NUM_INITIALIZER(struct cmd_config_max_pkt_len_result, value, 1874 UINT32); 1875 1876 cmdline_parse_inst_t cmd_config_max_pkt_len = { 1877 .f = cmd_config_max_pkt_len_parsed, 1878 .data = NULL, 1879 .help_str = "port config all max-pkt-len <value>", 1880 .tokens = { 1881 (void *)&cmd_config_max_pkt_len_port, 1882 (void *)&cmd_config_max_pkt_len_keyword, 1883 (void *)&cmd_config_max_pkt_len_all, 1884 (void *)&cmd_config_max_pkt_len_name, 1885 (void *)&cmd_config_max_pkt_len_value, 1886 NULL, 1887 }, 1888 }; 1889 1890 /* *** configure port MTU *** */ 1891 struct cmd_config_mtu_result { 1892 cmdline_fixed_string_t port; 1893 cmdline_fixed_string_t keyword; 1894 cmdline_fixed_string_t mtu; 1895 portid_t port_id; 1896 uint16_t value; 1897 }; 1898 1899 static void 1900 cmd_config_mtu_parsed(void *parsed_result, 1901 __attribute__((unused)) struct cmdline *cl, 1902 __attribute__((unused)) void *data) 1903 { 1904 struct cmd_config_mtu_result *res = parsed_result; 1905 1906 if (res->value < ETHER_MIN_LEN) { 1907 printf("mtu cannot be less than %d\n", ETHER_MIN_LEN); 1908 return; 1909 } 1910 port_mtu_set(res->port_id, res->value); 1911 } 1912 1913 cmdline_parse_token_string_t cmd_config_mtu_port = 1914 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port, 1915 "port"); 1916 cmdline_parse_token_string_t cmd_config_mtu_keyword = 1917 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 1918 "config"); 1919 cmdline_parse_token_string_t cmd_config_mtu_mtu = 1920 TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword, 1921 "mtu"); 1922 cmdline_parse_token_num_t cmd_config_mtu_port_id = 1923 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT16); 1924 cmdline_parse_token_num_t cmd_config_mtu_value = 1925 TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16); 1926 1927 cmdline_parse_inst_t cmd_config_mtu = { 1928 .f = cmd_config_mtu_parsed, 1929 .data = NULL, 1930 .help_str = "port config mtu <port_id> <value>", 1931 .tokens = { 1932 (void *)&cmd_config_mtu_port, 1933 (void *)&cmd_config_mtu_keyword, 1934 (void *)&cmd_config_mtu_mtu, 1935 (void *)&cmd_config_mtu_port_id, 1936 (void *)&cmd_config_mtu_value, 1937 NULL, 1938 }, 1939 }; 1940 1941 /* *** configure rx mode *** */ 1942 struct cmd_config_rx_mode_flag { 1943 cmdline_fixed_string_t port; 1944 cmdline_fixed_string_t keyword; 1945 cmdline_fixed_string_t all; 1946 cmdline_fixed_string_t name; 1947 cmdline_fixed_string_t value; 1948 }; 1949 1950 static void 1951 cmd_config_rx_mode_flag_parsed(void *parsed_result, 1952 __attribute__((unused)) struct cmdline *cl, 1953 __attribute__((unused)) void *data) 1954 { 1955 struct cmd_config_rx_mode_flag *res = parsed_result; 1956 portid_t pid; 1957 1958 if (!all_ports_stopped()) { 1959 printf("Please stop all ports first\n"); 1960 return; 1961 } 1962 1963 RTE_ETH_FOREACH_DEV(pid) { 1964 struct rte_port *port; 1965 uint64_t rx_offloads; 1966 1967 port = &ports[pid]; 1968 rx_offloads = port->dev_conf.rxmode.offloads; 1969 if (!strcmp(res->name, "crc-strip")) { 1970 if (!strcmp(res->value, "on")) { 1971 rx_offloads &= ~DEV_RX_OFFLOAD_KEEP_CRC; 1972 } else if (!strcmp(res->value, "off")) { 1973 rx_offloads |= DEV_RX_OFFLOAD_KEEP_CRC; 1974 } else { 1975 printf("Unknown parameter\n"); 1976 return; 1977 } 1978 } else if (!strcmp(res->name, "scatter")) { 1979 if (!strcmp(res->value, "on")) { 1980 rx_offloads |= DEV_RX_OFFLOAD_SCATTER; 1981 } else if (!strcmp(res->value, "off")) { 1982 rx_offloads &= ~DEV_RX_OFFLOAD_SCATTER; 1983 } else { 1984 printf("Unknown parameter\n"); 1985 return; 1986 } 1987 } else if (!strcmp(res->name, "rx-cksum")) { 1988 if (!strcmp(res->value, "on")) 1989 rx_offloads |= DEV_RX_OFFLOAD_CHECKSUM; 1990 else if (!strcmp(res->value, "off")) 1991 rx_offloads &= ~DEV_RX_OFFLOAD_CHECKSUM; 1992 else { 1993 printf("Unknown parameter\n"); 1994 return; 1995 } 1996 } else if (!strcmp(res->name, "rx-timestamp")) { 1997 if (!strcmp(res->value, "on")) 1998 rx_offloads |= DEV_RX_OFFLOAD_TIMESTAMP; 1999 else if (!strcmp(res->value, "off")) 2000 rx_offloads &= ~DEV_RX_OFFLOAD_TIMESTAMP; 2001 else { 2002 printf("Unknown parameter\n"); 2003 return; 2004 } 2005 } else if (!strcmp(res->name, "hw-vlan")) { 2006 if (!strcmp(res->value, "on")) { 2007 rx_offloads |= (DEV_RX_OFFLOAD_VLAN_FILTER | 2008 DEV_RX_OFFLOAD_VLAN_STRIP); 2009 } else if (!strcmp(res->value, "off")) { 2010 rx_offloads &= ~(DEV_RX_OFFLOAD_VLAN_FILTER | 2011 DEV_RX_OFFLOAD_VLAN_STRIP); 2012 } else { 2013 printf("Unknown parameter\n"); 2014 return; 2015 } 2016 } else if (!strcmp(res->name, "hw-vlan-filter")) { 2017 if (!strcmp(res->value, "on")) 2018 rx_offloads |= DEV_RX_OFFLOAD_VLAN_FILTER; 2019 else if (!strcmp(res->value, "off")) 2020 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_FILTER; 2021 else { 2022 printf("Unknown parameter\n"); 2023 return; 2024 } 2025 } else if (!strcmp(res->name, "hw-vlan-strip")) { 2026 if (!strcmp(res->value, "on")) 2027 rx_offloads |= DEV_RX_OFFLOAD_VLAN_STRIP; 2028 else if (!strcmp(res->value, "off")) 2029 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_STRIP; 2030 else { 2031 printf("Unknown parameter\n"); 2032 return; 2033 } 2034 } else if (!strcmp(res->name, "hw-vlan-extend")) { 2035 if (!strcmp(res->value, "on")) 2036 rx_offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND; 2037 else if (!strcmp(res->value, "off")) 2038 rx_offloads &= ~DEV_RX_OFFLOAD_VLAN_EXTEND; 2039 else { 2040 printf("Unknown parameter\n"); 2041 return; 2042 } 2043 } else if (!strcmp(res->name, "drop-en")) { 2044 if (!strcmp(res->value, "on")) 2045 rx_drop_en = 1; 2046 else if (!strcmp(res->value, "off")) 2047 rx_drop_en = 0; 2048 else { 2049 printf("Unknown parameter\n"); 2050 return; 2051 } 2052 } else { 2053 printf("Unknown parameter\n"); 2054 return; 2055 } 2056 port->dev_conf.rxmode.offloads = rx_offloads; 2057 } 2058 2059 init_port_config(); 2060 2061 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 2062 } 2063 2064 cmdline_parse_token_string_t cmd_config_rx_mode_flag_port = 2065 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, port, "port"); 2066 cmdline_parse_token_string_t cmd_config_rx_mode_flag_keyword = 2067 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, keyword, 2068 "config"); 2069 cmdline_parse_token_string_t cmd_config_rx_mode_flag_all = 2070 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, all, "all"); 2071 cmdline_parse_token_string_t cmd_config_rx_mode_flag_name = 2072 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, name, 2073 "crc-strip#scatter#rx-cksum#rx-timestamp#hw-vlan#" 2074 "hw-vlan-filter#hw-vlan-strip#hw-vlan-extend"); 2075 cmdline_parse_token_string_t cmd_config_rx_mode_flag_value = 2076 TOKEN_STRING_INITIALIZER(struct cmd_config_rx_mode_flag, value, 2077 "on#off"); 2078 2079 cmdline_parse_inst_t cmd_config_rx_mode_flag = { 2080 .f = cmd_config_rx_mode_flag_parsed, 2081 .data = NULL, 2082 .help_str = "port config all crc-strip|scatter|rx-cksum|rx-timestamp|hw-vlan|" 2083 "hw-vlan-filter|hw-vlan-strip|hw-vlan-extend on|off", 2084 .tokens = { 2085 (void *)&cmd_config_rx_mode_flag_port, 2086 (void *)&cmd_config_rx_mode_flag_keyword, 2087 (void *)&cmd_config_rx_mode_flag_all, 2088 (void *)&cmd_config_rx_mode_flag_name, 2089 (void *)&cmd_config_rx_mode_flag_value, 2090 NULL, 2091 }, 2092 }; 2093 2094 /* *** configure rss *** */ 2095 struct cmd_config_rss { 2096 cmdline_fixed_string_t port; 2097 cmdline_fixed_string_t keyword; 2098 cmdline_fixed_string_t all; 2099 cmdline_fixed_string_t name; 2100 cmdline_fixed_string_t value; 2101 }; 2102 2103 static void 2104 cmd_config_rss_parsed(void *parsed_result, 2105 __attribute__((unused)) struct cmdline *cl, 2106 __attribute__((unused)) void *data) 2107 { 2108 struct cmd_config_rss *res = parsed_result; 2109 struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, }; 2110 struct rte_eth_dev_info dev_info = { .flow_type_rss_offloads = 0, }; 2111 int use_default = 0; 2112 int all_updated = 1; 2113 int diag; 2114 uint16_t i; 2115 2116 if (!strcmp(res->value, "all")) 2117 rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP | 2118 ETH_RSS_UDP | ETH_RSS_SCTP | 2119 ETH_RSS_L2_PAYLOAD; 2120 else if (!strcmp(res->value, "ip")) 2121 rss_conf.rss_hf = ETH_RSS_IP; 2122 else if (!strcmp(res->value, "udp")) 2123 rss_conf.rss_hf = ETH_RSS_UDP; 2124 else if (!strcmp(res->value, "tcp")) 2125 rss_conf.rss_hf = ETH_RSS_TCP; 2126 else if (!strcmp(res->value, "sctp")) 2127 rss_conf.rss_hf = ETH_RSS_SCTP; 2128 else if (!strcmp(res->value, "ether")) 2129 rss_conf.rss_hf = ETH_RSS_L2_PAYLOAD; 2130 else if (!strcmp(res->value, "port")) 2131 rss_conf.rss_hf = ETH_RSS_PORT; 2132 else if (!strcmp(res->value, "vxlan")) 2133 rss_conf.rss_hf = ETH_RSS_VXLAN; 2134 else if (!strcmp(res->value, "geneve")) 2135 rss_conf.rss_hf = ETH_RSS_GENEVE; 2136 else if (!strcmp(res->value, "nvgre")) 2137 rss_conf.rss_hf = ETH_RSS_NVGRE; 2138 else if (!strcmp(res->value, "none")) 2139 rss_conf.rss_hf = 0; 2140 else if (!strcmp(res->value, "default")) 2141 use_default = 1; 2142 else if (isdigit(res->value[0]) && atoi(res->value) > 0 && 2143 atoi(res->value) < 64) 2144 rss_conf.rss_hf = 1ULL << atoi(res->value); 2145 else { 2146 printf("Unknown parameter\n"); 2147 return; 2148 } 2149 rss_conf.rss_key = NULL; 2150 /* Update global configuration for RSS types. */ 2151 RTE_ETH_FOREACH_DEV(i) { 2152 struct rte_eth_rss_conf local_rss_conf; 2153 2154 rte_eth_dev_info_get(i, &dev_info); 2155 if (use_default) 2156 rss_conf.rss_hf = dev_info.flow_type_rss_offloads; 2157 2158 local_rss_conf = rss_conf; 2159 local_rss_conf.rss_hf = rss_conf.rss_hf & 2160 dev_info.flow_type_rss_offloads; 2161 if (local_rss_conf.rss_hf != rss_conf.rss_hf) { 2162 printf("Port %u modified RSS hash function based on hardware support," 2163 "requested:%#"PRIx64" configured:%#"PRIx64"\n", 2164 i, rss_conf.rss_hf, local_rss_conf.rss_hf); 2165 } 2166 diag = rte_eth_dev_rss_hash_update(i, &local_rss_conf); 2167 if (diag < 0) { 2168 all_updated = 0; 2169 printf("Configuration of RSS hash at ethernet port %d " 2170 "failed with error (%d): %s.\n", 2171 i, -diag, strerror(-diag)); 2172 } 2173 } 2174 if (all_updated && !use_default) 2175 rss_hf = rss_conf.rss_hf; 2176 } 2177 2178 cmdline_parse_token_string_t cmd_config_rss_port = 2179 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, port, "port"); 2180 cmdline_parse_token_string_t cmd_config_rss_keyword = 2181 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, keyword, "config"); 2182 cmdline_parse_token_string_t cmd_config_rss_all = 2183 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, all, "all"); 2184 cmdline_parse_token_string_t cmd_config_rss_name = 2185 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, name, "rss"); 2186 cmdline_parse_token_string_t cmd_config_rss_value = 2187 TOKEN_STRING_INITIALIZER(struct cmd_config_rss, value, NULL); 2188 2189 cmdline_parse_inst_t cmd_config_rss = { 2190 .f = cmd_config_rss_parsed, 2191 .data = NULL, 2192 .help_str = "port config all rss " 2193 "all|default|ip|tcp|udp|sctp|ether|port|vxlan|geneve|nvgre|none|<flowtype_id>", 2194 .tokens = { 2195 (void *)&cmd_config_rss_port, 2196 (void *)&cmd_config_rss_keyword, 2197 (void *)&cmd_config_rss_all, 2198 (void *)&cmd_config_rss_name, 2199 (void *)&cmd_config_rss_value, 2200 NULL, 2201 }, 2202 }; 2203 2204 /* *** configure rss hash key *** */ 2205 struct cmd_config_rss_hash_key { 2206 cmdline_fixed_string_t port; 2207 cmdline_fixed_string_t config; 2208 portid_t port_id; 2209 cmdline_fixed_string_t rss_hash_key; 2210 cmdline_fixed_string_t rss_type; 2211 cmdline_fixed_string_t key; 2212 }; 2213 2214 static uint8_t 2215 hexa_digit_to_value(char hexa_digit) 2216 { 2217 if ((hexa_digit >= '0') && (hexa_digit <= '9')) 2218 return (uint8_t) (hexa_digit - '0'); 2219 if ((hexa_digit >= 'a') && (hexa_digit <= 'f')) 2220 return (uint8_t) ((hexa_digit - 'a') + 10); 2221 if ((hexa_digit >= 'A') && (hexa_digit <= 'F')) 2222 return (uint8_t) ((hexa_digit - 'A') + 10); 2223 /* Invalid hexa digit */ 2224 return 0xFF; 2225 } 2226 2227 static uint8_t 2228 parse_and_check_key_hexa_digit(char *key, int idx) 2229 { 2230 uint8_t hexa_v; 2231 2232 hexa_v = hexa_digit_to_value(key[idx]); 2233 if (hexa_v == 0xFF) 2234 printf("invalid key: character %c at position %d is not a " 2235 "valid hexa digit\n", key[idx], idx); 2236 return hexa_v; 2237 } 2238 2239 static void 2240 cmd_config_rss_hash_key_parsed(void *parsed_result, 2241 __attribute__((unused)) struct cmdline *cl, 2242 __attribute__((unused)) void *data) 2243 { 2244 struct cmd_config_rss_hash_key *res = parsed_result; 2245 uint8_t hash_key[RSS_HASH_KEY_LENGTH]; 2246 uint8_t xdgt0; 2247 uint8_t xdgt1; 2248 int i; 2249 struct rte_eth_dev_info dev_info; 2250 uint8_t hash_key_size; 2251 uint32_t key_len; 2252 2253 memset(&dev_info, 0, sizeof(dev_info)); 2254 rte_eth_dev_info_get(res->port_id, &dev_info); 2255 if (dev_info.hash_key_size > 0 && 2256 dev_info.hash_key_size <= sizeof(hash_key)) 2257 hash_key_size = dev_info.hash_key_size; 2258 else { 2259 printf("dev_info did not provide a valid hash key size\n"); 2260 return; 2261 } 2262 /* Check the length of the RSS hash key */ 2263 key_len = strlen(res->key); 2264 if (key_len != (hash_key_size * 2)) { 2265 printf("key length: %d invalid - key must be a string of %d" 2266 " hexa-decimal numbers\n", 2267 (int) key_len, hash_key_size * 2); 2268 return; 2269 } 2270 /* Translate RSS hash key into binary representation */ 2271 for (i = 0; i < hash_key_size; i++) { 2272 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 2273 if (xdgt0 == 0xFF) 2274 return; 2275 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 2276 if (xdgt1 == 0xFF) 2277 return; 2278 hash_key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 2279 } 2280 port_rss_hash_key_update(res->port_id, res->rss_type, hash_key, 2281 hash_key_size); 2282 } 2283 2284 cmdline_parse_token_string_t cmd_config_rss_hash_key_port = 2285 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port"); 2286 cmdline_parse_token_string_t cmd_config_rss_hash_key_config = 2287 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config, 2288 "config"); 2289 cmdline_parse_token_num_t cmd_config_rss_hash_key_port_id = 2290 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT16); 2291 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key = 2292 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, 2293 rss_hash_key, "rss-hash-key"); 2294 cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_type = 2295 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, rss_type, 2296 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 2297 "ipv4-other#ipv6#ipv6-frag#ipv6-tcp#ipv6-udp#" 2298 "ipv6-sctp#ipv6-other#l2-payload#ipv6-ex#" 2299 "ipv6-tcp-ex#ipv6-udp-ex"); 2300 cmdline_parse_token_string_t cmd_config_rss_hash_key_value = 2301 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL); 2302 2303 cmdline_parse_inst_t cmd_config_rss_hash_key = { 2304 .f = cmd_config_rss_hash_key_parsed, 2305 .data = NULL, 2306 .help_str = "port config <port_id> rss-hash-key " 2307 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 2308 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 2309 "l2-payload|ipv6-ex|ipv6-tcp-ex|ipv6-udp-ex " 2310 "<string of hex digits (variable length, NIC dependent)>", 2311 .tokens = { 2312 (void *)&cmd_config_rss_hash_key_port, 2313 (void *)&cmd_config_rss_hash_key_config, 2314 (void *)&cmd_config_rss_hash_key_port_id, 2315 (void *)&cmd_config_rss_hash_key_rss_hash_key, 2316 (void *)&cmd_config_rss_hash_key_rss_type, 2317 (void *)&cmd_config_rss_hash_key_value, 2318 NULL, 2319 }, 2320 }; 2321 2322 /* *** configure port rxq/txq ring size *** */ 2323 struct cmd_config_rxtx_ring_size { 2324 cmdline_fixed_string_t port; 2325 cmdline_fixed_string_t config; 2326 portid_t portid; 2327 cmdline_fixed_string_t rxtxq; 2328 uint16_t qid; 2329 cmdline_fixed_string_t rsize; 2330 uint16_t size; 2331 }; 2332 2333 static void 2334 cmd_config_rxtx_ring_size_parsed(void *parsed_result, 2335 __attribute__((unused)) struct cmdline *cl, 2336 __attribute__((unused)) void *data) 2337 { 2338 struct cmd_config_rxtx_ring_size *res = parsed_result; 2339 struct rte_port *port; 2340 uint8_t isrx; 2341 2342 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2343 return; 2344 2345 if (res->portid == (portid_t)RTE_PORT_ALL) { 2346 printf("Invalid port id\n"); 2347 return; 2348 } 2349 2350 port = &ports[res->portid]; 2351 2352 if (!strcmp(res->rxtxq, "rxq")) 2353 isrx = 1; 2354 else if (!strcmp(res->rxtxq, "txq")) 2355 isrx = 0; 2356 else { 2357 printf("Unknown parameter\n"); 2358 return; 2359 } 2360 2361 if (isrx && rx_queue_id_is_invalid(res->qid)) 2362 return; 2363 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2364 return; 2365 2366 if (isrx && res->size != 0 && res->size <= rx_free_thresh) { 2367 printf("Invalid rx ring_size, must > rx_free_thresh: %d\n", 2368 rx_free_thresh); 2369 return; 2370 } 2371 2372 if (isrx) 2373 port->nb_rx_desc[res->qid] = res->size; 2374 else 2375 port->nb_tx_desc[res->qid] = res->size; 2376 2377 cmd_reconfig_device_queue(res->portid, 0, 1); 2378 } 2379 2380 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_port = 2381 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2382 port, "port"); 2383 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_config = 2384 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2385 config, "config"); 2386 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_portid = 2387 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2388 portid, UINT16); 2389 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rxtxq = 2390 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2391 rxtxq, "rxq#txq"); 2392 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_qid = 2393 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2394 qid, UINT16); 2395 cmdline_parse_token_string_t cmd_config_rxtx_ring_size_rsize = 2396 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_ring_size, 2397 rsize, "ring_size"); 2398 cmdline_parse_token_num_t cmd_config_rxtx_ring_size_size = 2399 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_ring_size, 2400 size, UINT16); 2401 2402 cmdline_parse_inst_t cmd_config_rxtx_ring_size = { 2403 .f = cmd_config_rxtx_ring_size_parsed, 2404 .data = NULL, 2405 .help_str = "port config <port_id> rxq|txq <queue_id> ring_size <value>", 2406 .tokens = { 2407 (void *)&cmd_config_rxtx_ring_size_port, 2408 (void *)&cmd_config_rxtx_ring_size_config, 2409 (void *)&cmd_config_rxtx_ring_size_portid, 2410 (void *)&cmd_config_rxtx_ring_size_rxtxq, 2411 (void *)&cmd_config_rxtx_ring_size_qid, 2412 (void *)&cmd_config_rxtx_ring_size_rsize, 2413 (void *)&cmd_config_rxtx_ring_size_size, 2414 NULL, 2415 }, 2416 }; 2417 2418 /* *** configure port rxq/txq start/stop *** */ 2419 struct cmd_config_rxtx_queue { 2420 cmdline_fixed_string_t port; 2421 portid_t portid; 2422 cmdline_fixed_string_t rxtxq; 2423 uint16_t qid; 2424 cmdline_fixed_string_t opname; 2425 }; 2426 2427 static void 2428 cmd_config_rxtx_queue_parsed(void *parsed_result, 2429 __attribute__((unused)) struct cmdline *cl, 2430 __attribute__((unused)) void *data) 2431 { 2432 struct cmd_config_rxtx_queue *res = parsed_result; 2433 uint8_t isrx; 2434 uint8_t isstart; 2435 int ret = 0; 2436 2437 if (test_done == 0) { 2438 printf("Please stop forwarding first\n"); 2439 return; 2440 } 2441 2442 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2443 return; 2444 2445 if (port_is_started(res->portid) != 1) { 2446 printf("Please start port %u first\n", res->portid); 2447 return; 2448 } 2449 2450 if (!strcmp(res->rxtxq, "rxq")) 2451 isrx = 1; 2452 else if (!strcmp(res->rxtxq, "txq")) 2453 isrx = 0; 2454 else { 2455 printf("Unknown parameter\n"); 2456 return; 2457 } 2458 2459 if (isrx && rx_queue_id_is_invalid(res->qid)) 2460 return; 2461 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2462 return; 2463 2464 if (!strcmp(res->opname, "start")) 2465 isstart = 1; 2466 else if (!strcmp(res->opname, "stop")) 2467 isstart = 0; 2468 else { 2469 printf("Unknown parameter\n"); 2470 return; 2471 } 2472 2473 if (isstart && isrx) 2474 ret = rte_eth_dev_rx_queue_start(res->portid, res->qid); 2475 else if (!isstart && isrx) 2476 ret = rte_eth_dev_rx_queue_stop(res->portid, res->qid); 2477 else if (isstart && !isrx) 2478 ret = rte_eth_dev_tx_queue_start(res->portid, res->qid); 2479 else 2480 ret = rte_eth_dev_tx_queue_stop(res->portid, res->qid); 2481 2482 if (ret == -ENOTSUP) 2483 printf("Function not supported in PMD driver\n"); 2484 } 2485 2486 cmdline_parse_token_string_t cmd_config_rxtx_queue_port = 2487 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, port, "port"); 2488 cmdline_parse_token_num_t cmd_config_rxtx_queue_portid = 2489 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, portid, UINT16); 2490 cmdline_parse_token_string_t cmd_config_rxtx_queue_rxtxq = 2491 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, rxtxq, "rxq#txq"); 2492 cmdline_parse_token_num_t cmd_config_rxtx_queue_qid = 2493 TOKEN_NUM_INITIALIZER(struct cmd_config_rxtx_queue, qid, UINT16); 2494 cmdline_parse_token_string_t cmd_config_rxtx_queue_opname = 2495 TOKEN_STRING_INITIALIZER(struct cmd_config_rxtx_queue, opname, 2496 "start#stop"); 2497 2498 cmdline_parse_inst_t cmd_config_rxtx_queue = { 2499 .f = cmd_config_rxtx_queue_parsed, 2500 .data = NULL, 2501 .help_str = "port <port_id> rxq|txq <queue_id> start|stop", 2502 .tokens = { 2503 (void *)&cmd_config_rxtx_queue_port, 2504 (void *)&cmd_config_rxtx_queue_portid, 2505 (void *)&cmd_config_rxtx_queue_rxtxq, 2506 (void *)&cmd_config_rxtx_queue_qid, 2507 (void *)&cmd_config_rxtx_queue_opname, 2508 NULL, 2509 }, 2510 }; 2511 2512 /* *** configure port rxq/txq deferred start on/off *** */ 2513 struct cmd_config_deferred_start_rxtx_queue { 2514 cmdline_fixed_string_t port; 2515 portid_t port_id; 2516 cmdline_fixed_string_t rxtxq; 2517 uint16_t qid; 2518 cmdline_fixed_string_t opname; 2519 cmdline_fixed_string_t state; 2520 }; 2521 2522 static void 2523 cmd_config_deferred_start_rxtx_queue_parsed(void *parsed_result, 2524 __attribute__((unused)) struct cmdline *cl, 2525 __attribute__((unused)) void *data) 2526 { 2527 struct cmd_config_deferred_start_rxtx_queue *res = parsed_result; 2528 struct rte_port *port; 2529 uint8_t isrx; 2530 uint8_t ison; 2531 uint8_t needreconfig = 0; 2532 2533 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 2534 return; 2535 2536 if (port_is_started(res->port_id) != 0) { 2537 printf("Please stop port %u first\n", res->port_id); 2538 return; 2539 } 2540 2541 port = &ports[res->port_id]; 2542 2543 isrx = !strcmp(res->rxtxq, "rxq"); 2544 2545 if (isrx && rx_queue_id_is_invalid(res->qid)) 2546 return; 2547 else if (!isrx && tx_queue_id_is_invalid(res->qid)) 2548 return; 2549 2550 ison = !strcmp(res->state, "on"); 2551 2552 if (isrx && port->rx_conf[res->qid].rx_deferred_start != ison) { 2553 port->rx_conf[res->qid].rx_deferred_start = ison; 2554 needreconfig = 1; 2555 } else if (!isrx && port->tx_conf[res->qid].tx_deferred_start != ison) { 2556 port->tx_conf[res->qid].tx_deferred_start = ison; 2557 needreconfig = 1; 2558 } 2559 2560 if (needreconfig) 2561 cmd_reconfig_device_queue(res->port_id, 0, 1); 2562 } 2563 2564 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_port = 2565 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2566 port, "port"); 2567 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_port_id = 2568 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2569 port_id, UINT16); 2570 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_rxtxq = 2571 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2572 rxtxq, "rxq#txq"); 2573 cmdline_parse_token_num_t cmd_config_deferred_start_rxtx_queue_qid = 2574 TOKEN_NUM_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2575 qid, UINT16); 2576 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_opname = 2577 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2578 opname, "deferred_start"); 2579 cmdline_parse_token_string_t cmd_config_deferred_start_rxtx_queue_state = 2580 TOKEN_STRING_INITIALIZER(struct cmd_config_deferred_start_rxtx_queue, 2581 state, "on#off"); 2582 2583 cmdline_parse_inst_t cmd_config_deferred_start_rxtx_queue = { 2584 .f = cmd_config_deferred_start_rxtx_queue_parsed, 2585 .data = NULL, 2586 .help_str = "port <port_id> rxq|txq <queue_id> deferred_start on|off", 2587 .tokens = { 2588 (void *)&cmd_config_deferred_start_rxtx_queue_port, 2589 (void *)&cmd_config_deferred_start_rxtx_queue_port_id, 2590 (void *)&cmd_config_deferred_start_rxtx_queue_rxtxq, 2591 (void *)&cmd_config_deferred_start_rxtx_queue_qid, 2592 (void *)&cmd_config_deferred_start_rxtx_queue_opname, 2593 (void *)&cmd_config_deferred_start_rxtx_queue_state, 2594 NULL, 2595 }, 2596 }; 2597 2598 /* *** configure port rxq/txq setup *** */ 2599 struct cmd_setup_rxtx_queue { 2600 cmdline_fixed_string_t port; 2601 portid_t portid; 2602 cmdline_fixed_string_t rxtxq; 2603 uint16_t qid; 2604 cmdline_fixed_string_t setup; 2605 }; 2606 2607 /* Common CLI fields for queue setup */ 2608 cmdline_parse_token_string_t cmd_setup_rxtx_queue_port = 2609 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, port, "port"); 2610 cmdline_parse_token_num_t cmd_setup_rxtx_queue_portid = 2611 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, portid, UINT16); 2612 cmdline_parse_token_string_t cmd_setup_rxtx_queue_rxtxq = 2613 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, rxtxq, "rxq#txq"); 2614 cmdline_parse_token_num_t cmd_setup_rxtx_queue_qid = 2615 TOKEN_NUM_INITIALIZER(struct cmd_setup_rxtx_queue, qid, UINT16); 2616 cmdline_parse_token_string_t cmd_setup_rxtx_queue_setup = 2617 TOKEN_STRING_INITIALIZER(struct cmd_setup_rxtx_queue, setup, "setup"); 2618 2619 static void 2620 cmd_setup_rxtx_queue_parsed( 2621 void *parsed_result, 2622 __attribute__((unused)) struct cmdline *cl, 2623 __attribute__((unused)) void *data) 2624 { 2625 struct cmd_setup_rxtx_queue *res = parsed_result; 2626 struct rte_port *port; 2627 struct rte_mempool *mp; 2628 unsigned int socket_id; 2629 uint8_t isrx = 0; 2630 int ret; 2631 2632 if (port_id_is_invalid(res->portid, ENABLED_WARN)) 2633 return; 2634 2635 if (res->portid == (portid_t)RTE_PORT_ALL) { 2636 printf("Invalid port id\n"); 2637 return; 2638 } 2639 2640 if (!strcmp(res->rxtxq, "rxq")) 2641 isrx = 1; 2642 else if (!strcmp(res->rxtxq, "txq")) 2643 isrx = 0; 2644 else { 2645 printf("Unknown parameter\n"); 2646 return; 2647 } 2648 2649 if (isrx && rx_queue_id_is_invalid(res->qid)) { 2650 printf("Invalid rx queue\n"); 2651 return; 2652 } else if (!isrx && tx_queue_id_is_invalid(res->qid)) { 2653 printf("Invalid tx queue\n"); 2654 return; 2655 } 2656 2657 port = &ports[res->portid]; 2658 if (isrx) { 2659 socket_id = rxring_numa[res->portid]; 2660 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2661 socket_id = port->socket_id; 2662 2663 mp = mbuf_pool_find(socket_id); 2664 if (mp == NULL) { 2665 printf("Failed to setup RX queue: " 2666 "No mempool allocation" 2667 " on the socket %d\n", 2668 rxring_numa[res->portid]); 2669 return; 2670 } 2671 ret = rte_eth_rx_queue_setup(res->portid, 2672 res->qid, 2673 port->nb_rx_desc[res->qid], 2674 socket_id, 2675 &port->rx_conf[res->qid], 2676 mp); 2677 if (ret) 2678 printf("Failed to setup RX queue\n"); 2679 } else { 2680 socket_id = txring_numa[res->portid]; 2681 if (!numa_support || socket_id == NUMA_NO_CONFIG) 2682 socket_id = port->socket_id; 2683 2684 ret = rte_eth_tx_queue_setup(res->portid, 2685 res->qid, 2686 port->nb_tx_desc[res->qid], 2687 socket_id, 2688 &port->tx_conf[res->qid]); 2689 if (ret) 2690 printf("Failed to setup TX queue\n"); 2691 } 2692 } 2693 2694 cmdline_parse_inst_t cmd_setup_rxtx_queue = { 2695 .f = cmd_setup_rxtx_queue_parsed, 2696 .data = NULL, 2697 .help_str = "port <port_id> rxq|txq <queue_idx> setup", 2698 .tokens = { 2699 (void *)&cmd_setup_rxtx_queue_port, 2700 (void *)&cmd_setup_rxtx_queue_portid, 2701 (void *)&cmd_setup_rxtx_queue_rxtxq, 2702 (void *)&cmd_setup_rxtx_queue_qid, 2703 (void *)&cmd_setup_rxtx_queue_setup, 2704 NULL, 2705 }, 2706 }; 2707 2708 2709 /* *** Configure RSS RETA *** */ 2710 struct cmd_config_rss_reta { 2711 cmdline_fixed_string_t port; 2712 cmdline_fixed_string_t keyword; 2713 portid_t port_id; 2714 cmdline_fixed_string_t name; 2715 cmdline_fixed_string_t list_name; 2716 cmdline_fixed_string_t list_of_items; 2717 }; 2718 2719 static int 2720 parse_reta_config(const char *str, 2721 struct rte_eth_rss_reta_entry64 *reta_conf, 2722 uint16_t nb_entries) 2723 { 2724 int i; 2725 unsigned size; 2726 uint16_t hash_index, idx, shift; 2727 uint16_t nb_queue; 2728 char s[256]; 2729 const char *p, *p0 = str; 2730 char *end; 2731 enum fieldnames { 2732 FLD_HASH_INDEX = 0, 2733 FLD_QUEUE, 2734 _NUM_FLD 2735 }; 2736 unsigned long int_fld[_NUM_FLD]; 2737 char *str_fld[_NUM_FLD]; 2738 2739 while ((p = strchr(p0,'(')) != NULL) { 2740 ++p; 2741 if((p0 = strchr(p,')')) == NULL) 2742 return -1; 2743 2744 size = p0 - p; 2745 if(size >= sizeof(s)) 2746 return -1; 2747 2748 snprintf(s, sizeof(s), "%.*s", size, p); 2749 if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) 2750 return -1; 2751 for (i = 0; i < _NUM_FLD; i++) { 2752 errno = 0; 2753 int_fld[i] = strtoul(str_fld[i], &end, 0); 2754 if (errno != 0 || end == str_fld[i] || 2755 int_fld[i] > 65535) 2756 return -1; 2757 } 2758 2759 hash_index = (uint16_t)int_fld[FLD_HASH_INDEX]; 2760 nb_queue = (uint16_t)int_fld[FLD_QUEUE]; 2761 2762 if (hash_index >= nb_entries) { 2763 printf("Invalid RETA hash index=%d\n", hash_index); 2764 return -1; 2765 } 2766 2767 idx = hash_index / RTE_RETA_GROUP_SIZE; 2768 shift = hash_index % RTE_RETA_GROUP_SIZE; 2769 reta_conf[idx].mask |= (1ULL << shift); 2770 reta_conf[idx].reta[shift] = nb_queue; 2771 } 2772 2773 return 0; 2774 } 2775 2776 static void 2777 cmd_set_rss_reta_parsed(void *parsed_result, 2778 __attribute__((unused)) struct cmdline *cl, 2779 __attribute__((unused)) void *data) 2780 { 2781 int ret; 2782 struct rte_eth_dev_info dev_info; 2783 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2784 struct cmd_config_rss_reta *res = parsed_result; 2785 2786 memset(&dev_info, 0, sizeof(dev_info)); 2787 rte_eth_dev_info_get(res->port_id, &dev_info); 2788 if (dev_info.reta_size == 0) { 2789 printf("Redirection table size is 0 which is " 2790 "invalid for RSS\n"); 2791 return; 2792 } else 2793 printf("The reta size of port %d is %u\n", 2794 res->port_id, dev_info.reta_size); 2795 if (dev_info.reta_size > ETH_RSS_RETA_SIZE_512) { 2796 printf("Currently do not support more than %u entries of " 2797 "redirection table\n", ETH_RSS_RETA_SIZE_512); 2798 return; 2799 } 2800 2801 memset(reta_conf, 0, sizeof(reta_conf)); 2802 if (!strcmp(res->list_name, "reta")) { 2803 if (parse_reta_config(res->list_of_items, reta_conf, 2804 dev_info.reta_size)) { 2805 printf("Invalid RSS Redirection Table " 2806 "config entered\n"); 2807 return; 2808 } 2809 ret = rte_eth_dev_rss_reta_update(res->port_id, 2810 reta_conf, dev_info.reta_size); 2811 if (ret != 0) 2812 printf("Bad redirection table parameter, " 2813 "return code = %d \n", ret); 2814 } 2815 } 2816 2817 cmdline_parse_token_string_t cmd_config_rss_reta_port = 2818 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, port, "port"); 2819 cmdline_parse_token_string_t cmd_config_rss_reta_keyword = 2820 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, keyword, "config"); 2821 cmdline_parse_token_num_t cmd_config_rss_reta_port_id = 2822 TOKEN_NUM_INITIALIZER(struct cmd_config_rss_reta, port_id, UINT16); 2823 cmdline_parse_token_string_t cmd_config_rss_reta_name = 2824 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, name, "rss"); 2825 cmdline_parse_token_string_t cmd_config_rss_reta_list_name = 2826 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_name, "reta"); 2827 cmdline_parse_token_string_t cmd_config_rss_reta_list_of_items = 2828 TOKEN_STRING_INITIALIZER(struct cmd_config_rss_reta, list_of_items, 2829 NULL); 2830 cmdline_parse_inst_t cmd_config_rss_reta = { 2831 .f = cmd_set_rss_reta_parsed, 2832 .data = NULL, 2833 .help_str = "port config <port_id> rss reta <hash,queue[,hash,queue]*>", 2834 .tokens = { 2835 (void *)&cmd_config_rss_reta_port, 2836 (void *)&cmd_config_rss_reta_keyword, 2837 (void *)&cmd_config_rss_reta_port_id, 2838 (void *)&cmd_config_rss_reta_name, 2839 (void *)&cmd_config_rss_reta_list_name, 2840 (void *)&cmd_config_rss_reta_list_of_items, 2841 NULL, 2842 }, 2843 }; 2844 2845 /* *** SHOW PORT RETA INFO *** */ 2846 struct cmd_showport_reta { 2847 cmdline_fixed_string_t show; 2848 cmdline_fixed_string_t port; 2849 portid_t port_id; 2850 cmdline_fixed_string_t rss; 2851 cmdline_fixed_string_t reta; 2852 uint16_t size; 2853 cmdline_fixed_string_t list_of_items; 2854 }; 2855 2856 static int 2857 showport_parse_reta_config(struct rte_eth_rss_reta_entry64 *conf, 2858 uint16_t nb_entries, 2859 char *str) 2860 { 2861 uint32_t size; 2862 const char *p, *p0 = str; 2863 char s[256]; 2864 char *end; 2865 char *str_fld[8]; 2866 uint16_t i; 2867 uint16_t num = (nb_entries + RTE_RETA_GROUP_SIZE - 1) / 2868 RTE_RETA_GROUP_SIZE; 2869 int ret; 2870 2871 p = strchr(p0, '('); 2872 if (p == NULL) 2873 return -1; 2874 p++; 2875 p0 = strchr(p, ')'); 2876 if (p0 == NULL) 2877 return -1; 2878 size = p0 - p; 2879 if (size >= sizeof(s)) { 2880 printf("The string size exceeds the internal buffer size\n"); 2881 return -1; 2882 } 2883 snprintf(s, sizeof(s), "%.*s", size, p); 2884 ret = rte_strsplit(s, sizeof(s), str_fld, num, ','); 2885 if (ret <= 0 || ret != num) { 2886 printf("The bits of masks do not match the number of " 2887 "reta entries: %u\n", num); 2888 return -1; 2889 } 2890 for (i = 0; i < ret; i++) 2891 conf[i].mask = (uint64_t)strtoul(str_fld[i], &end, 0); 2892 2893 return 0; 2894 } 2895 2896 static void 2897 cmd_showport_reta_parsed(void *parsed_result, 2898 __attribute__((unused)) struct cmdline *cl, 2899 __attribute__((unused)) void *data) 2900 { 2901 struct cmd_showport_reta *res = parsed_result; 2902 struct rte_eth_rss_reta_entry64 reta_conf[8]; 2903 struct rte_eth_dev_info dev_info; 2904 uint16_t max_reta_size; 2905 2906 memset(&dev_info, 0, sizeof(dev_info)); 2907 rte_eth_dev_info_get(res->port_id, &dev_info); 2908 max_reta_size = RTE_MIN(dev_info.reta_size, ETH_RSS_RETA_SIZE_512); 2909 if (res->size == 0 || res->size > max_reta_size) { 2910 printf("Invalid redirection table size: %u (1-%u)\n", 2911 res->size, max_reta_size); 2912 return; 2913 } 2914 2915 memset(reta_conf, 0, sizeof(reta_conf)); 2916 if (showport_parse_reta_config(reta_conf, res->size, 2917 res->list_of_items) < 0) { 2918 printf("Invalid string: %s for reta masks\n", 2919 res->list_of_items); 2920 return; 2921 } 2922 port_rss_reta_info(res->port_id, reta_conf, res->size); 2923 } 2924 2925 cmdline_parse_token_string_t cmd_showport_reta_show = 2926 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, show, "show"); 2927 cmdline_parse_token_string_t cmd_showport_reta_port = 2928 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, port, "port"); 2929 cmdline_parse_token_num_t cmd_showport_reta_port_id = 2930 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, port_id, UINT16); 2931 cmdline_parse_token_string_t cmd_showport_reta_rss = 2932 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, rss, "rss"); 2933 cmdline_parse_token_string_t cmd_showport_reta_reta = 2934 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, reta, "reta"); 2935 cmdline_parse_token_num_t cmd_showport_reta_size = 2936 TOKEN_NUM_INITIALIZER(struct cmd_showport_reta, size, UINT16); 2937 cmdline_parse_token_string_t cmd_showport_reta_list_of_items = 2938 TOKEN_STRING_INITIALIZER(struct cmd_showport_reta, 2939 list_of_items, NULL); 2940 2941 cmdline_parse_inst_t cmd_showport_reta = { 2942 .f = cmd_showport_reta_parsed, 2943 .data = NULL, 2944 .help_str = "show port <port_id> rss reta <size> <mask0[,mask1]*>", 2945 .tokens = { 2946 (void *)&cmd_showport_reta_show, 2947 (void *)&cmd_showport_reta_port, 2948 (void *)&cmd_showport_reta_port_id, 2949 (void *)&cmd_showport_reta_rss, 2950 (void *)&cmd_showport_reta_reta, 2951 (void *)&cmd_showport_reta_size, 2952 (void *)&cmd_showport_reta_list_of_items, 2953 NULL, 2954 }, 2955 }; 2956 2957 /* *** Show RSS hash configuration *** */ 2958 struct cmd_showport_rss_hash { 2959 cmdline_fixed_string_t show; 2960 cmdline_fixed_string_t port; 2961 portid_t port_id; 2962 cmdline_fixed_string_t rss_hash; 2963 cmdline_fixed_string_t rss_type; 2964 cmdline_fixed_string_t key; /* optional argument */ 2965 }; 2966 2967 static void cmd_showport_rss_hash_parsed(void *parsed_result, 2968 __attribute__((unused)) struct cmdline *cl, 2969 void *show_rss_key) 2970 { 2971 struct cmd_showport_rss_hash *res = parsed_result; 2972 2973 port_rss_hash_conf_show(res->port_id, show_rss_key != NULL); 2974 } 2975 2976 cmdline_parse_token_string_t cmd_showport_rss_hash_show = 2977 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show"); 2978 cmdline_parse_token_string_t cmd_showport_rss_hash_port = 2979 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port"); 2980 cmdline_parse_token_num_t cmd_showport_rss_hash_port_id = 2981 TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT16); 2982 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = 2983 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash, 2984 "rss-hash"); 2985 cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = 2986 TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); 2987 2988 cmdline_parse_inst_t cmd_showport_rss_hash = { 2989 .f = cmd_showport_rss_hash_parsed, 2990 .data = NULL, 2991 .help_str = "show port <port_id> rss-hash", 2992 .tokens = { 2993 (void *)&cmd_showport_rss_hash_show, 2994 (void *)&cmd_showport_rss_hash_port, 2995 (void *)&cmd_showport_rss_hash_port_id, 2996 (void *)&cmd_showport_rss_hash_rss_hash, 2997 NULL, 2998 }, 2999 }; 3000 3001 cmdline_parse_inst_t cmd_showport_rss_hash_key = { 3002 .f = cmd_showport_rss_hash_parsed, 3003 .data = (void *)1, 3004 .help_str = "show port <port_id> rss-hash key", 3005 .tokens = { 3006 (void *)&cmd_showport_rss_hash_show, 3007 (void *)&cmd_showport_rss_hash_port, 3008 (void *)&cmd_showport_rss_hash_port_id, 3009 (void *)&cmd_showport_rss_hash_rss_hash, 3010 (void *)&cmd_showport_rss_hash_rss_key, 3011 NULL, 3012 }, 3013 }; 3014 3015 /* *** Configure DCB *** */ 3016 struct cmd_config_dcb { 3017 cmdline_fixed_string_t port; 3018 cmdline_fixed_string_t config; 3019 portid_t port_id; 3020 cmdline_fixed_string_t dcb; 3021 cmdline_fixed_string_t vt; 3022 cmdline_fixed_string_t vt_en; 3023 uint8_t num_tcs; 3024 cmdline_fixed_string_t pfc; 3025 cmdline_fixed_string_t pfc_en; 3026 }; 3027 3028 static void 3029 cmd_config_dcb_parsed(void *parsed_result, 3030 __attribute__((unused)) struct cmdline *cl, 3031 __attribute__((unused)) void *data) 3032 { 3033 struct cmd_config_dcb *res = parsed_result; 3034 portid_t port_id = res->port_id; 3035 struct rte_port *port; 3036 uint8_t pfc_en; 3037 int ret; 3038 3039 port = &ports[port_id]; 3040 /** Check if the port is not started **/ 3041 if (port->port_status != RTE_PORT_STOPPED) { 3042 printf("Please stop port %d first\n", port_id); 3043 return; 3044 } 3045 3046 if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) { 3047 printf("The invalid number of traffic class," 3048 " only 4 or 8 allowed.\n"); 3049 return; 3050 } 3051 3052 if (nb_fwd_lcores < res->num_tcs) { 3053 printf("nb_cores shouldn't be less than number of TCs.\n"); 3054 return; 3055 } 3056 if (!strncmp(res->pfc_en, "on", 2)) 3057 pfc_en = 1; 3058 else 3059 pfc_en = 0; 3060 3061 /* DCB in VT mode */ 3062 if (!strncmp(res->vt_en, "on", 2)) 3063 ret = init_port_dcb_config(port_id, DCB_VT_ENABLED, 3064 (enum rte_eth_nb_tcs)res->num_tcs, 3065 pfc_en); 3066 else 3067 ret = init_port_dcb_config(port_id, DCB_ENABLED, 3068 (enum rte_eth_nb_tcs)res->num_tcs, 3069 pfc_en); 3070 3071 3072 if (ret != 0) { 3073 printf("Cannot initialize network ports.\n"); 3074 return; 3075 } 3076 3077 cmd_reconfig_device_queue(port_id, 1, 1); 3078 } 3079 3080 cmdline_parse_token_string_t cmd_config_dcb_port = 3081 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, port, "port"); 3082 cmdline_parse_token_string_t cmd_config_dcb_config = 3083 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, config, "config"); 3084 cmdline_parse_token_num_t cmd_config_dcb_port_id = 3085 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, port_id, UINT16); 3086 cmdline_parse_token_string_t cmd_config_dcb_dcb = 3087 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, dcb, "dcb"); 3088 cmdline_parse_token_string_t cmd_config_dcb_vt = 3089 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt, "vt"); 3090 cmdline_parse_token_string_t cmd_config_dcb_vt_en = 3091 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, vt_en, "on#off"); 3092 cmdline_parse_token_num_t cmd_config_dcb_num_tcs = 3093 TOKEN_NUM_INITIALIZER(struct cmd_config_dcb, num_tcs, UINT8); 3094 cmdline_parse_token_string_t cmd_config_dcb_pfc= 3095 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc, "pfc"); 3096 cmdline_parse_token_string_t cmd_config_dcb_pfc_en = 3097 TOKEN_STRING_INITIALIZER(struct cmd_config_dcb, pfc_en, "on#off"); 3098 3099 cmdline_parse_inst_t cmd_config_dcb = { 3100 .f = cmd_config_dcb_parsed, 3101 .data = NULL, 3102 .help_str = "port config <port-id> dcb vt on|off <num_tcs> pfc on|off", 3103 .tokens = { 3104 (void *)&cmd_config_dcb_port, 3105 (void *)&cmd_config_dcb_config, 3106 (void *)&cmd_config_dcb_port_id, 3107 (void *)&cmd_config_dcb_dcb, 3108 (void *)&cmd_config_dcb_vt, 3109 (void *)&cmd_config_dcb_vt_en, 3110 (void *)&cmd_config_dcb_num_tcs, 3111 (void *)&cmd_config_dcb_pfc, 3112 (void *)&cmd_config_dcb_pfc_en, 3113 NULL, 3114 }, 3115 }; 3116 3117 /* *** configure number of packets per burst *** */ 3118 struct cmd_config_burst { 3119 cmdline_fixed_string_t port; 3120 cmdline_fixed_string_t keyword; 3121 cmdline_fixed_string_t all; 3122 cmdline_fixed_string_t name; 3123 uint16_t value; 3124 }; 3125 3126 static void 3127 cmd_config_burst_parsed(void *parsed_result, 3128 __attribute__((unused)) struct cmdline *cl, 3129 __attribute__((unused)) void *data) 3130 { 3131 struct cmd_config_burst *res = parsed_result; 3132 struct rte_eth_dev_info dev_info; 3133 uint16_t rec_nb_pkts; 3134 3135 if (!all_ports_stopped()) { 3136 printf("Please stop all ports first\n"); 3137 return; 3138 } 3139 3140 if (!strcmp(res->name, "burst")) { 3141 if (res->value == 0) { 3142 /* If user gives a value of zero, query the PMD for 3143 * its recommended Rx burst size. Testpmd uses a single 3144 * size for all ports, so assume all ports are the same 3145 * NIC model and use the values from Port 0. 3146 */ 3147 rte_eth_dev_info_get(0, &dev_info); 3148 rec_nb_pkts = dev_info.default_rxportconf.burst_size; 3149 3150 if (rec_nb_pkts == 0) { 3151 printf("PMD does not recommend a burst size.\n" 3152 "User provided value must be between" 3153 " 1 and %d\n", MAX_PKT_BURST); 3154 return; 3155 } else if (rec_nb_pkts > MAX_PKT_BURST) { 3156 printf("PMD recommended burst size of %d" 3157 " exceeds maximum value of %d\n", 3158 rec_nb_pkts, MAX_PKT_BURST); 3159 return; 3160 } 3161 printf("Using PMD-provided burst value of %d\n", 3162 rec_nb_pkts); 3163 nb_pkt_per_burst = rec_nb_pkts; 3164 } else if (res->value > MAX_PKT_BURST) { 3165 printf("burst must be >= 1 && <= %d\n", MAX_PKT_BURST); 3166 return; 3167 } else 3168 nb_pkt_per_burst = res->value; 3169 } else { 3170 printf("Unknown parameter\n"); 3171 return; 3172 } 3173 3174 init_port_config(); 3175 3176 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3177 } 3178 3179 cmdline_parse_token_string_t cmd_config_burst_port = 3180 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, port, "port"); 3181 cmdline_parse_token_string_t cmd_config_burst_keyword = 3182 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, keyword, "config"); 3183 cmdline_parse_token_string_t cmd_config_burst_all = 3184 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, all, "all"); 3185 cmdline_parse_token_string_t cmd_config_burst_name = 3186 TOKEN_STRING_INITIALIZER(struct cmd_config_burst, name, "burst"); 3187 cmdline_parse_token_num_t cmd_config_burst_value = 3188 TOKEN_NUM_INITIALIZER(struct cmd_config_burst, value, UINT16); 3189 3190 cmdline_parse_inst_t cmd_config_burst = { 3191 .f = cmd_config_burst_parsed, 3192 .data = NULL, 3193 .help_str = "port config all burst <value>", 3194 .tokens = { 3195 (void *)&cmd_config_burst_port, 3196 (void *)&cmd_config_burst_keyword, 3197 (void *)&cmd_config_burst_all, 3198 (void *)&cmd_config_burst_name, 3199 (void *)&cmd_config_burst_value, 3200 NULL, 3201 }, 3202 }; 3203 3204 /* *** configure rx/tx queues *** */ 3205 struct cmd_config_thresh { 3206 cmdline_fixed_string_t port; 3207 cmdline_fixed_string_t keyword; 3208 cmdline_fixed_string_t all; 3209 cmdline_fixed_string_t name; 3210 uint8_t value; 3211 }; 3212 3213 static void 3214 cmd_config_thresh_parsed(void *parsed_result, 3215 __attribute__((unused)) struct cmdline *cl, 3216 __attribute__((unused)) void *data) 3217 { 3218 struct cmd_config_thresh *res = parsed_result; 3219 3220 if (!all_ports_stopped()) { 3221 printf("Please stop all ports first\n"); 3222 return; 3223 } 3224 3225 if (!strcmp(res->name, "txpt")) 3226 tx_pthresh = res->value; 3227 else if(!strcmp(res->name, "txht")) 3228 tx_hthresh = res->value; 3229 else if(!strcmp(res->name, "txwt")) 3230 tx_wthresh = res->value; 3231 else if(!strcmp(res->name, "rxpt")) 3232 rx_pthresh = res->value; 3233 else if(!strcmp(res->name, "rxht")) 3234 rx_hthresh = res->value; 3235 else if(!strcmp(res->name, "rxwt")) 3236 rx_wthresh = res->value; 3237 else { 3238 printf("Unknown parameter\n"); 3239 return; 3240 } 3241 3242 init_port_config(); 3243 3244 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3245 } 3246 3247 cmdline_parse_token_string_t cmd_config_thresh_port = 3248 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, port, "port"); 3249 cmdline_parse_token_string_t cmd_config_thresh_keyword = 3250 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, keyword, "config"); 3251 cmdline_parse_token_string_t cmd_config_thresh_all = 3252 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, all, "all"); 3253 cmdline_parse_token_string_t cmd_config_thresh_name = 3254 TOKEN_STRING_INITIALIZER(struct cmd_config_thresh, name, 3255 "txpt#txht#txwt#rxpt#rxht#rxwt"); 3256 cmdline_parse_token_num_t cmd_config_thresh_value = 3257 TOKEN_NUM_INITIALIZER(struct cmd_config_thresh, value, UINT8); 3258 3259 cmdline_parse_inst_t cmd_config_thresh = { 3260 .f = cmd_config_thresh_parsed, 3261 .data = NULL, 3262 .help_str = "port config all txpt|txht|txwt|rxpt|rxht|rxwt <value>", 3263 .tokens = { 3264 (void *)&cmd_config_thresh_port, 3265 (void *)&cmd_config_thresh_keyword, 3266 (void *)&cmd_config_thresh_all, 3267 (void *)&cmd_config_thresh_name, 3268 (void *)&cmd_config_thresh_value, 3269 NULL, 3270 }, 3271 }; 3272 3273 /* *** configure free/rs threshold *** */ 3274 struct cmd_config_threshold { 3275 cmdline_fixed_string_t port; 3276 cmdline_fixed_string_t keyword; 3277 cmdline_fixed_string_t all; 3278 cmdline_fixed_string_t name; 3279 uint16_t value; 3280 }; 3281 3282 static void 3283 cmd_config_threshold_parsed(void *parsed_result, 3284 __attribute__((unused)) struct cmdline *cl, 3285 __attribute__((unused)) void *data) 3286 { 3287 struct cmd_config_threshold *res = parsed_result; 3288 3289 if (!all_ports_stopped()) { 3290 printf("Please stop all ports first\n"); 3291 return; 3292 } 3293 3294 if (!strcmp(res->name, "txfreet")) 3295 tx_free_thresh = res->value; 3296 else if (!strcmp(res->name, "txrst")) 3297 tx_rs_thresh = res->value; 3298 else if (!strcmp(res->name, "rxfreet")) 3299 rx_free_thresh = res->value; 3300 else { 3301 printf("Unknown parameter\n"); 3302 return; 3303 } 3304 3305 init_port_config(); 3306 3307 cmd_reconfig_device_queue(RTE_PORT_ALL, 1, 1); 3308 } 3309 3310 cmdline_parse_token_string_t cmd_config_threshold_port = 3311 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, port, "port"); 3312 cmdline_parse_token_string_t cmd_config_threshold_keyword = 3313 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, keyword, 3314 "config"); 3315 cmdline_parse_token_string_t cmd_config_threshold_all = 3316 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, all, "all"); 3317 cmdline_parse_token_string_t cmd_config_threshold_name = 3318 TOKEN_STRING_INITIALIZER(struct cmd_config_threshold, name, 3319 "txfreet#txrst#rxfreet"); 3320 cmdline_parse_token_num_t cmd_config_threshold_value = 3321 TOKEN_NUM_INITIALIZER(struct cmd_config_threshold, value, UINT16); 3322 3323 cmdline_parse_inst_t cmd_config_threshold = { 3324 .f = cmd_config_threshold_parsed, 3325 .data = NULL, 3326 .help_str = "port config all txfreet|txrst|rxfreet <value>", 3327 .tokens = { 3328 (void *)&cmd_config_threshold_port, 3329 (void *)&cmd_config_threshold_keyword, 3330 (void *)&cmd_config_threshold_all, 3331 (void *)&cmd_config_threshold_name, 3332 (void *)&cmd_config_threshold_value, 3333 NULL, 3334 }, 3335 }; 3336 3337 /* *** stop *** */ 3338 struct cmd_stop_result { 3339 cmdline_fixed_string_t stop; 3340 }; 3341 3342 static void cmd_stop_parsed(__attribute__((unused)) void *parsed_result, 3343 __attribute__((unused)) struct cmdline *cl, 3344 __attribute__((unused)) void *data) 3345 { 3346 stop_packet_forwarding(); 3347 } 3348 3349 cmdline_parse_token_string_t cmd_stop_stop = 3350 TOKEN_STRING_INITIALIZER(struct cmd_stop_result, stop, "stop"); 3351 3352 cmdline_parse_inst_t cmd_stop = { 3353 .f = cmd_stop_parsed, 3354 .data = NULL, 3355 .help_str = "stop: Stop packet forwarding", 3356 .tokens = { 3357 (void *)&cmd_stop_stop, 3358 NULL, 3359 }, 3360 }; 3361 3362 /* *** SET CORELIST and PORTLIST CONFIGURATION *** */ 3363 3364 unsigned int 3365 parse_item_list(char* str, const char* item_name, unsigned int max_items, 3366 unsigned int *parsed_items, int check_unique_values) 3367 { 3368 unsigned int nb_item; 3369 unsigned int value; 3370 unsigned int i; 3371 unsigned int j; 3372 int value_ok; 3373 char c; 3374 3375 /* 3376 * First parse all items in the list and store their value. 3377 */ 3378 value = 0; 3379 nb_item = 0; 3380 value_ok = 0; 3381 for (i = 0; i < strnlen(str, STR_TOKEN_SIZE); i++) { 3382 c = str[i]; 3383 if ((c >= '0') && (c <= '9')) { 3384 value = (unsigned int) (value * 10 + (c - '0')); 3385 value_ok = 1; 3386 continue; 3387 } 3388 if (c != ',') { 3389 printf("character %c is not a decimal digit\n", c); 3390 return 0; 3391 } 3392 if (! value_ok) { 3393 printf("No valid value before comma\n"); 3394 return 0; 3395 } 3396 if (nb_item < max_items) { 3397 parsed_items[nb_item] = value; 3398 value_ok = 0; 3399 value = 0; 3400 } 3401 nb_item++; 3402 } 3403 if (nb_item >= max_items) { 3404 printf("Number of %s = %u > %u (maximum items)\n", 3405 item_name, nb_item + 1, max_items); 3406 return 0; 3407 } 3408 parsed_items[nb_item++] = value; 3409 if (! check_unique_values) 3410 return nb_item; 3411 3412 /* 3413 * Then, check that all values in the list are differents. 3414 * No optimization here... 3415 */ 3416 for (i = 0; i < nb_item; i++) { 3417 for (j = i + 1; j < nb_item; j++) { 3418 if (parsed_items[j] == parsed_items[i]) { 3419 printf("duplicated %s %u at index %u and %u\n", 3420 item_name, parsed_items[i], i, j); 3421 return 0; 3422 } 3423 } 3424 } 3425 return nb_item; 3426 } 3427 3428 struct cmd_set_list_result { 3429 cmdline_fixed_string_t cmd_keyword; 3430 cmdline_fixed_string_t list_name; 3431 cmdline_fixed_string_t list_of_items; 3432 }; 3433 3434 static void cmd_set_list_parsed(void *parsed_result, 3435 __attribute__((unused)) struct cmdline *cl, 3436 __attribute__((unused)) void *data) 3437 { 3438 struct cmd_set_list_result *res; 3439 union { 3440 unsigned int lcorelist[RTE_MAX_LCORE]; 3441 unsigned int portlist[RTE_MAX_ETHPORTS]; 3442 } parsed_items; 3443 unsigned int nb_item; 3444 3445 if (test_done == 0) { 3446 printf("Please stop forwarding first\n"); 3447 return; 3448 } 3449 3450 res = parsed_result; 3451 if (!strcmp(res->list_name, "corelist")) { 3452 nb_item = parse_item_list(res->list_of_items, "core", 3453 RTE_MAX_LCORE, 3454 parsed_items.lcorelist, 1); 3455 if (nb_item > 0) { 3456 set_fwd_lcores_list(parsed_items.lcorelist, nb_item); 3457 fwd_config_setup(); 3458 } 3459 return; 3460 } 3461 if (!strcmp(res->list_name, "portlist")) { 3462 nb_item = parse_item_list(res->list_of_items, "port", 3463 RTE_MAX_ETHPORTS, 3464 parsed_items.portlist, 1); 3465 if (nb_item > 0) { 3466 set_fwd_ports_list(parsed_items.portlist, nb_item); 3467 fwd_config_setup(); 3468 } 3469 } 3470 } 3471 3472 cmdline_parse_token_string_t cmd_set_list_keyword = 3473 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, cmd_keyword, 3474 "set"); 3475 cmdline_parse_token_string_t cmd_set_list_name = 3476 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_name, 3477 "corelist#portlist"); 3478 cmdline_parse_token_string_t cmd_set_list_of_items = 3479 TOKEN_STRING_INITIALIZER(struct cmd_set_list_result, list_of_items, 3480 NULL); 3481 3482 cmdline_parse_inst_t cmd_set_fwd_list = { 3483 .f = cmd_set_list_parsed, 3484 .data = NULL, 3485 .help_str = "set corelist|portlist <list0[,list1]*>", 3486 .tokens = { 3487 (void *)&cmd_set_list_keyword, 3488 (void *)&cmd_set_list_name, 3489 (void *)&cmd_set_list_of_items, 3490 NULL, 3491 }, 3492 }; 3493 3494 /* *** SET COREMASK and PORTMASK CONFIGURATION *** */ 3495 3496 struct cmd_setmask_result { 3497 cmdline_fixed_string_t set; 3498 cmdline_fixed_string_t mask; 3499 uint64_t hexavalue; 3500 }; 3501 3502 static void cmd_set_mask_parsed(void *parsed_result, 3503 __attribute__((unused)) struct cmdline *cl, 3504 __attribute__((unused)) void *data) 3505 { 3506 struct cmd_setmask_result *res = parsed_result; 3507 3508 if (test_done == 0) { 3509 printf("Please stop forwarding first\n"); 3510 return; 3511 } 3512 if (!strcmp(res->mask, "coremask")) { 3513 set_fwd_lcores_mask(res->hexavalue); 3514 fwd_config_setup(); 3515 } else if (!strcmp(res->mask, "portmask")) { 3516 set_fwd_ports_mask(res->hexavalue); 3517 fwd_config_setup(); 3518 } 3519 } 3520 3521 cmdline_parse_token_string_t cmd_setmask_set = 3522 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, set, "set"); 3523 cmdline_parse_token_string_t cmd_setmask_mask = 3524 TOKEN_STRING_INITIALIZER(struct cmd_setmask_result, mask, 3525 "coremask#portmask"); 3526 cmdline_parse_token_num_t cmd_setmask_value = 3527 TOKEN_NUM_INITIALIZER(struct cmd_setmask_result, hexavalue, UINT64); 3528 3529 cmdline_parse_inst_t cmd_set_fwd_mask = { 3530 .f = cmd_set_mask_parsed, 3531 .data = NULL, 3532 .help_str = "set coremask|portmask <hexadecimal value>", 3533 .tokens = { 3534 (void *)&cmd_setmask_set, 3535 (void *)&cmd_setmask_mask, 3536 (void *)&cmd_setmask_value, 3537 NULL, 3538 }, 3539 }; 3540 3541 /* 3542 * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION 3543 */ 3544 struct cmd_set_result { 3545 cmdline_fixed_string_t set; 3546 cmdline_fixed_string_t what; 3547 uint16_t value; 3548 }; 3549 3550 static void cmd_set_parsed(void *parsed_result, 3551 __attribute__((unused)) struct cmdline *cl, 3552 __attribute__((unused)) void *data) 3553 { 3554 struct cmd_set_result *res = parsed_result; 3555 if (!strcmp(res->what, "nbport")) { 3556 set_fwd_ports_number(res->value); 3557 fwd_config_setup(); 3558 } else if (!strcmp(res->what, "nbcore")) { 3559 set_fwd_lcores_number(res->value); 3560 fwd_config_setup(); 3561 } else if (!strcmp(res->what, "burst")) 3562 set_nb_pkt_per_burst(res->value); 3563 else if (!strcmp(res->what, "verbose")) 3564 set_verbose_level(res->value); 3565 } 3566 3567 cmdline_parse_token_string_t cmd_set_set = 3568 TOKEN_STRING_INITIALIZER(struct cmd_set_result, set, "set"); 3569 cmdline_parse_token_string_t cmd_set_what = 3570 TOKEN_STRING_INITIALIZER(struct cmd_set_result, what, 3571 "nbport#nbcore#burst#verbose"); 3572 cmdline_parse_token_num_t cmd_set_value = 3573 TOKEN_NUM_INITIALIZER(struct cmd_set_result, value, UINT16); 3574 3575 cmdline_parse_inst_t cmd_set_numbers = { 3576 .f = cmd_set_parsed, 3577 .data = NULL, 3578 .help_str = "set nbport|nbcore|burst|verbose <value>", 3579 .tokens = { 3580 (void *)&cmd_set_set, 3581 (void *)&cmd_set_what, 3582 (void *)&cmd_set_value, 3583 NULL, 3584 }, 3585 }; 3586 3587 /* *** SET LOG LEVEL CONFIGURATION *** */ 3588 3589 struct cmd_set_log_result { 3590 cmdline_fixed_string_t set; 3591 cmdline_fixed_string_t log; 3592 cmdline_fixed_string_t type; 3593 uint32_t level; 3594 }; 3595 3596 static void 3597 cmd_set_log_parsed(void *parsed_result, 3598 __attribute__((unused)) struct cmdline *cl, 3599 __attribute__((unused)) void *data) 3600 { 3601 struct cmd_set_log_result *res; 3602 int ret; 3603 3604 res = parsed_result; 3605 if (!strcmp(res->type, "global")) 3606 rte_log_set_global_level(res->level); 3607 else { 3608 ret = rte_log_set_level_regexp(res->type, res->level); 3609 if (ret < 0) 3610 printf("Unable to set log level\n"); 3611 } 3612 } 3613 3614 cmdline_parse_token_string_t cmd_set_log_set = 3615 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, set, "set"); 3616 cmdline_parse_token_string_t cmd_set_log_log = 3617 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, log, "log"); 3618 cmdline_parse_token_string_t cmd_set_log_type = 3619 TOKEN_STRING_INITIALIZER(struct cmd_set_log_result, type, NULL); 3620 cmdline_parse_token_num_t cmd_set_log_level = 3621 TOKEN_NUM_INITIALIZER(struct cmd_set_log_result, level, UINT32); 3622 3623 cmdline_parse_inst_t cmd_set_log = { 3624 .f = cmd_set_log_parsed, 3625 .data = NULL, 3626 .help_str = "set log global|<type> <level>", 3627 .tokens = { 3628 (void *)&cmd_set_log_set, 3629 (void *)&cmd_set_log_log, 3630 (void *)&cmd_set_log_type, 3631 (void *)&cmd_set_log_level, 3632 NULL, 3633 }, 3634 }; 3635 3636 /* *** SET SEGMENT LENGTHS OF TXONLY PACKETS *** */ 3637 3638 struct cmd_set_txpkts_result { 3639 cmdline_fixed_string_t cmd_keyword; 3640 cmdline_fixed_string_t txpkts; 3641 cmdline_fixed_string_t seg_lengths; 3642 }; 3643 3644 static void 3645 cmd_set_txpkts_parsed(void *parsed_result, 3646 __attribute__((unused)) struct cmdline *cl, 3647 __attribute__((unused)) void *data) 3648 { 3649 struct cmd_set_txpkts_result *res; 3650 unsigned seg_lengths[RTE_MAX_SEGS_PER_PKT]; 3651 unsigned int nb_segs; 3652 3653 res = parsed_result; 3654 nb_segs = parse_item_list(res->seg_lengths, "segment lengths", 3655 RTE_MAX_SEGS_PER_PKT, seg_lengths, 0); 3656 if (nb_segs > 0) 3657 set_tx_pkt_segments(seg_lengths, nb_segs); 3658 } 3659 3660 cmdline_parse_token_string_t cmd_set_txpkts_keyword = 3661 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3662 cmd_keyword, "set"); 3663 cmdline_parse_token_string_t cmd_set_txpkts_name = 3664 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3665 txpkts, "txpkts"); 3666 cmdline_parse_token_string_t cmd_set_txpkts_lengths = 3667 TOKEN_STRING_INITIALIZER(struct cmd_set_txpkts_result, 3668 seg_lengths, NULL); 3669 3670 cmdline_parse_inst_t cmd_set_txpkts = { 3671 .f = cmd_set_txpkts_parsed, 3672 .data = NULL, 3673 .help_str = "set txpkts <len0[,len1]*>", 3674 .tokens = { 3675 (void *)&cmd_set_txpkts_keyword, 3676 (void *)&cmd_set_txpkts_name, 3677 (void *)&cmd_set_txpkts_lengths, 3678 NULL, 3679 }, 3680 }; 3681 3682 /* *** SET COPY AND SPLIT POLICY ON TX PACKETS *** */ 3683 3684 struct cmd_set_txsplit_result { 3685 cmdline_fixed_string_t cmd_keyword; 3686 cmdline_fixed_string_t txsplit; 3687 cmdline_fixed_string_t mode; 3688 }; 3689 3690 static void 3691 cmd_set_txsplit_parsed(void *parsed_result, 3692 __attribute__((unused)) struct cmdline *cl, 3693 __attribute__((unused)) void *data) 3694 { 3695 struct cmd_set_txsplit_result *res; 3696 3697 res = parsed_result; 3698 set_tx_pkt_split(res->mode); 3699 } 3700 3701 cmdline_parse_token_string_t cmd_set_txsplit_keyword = 3702 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3703 cmd_keyword, "set"); 3704 cmdline_parse_token_string_t cmd_set_txsplit_name = 3705 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3706 txsplit, "txsplit"); 3707 cmdline_parse_token_string_t cmd_set_txsplit_mode = 3708 TOKEN_STRING_INITIALIZER(struct cmd_set_txsplit_result, 3709 mode, NULL); 3710 3711 cmdline_parse_inst_t cmd_set_txsplit = { 3712 .f = cmd_set_txsplit_parsed, 3713 .data = NULL, 3714 .help_str = "set txsplit on|off|rand", 3715 .tokens = { 3716 (void *)&cmd_set_txsplit_keyword, 3717 (void *)&cmd_set_txsplit_name, 3718 (void *)&cmd_set_txsplit_mode, 3719 NULL, 3720 }, 3721 }; 3722 3723 /* *** ADD/REMOVE ALL VLAN IDENTIFIERS TO/FROM A PORT VLAN RX FILTER *** */ 3724 struct cmd_rx_vlan_filter_all_result { 3725 cmdline_fixed_string_t rx_vlan; 3726 cmdline_fixed_string_t what; 3727 cmdline_fixed_string_t all; 3728 portid_t port_id; 3729 }; 3730 3731 static void 3732 cmd_rx_vlan_filter_all_parsed(void *parsed_result, 3733 __attribute__((unused)) struct cmdline *cl, 3734 __attribute__((unused)) void *data) 3735 { 3736 struct cmd_rx_vlan_filter_all_result *res = parsed_result; 3737 3738 if (!strcmp(res->what, "add")) 3739 rx_vlan_all_filter_set(res->port_id, 1); 3740 else 3741 rx_vlan_all_filter_set(res->port_id, 0); 3742 } 3743 3744 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_rx_vlan = 3745 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3746 rx_vlan, "rx_vlan"); 3747 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_what = 3748 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3749 what, "add#rm"); 3750 cmdline_parse_token_string_t cmd_rx_vlan_filter_all_all = 3751 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3752 all, "all"); 3753 cmdline_parse_token_num_t cmd_rx_vlan_filter_all_portid = 3754 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_all_result, 3755 port_id, UINT16); 3756 3757 cmdline_parse_inst_t cmd_rx_vlan_filter_all = { 3758 .f = cmd_rx_vlan_filter_all_parsed, 3759 .data = NULL, 3760 .help_str = "rx_vlan add|rm all <port_id>: " 3761 "Add/Remove all identifiers to/from the set of VLAN " 3762 "identifiers filtered by a port", 3763 .tokens = { 3764 (void *)&cmd_rx_vlan_filter_all_rx_vlan, 3765 (void *)&cmd_rx_vlan_filter_all_what, 3766 (void *)&cmd_rx_vlan_filter_all_all, 3767 (void *)&cmd_rx_vlan_filter_all_portid, 3768 NULL, 3769 }, 3770 }; 3771 3772 /* *** VLAN OFFLOAD SET ON A PORT *** */ 3773 struct cmd_vlan_offload_result { 3774 cmdline_fixed_string_t vlan; 3775 cmdline_fixed_string_t set; 3776 cmdline_fixed_string_t vlan_type; 3777 cmdline_fixed_string_t what; 3778 cmdline_fixed_string_t on; 3779 cmdline_fixed_string_t port_id; 3780 }; 3781 3782 static void 3783 cmd_vlan_offload_parsed(void *parsed_result, 3784 __attribute__((unused)) struct cmdline *cl, 3785 __attribute__((unused)) void *data) 3786 { 3787 int on; 3788 struct cmd_vlan_offload_result *res = parsed_result; 3789 char *str; 3790 int i, len = 0; 3791 portid_t port_id = 0; 3792 unsigned int tmp; 3793 3794 str = res->port_id; 3795 len = strnlen(str, STR_TOKEN_SIZE); 3796 i = 0; 3797 /* Get port_id first */ 3798 while(i < len){ 3799 if(str[i] == ',') 3800 break; 3801 3802 i++; 3803 } 3804 str[i]='\0'; 3805 tmp = strtoul(str, NULL, 0); 3806 /* If port_id greater that what portid_t can represent, return */ 3807 if(tmp >= RTE_MAX_ETHPORTS) 3808 return; 3809 port_id = (portid_t)tmp; 3810 3811 if (!strcmp(res->on, "on")) 3812 on = 1; 3813 else 3814 on = 0; 3815 3816 if (!strcmp(res->what, "strip")) 3817 rx_vlan_strip_set(port_id, on); 3818 else if(!strcmp(res->what, "stripq")){ 3819 uint16_t queue_id = 0; 3820 3821 /* No queue_id, return */ 3822 if(i + 1 >= len) { 3823 printf("must specify (port,queue_id)\n"); 3824 return; 3825 } 3826 tmp = strtoul(str + i + 1, NULL, 0); 3827 /* If queue_id greater that what 16-bits can represent, return */ 3828 if(tmp > 0xffff) 3829 return; 3830 3831 queue_id = (uint16_t)tmp; 3832 rx_vlan_strip_set_on_queue(port_id, queue_id, on); 3833 } 3834 else if (!strcmp(res->what, "filter")) 3835 rx_vlan_filter_set(port_id, on); 3836 else 3837 vlan_extend_set(port_id, on); 3838 3839 return; 3840 } 3841 3842 cmdline_parse_token_string_t cmd_vlan_offload_vlan = 3843 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3844 vlan, "vlan"); 3845 cmdline_parse_token_string_t cmd_vlan_offload_set = 3846 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3847 set, "set"); 3848 cmdline_parse_token_string_t cmd_vlan_offload_what = 3849 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3850 what, "strip#filter#qinq#stripq"); 3851 cmdline_parse_token_string_t cmd_vlan_offload_on = 3852 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3853 on, "on#off"); 3854 cmdline_parse_token_string_t cmd_vlan_offload_portid = 3855 TOKEN_STRING_INITIALIZER(struct cmd_vlan_offload_result, 3856 port_id, NULL); 3857 3858 cmdline_parse_inst_t cmd_vlan_offload = { 3859 .f = cmd_vlan_offload_parsed, 3860 .data = NULL, 3861 .help_str = "vlan set strip|filter|qinq|stripq on|off " 3862 "<port_id[,queue_id]>: " 3863 "Filter/Strip for rx side qinq(extended) for both rx/tx sides", 3864 .tokens = { 3865 (void *)&cmd_vlan_offload_vlan, 3866 (void *)&cmd_vlan_offload_set, 3867 (void *)&cmd_vlan_offload_what, 3868 (void *)&cmd_vlan_offload_on, 3869 (void *)&cmd_vlan_offload_portid, 3870 NULL, 3871 }, 3872 }; 3873 3874 /* *** VLAN TPID SET ON A PORT *** */ 3875 struct cmd_vlan_tpid_result { 3876 cmdline_fixed_string_t vlan; 3877 cmdline_fixed_string_t set; 3878 cmdline_fixed_string_t vlan_type; 3879 cmdline_fixed_string_t what; 3880 uint16_t tp_id; 3881 portid_t port_id; 3882 }; 3883 3884 static void 3885 cmd_vlan_tpid_parsed(void *parsed_result, 3886 __attribute__((unused)) struct cmdline *cl, 3887 __attribute__((unused)) void *data) 3888 { 3889 struct cmd_vlan_tpid_result *res = parsed_result; 3890 enum rte_vlan_type vlan_type; 3891 3892 if (!strcmp(res->vlan_type, "inner")) 3893 vlan_type = ETH_VLAN_TYPE_INNER; 3894 else if (!strcmp(res->vlan_type, "outer")) 3895 vlan_type = ETH_VLAN_TYPE_OUTER; 3896 else { 3897 printf("Unknown vlan type\n"); 3898 return; 3899 } 3900 vlan_tpid_set(res->port_id, vlan_type, res->tp_id); 3901 } 3902 3903 cmdline_parse_token_string_t cmd_vlan_tpid_vlan = 3904 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3905 vlan, "vlan"); 3906 cmdline_parse_token_string_t cmd_vlan_tpid_set = 3907 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3908 set, "set"); 3909 cmdline_parse_token_string_t cmd_vlan_type = 3910 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3911 vlan_type, "inner#outer"); 3912 cmdline_parse_token_string_t cmd_vlan_tpid_what = 3913 TOKEN_STRING_INITIALIZER(struct cmd_vlan_tpid_result, 3914 what, "tpid"); 3915 cmdline_parse_token_num_t cmd_vlan_tpid_tpid = 3916 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 3917 tp_id, UINT16); 3918 cmdline_parse_token_num_t cmd_vlan_tpid_portid = 3919 TOKEN_NUM_INITIALIZER(struct cmd_vlan_tpid_result, 3920 port_id, UINT16); 3921 3922 cmdline_parse_inst_t cmd_vlan_tpid = { 3923 .f = cmd_vlan_tpid_parsed, 3924 .data = NULL, 3925 .help_str = "vlan set inner|outer tpid <tp_id> <port_id>: " 3926 "Set the VLAN Ether type", 3927 .tokens = { 3928 (void *)&cmd_vlan_tpid_vlan, 3929 (void *)&cmd_vlan_tpid_set, 3930 (void *)&cmd_vlan_type, 3931 (void *)&cmd_vlan_tpid_what, 3932 (void *)&cmd_vlan_tpid_tpid, 3933 (void *)&cmd_vlan_tpid_portid, 3934 NULL, 3935 }, 3936 }; 3937 3938 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 3939 struct cmd_rx_vlan_filter_result { 3940 cmdline_fixed_string_t rx_vlan; 3941 cmdline_fixed_string_t what; 3942 uint16_t vlan_id; 3943 portid_t port_id; 3944 }; 3945 3946 static void 3947 cmd_rx_vlan_filter_parsed(void *parsed_result, 3948 __attribute__((unused)) struct cmdline *cl, 3949 __attribute__((unused)) void *data) 3950 { 3951 struct cmd_rx_vlan_filter_result *res = parsed_result; 3952 3953 if (!strcmp(res->what, "add")) 3954 rx_vft_set(res->port_id, res->vlan_id, 1); 3955 else 3956 rx_vft_set(res->port_id, res->vlan_id, 0); 3957 } 3958 3959 cmdline_parse_token_string_t cmd_rx_vlan_filter_rx_vlan = 3960 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 3961 rx_vlan, "rx_vlan"); 3962 cmdline_parse_token_string_t cmd_rx_vlan_filter_what = 3963 TOKEN_STRING_INITIALIZER(struct cmd_rx_vlan_filter_result, 3964 what, "add#rm"); 3965 cmdline_parse_token_num_t cmd_rx_vlan_filter_vlanid = 3966 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 3967 vlan_id, UINT16); 3968 cmdline_parse_token_num_t cmd_rx_vlan_filter_portid = 3969 TOKEN_NUM_INITIALIZER(struct cmd_rx_vlan_filter_result, 3970 port_id, UINT16); 3971 3972 cmdline_parse_inst_t cmd_rx_vlan_filter = { 3973 .f = cmd_rx_vlan_filter_parsed, 3974 .data = NULL, 3975 .help_str = "rx_vlan add|rm <vlan_id> <port_id>: " 3976 "Add/Remove a VLAN identifier to/from the set of VLAN " 3977 "identifiers filtered by a port", 3978 .tokens = { 3979 (void *)&cmd_rx_vlan_filter_rx_vlan, 3980 (void *)&cmd_rx_vlan_filter_what, 3981 (void *)&cmd_rx_vlan_filter_vlanid, 3982 (void *)&cmd_rx_vlan_filter_portid, 3983 NULL, 3984 }, 3985 }; 3986 3987 /* *** ENABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 3988 struct cmd_tx_vlan_set_result { 3989 cmdline_fixed_string_t tx_vlan; 3990 cmdline_fixed_string_t set; 3991 portid_t port_id; 3992 uint16_t vlan_id; 3993 }; 3994 3995 static void 3996 cmd_tx_vlan_set_parsed(void *parsed_result, 3997 __attribute__((unused)) struct cmdline *cl, 3998 __attribute__((unused)) void *data) 3999 { 4000 struct cmd_tx_vlan_set_result *res = parsed_result; 4001 4002 if (!port_is_stopped(res->port_id)) { 4003 printf("Please stop port %d first\n", res->port_id); 4004 return; 4005 } 4006 4007 tx_vlan_set(res->port_id, res->vlan_id); 4008 4009 cmd_reconfig_device_queue(res->port_id, 1, 1); 4010 } 4011 4012 cmdline_parse_token_string_t cmd_tx_vlan_set_tx_vlan = 4013 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4014 tx_vlan, "tx_vlan"); 4015 cmdline_parse_token_string_t cmd_tx_vlan_set_set = 4016 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_result, 4017 set, "set"); 4018 cmdline_parse_token_num_t cmd_tx_vlan_set_portid = 4019 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4020 port_id, UINT16); 4021 cmdline_parse_token_num_t cmd_tx_vlan_set_vlanid = 4022 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_result, 4023 vlan_id, UINT16); 4024 4025 cmdline_parse_inst_t cmd_tx_vlan_set = { 4026 .f = cmd_tx_vlan_set_parsed, 4027 .data = NULL, 4028 .help_str = "tx_vlan set <port_id> <vlan_id>: " 4029 "Enable hardware insertion of a single VLAN header " 4030 "with a given TAG Identifier in packets sent on a port", 4031 .tokens = { 4032 (void *)&cmd_tx_vlan_set_tx_vlan, 4033 (void *)&cmd_tx_vlan_set_set, 4034 (void *)&cmd_tx_vlan_set_portid, 4035 (void *)&cmd_tx_vlan_set_vlanid, 4036 NULL, 4037 }, 4038 }; 4039 4040 /* *** ENABLE HARDWARE INSERTION OF Double VLAN HEADER IN TX PACKETS *** */ 4041 struct cmd_tx_vlan_set_qinq_result { 4042 cmdline_fixed_string_t tx_vlan; 4043 cmdline_fixed_string_t set; 4044 portid_t port_id; 4045 uint16_t vlan_id; 4046 uint16_t vlan_id_outer; 4047 }; 4048 4049 static void 4050 cmd_tx_vlan_set_qinq_parsed(void *parsed_result, 4051 __attribute__((unused)) struct cmdline *cl, 4052 __attribute__((unused)) void *data) 4053 { 4054 struct cmd_tx_vlan_set_qinq_result *res = parsed_result; 4055 4056 if (!port_is_stopped(res->port_id)) { 4057 printf("Please stop port %d first\n", res->port_id); 4058 return; 4059 } 4060 4061 tx_qinq_set(res->port_id, res->vlan_id, res->vlan_id_outer); 4062 4063 cmd_reconfig_device_queue(res->port_id, 1, 1); 4064 } 4065 4066 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_tx_vlan = 4067 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4068 tx_vlan, "tx_vlan"); 4069 cmdline_parse_token_string_t cmd_tx_vlan_set_qinq_set = 4070 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4071 set, "set"); 4072 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_portid = 4073 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4074 port_id, UINT16); 4075 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid = 4076 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4077 vlan_id, UINT16); 4078 cmdline_parse_token_num_t cmd_tx_vlan_set_qinq_vlanid_outer = 4079 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_qinq_result, 4080 vlan_id_outer, UINT16); 4081 4082 cmdline_parse_inst_t cmd_tx_vlan_set_qinq = { 4083 .f = cmd_tx_vlan_set_qinq_parsed, 4084 .data = NULL, 4085 .help_str = "tx_vlan set <port_id> <vlan_id> <outer_vlan_id>: " 4086 "Enable hardware insertion of double VLAN header " 4087 "with given TAG Identifiers in packets sent on a port", 4088 .tokens = { 4089 (void *)&cmd_tx_vlan_set_qinq_tx_vlan, 4090 (void *)&cmd_tx_vlan_set_qinq_set, 4091 (void *)&cmd_tx_vlan_set_qinq_portid, 4092 (void *)&cmd_tx_vlan_set_qinq_vlanid, 4093 (void *)&cmd_tx_vlan_set_qinq_vlanid_outer, 4094 NULL, 4095 }, 4096 }; 4097 4098 /* *** ENABLE/DISABLE PORT BASED TX VLAN INSERTION *** */ 4099 struct cmd_tx_vlan_set_pvid_result { 4100 cmdline_fixed_string_t tx_vlan; 4101 cmdline_fixed_string_t set; 4102 cmdline_fixed_string_t pvid; 4103 portid_t port_id; 4104 uint16_t vlan_id; 4105 cmdline_fixed_string_t mode; 4106 }; 4107 4108 static void 4109 cmd_tx_vlan_set_pvid_parsed(void *parsed_result, 4110 __attribute__((unused)) struct cmdline *cl, 4111 __attribute__((unused)) void *data) 4112 { 4113 struct cmd_tx_vlan_set_pvid_result *res = parsed_result; 4114 4115 if (strcmp(res->mode, "on") == 0) 4116 tx_vlan_pvid_set(res->port_id, res->vlan_id, 1); 4117 else 4118 tx_vlan_pvid_set(res->port_id, res->vlan_id, 0); 4119 } 4120 4121 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_tx_vlan = 4122 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4123 tx_vlan, "tx_vlan"); 4124 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_set = 4125 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4126 set, "set"); 4127 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_pvid = 4128 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4129 pvid, "pvid"); 4130 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_port_id = 4131 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4132 port_id, UINT16); 4133 cmdline_parse_token_num_t cmd_tx_vlan_set_pvid_vlan_id = 4134 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4135 vlan_id, UINT16); 4136 cmdline_parse_token_string_t cmd_tx_vlan_set_pvid_mode = 4137 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_set_pvid_result, 4138 mode, "on#off"); 4139 4140 cmdline_parse_inst_t cmd_tx_vlan_set_pvid = { 4141 .f = cmd_tx_vlan_set_pvid_parsed, 4142 .data = NULL, 4143 .help_str = "tx_vlan set pvid <port_id> <vlan_id> on|off", 4144 .tokens = { 4145 (void *)&cmd_tx_vlan_set_pvid_tx_vlan, 4146 (void *)&cmd_tx_vlan_set_pvid_set, 4147 (void *)&cmd_tx_vlan_set_pvid_pvid, 4148 (void *)&cmd_tx_vlan_set_pvid_port_id, 4149 (void *)&cmd_tx_vlan_set_pvid_vlan_id, 4150 (void *)&cmd_tx_vlan_set_pvid_mode, 4151 NULL, 4152 }, 4153 }; 4154 4155 /* *** DISABLE HARDWARE INSERTION OF VLAN HEADER IN TX PACKETS *** */ 4156 struct cmd_tx_vlan_reset_result { 4157 cmdline_fixed_string_t tx_vlan; 4158 cmdline_fixed_string_t reset; 4159 portid_t port_id; 4160 }; 4161 4162 static void 4163 cmd_tx_vlan_reset_parsed(void *parsed_result, 4164 __attribute__((unused)) struct cmdline *cl, 4165 __attribute__((unused)) void *data) 4166 { 4167 struct cmd_tx_vlan_reset_result *res = parsed_result; 4168 4169 if (!port_is_stopped(res->port_id)) { 4170 printf("Please stop port %d first\n", res->port_id); 4171 return; 4172 } 4173 4174 tx_vlan_reset(res->port_id); 4175 4176 cmd_reconfig_device_queue(res->port_id, 1, 1); 4177 } 4178 4179 cmdline_parse_token_string_t cmd_tx_vlan_reset_tx_vlan = 4180 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4181 tx_vlan, "tx_vlan"); 4182 cmdline_parse_token_string_t cmd_tx_vlan_reset_reset = 4183 TOKEN_STRING_INITIALIZER(struct cmd_tx_vlan_reset_result, 4184 reset, "reset"); 4185 cmdline_parse_token_num_t cmd_tx_vlan_reset_portid = 4186 TOKEN_NUM_INITIALIZER(struct cmd_tx_vlan_reset_result, 4187 port_id, UINT16); 4188 4189 cmdline_parse_inst_t cmd_tx_vlan_reset = { 4190 .f = cmd_tx_vlan_reset_parsed, 4191 .data = NULL, 4192 .help_str = "tx_vlan reset <port_id>: Disable hardware insertion of a " 4193 "VLAN header in packets sent on a port", 4194 .tokens = { 4195 (void *)&cmd_tx_vlan_reset_tx_vlan, 4196 (void *)&cmd_tx_vlan_reset_reset, 4197 (void *)&cmd_tx_vlan_reset_portid, 4198 NULL, 4199 }, 4200 }; 4201 4202 4203 /* *** ENABLE HARDWARE INSERTION OF CHECKSUM IN TX PACKETS *** */ 4204 struct cmd_csum_result { 4205 cmdline_fixed_string_t csum; 4206 cmdline_fixed_string_t mode; 4207 cmdline_fixed_string_t proto; 4208 cmdline_fixed_string_t hwsw; 4209 portid_t port_id; 4210 }; 4211 4212 static void 4213 csum_show(int port_id) 4214 { 4215 struct rte_eth_dev_info dev_info; 4216 uint64_t tx_offloads; 4217 4218 tx_offloads = ports[port_id].dev_conf.txmode.offloads; 4219 printf("Parse tunnel is %s\n", 4220 (ports[port_id].parse_tunnel) ? "on" : "off"); 4221 printf("IP checksum offload is %s\n", 4222 (tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ? "hw" : "sw"); 4223 printf("UDP checksum offload is %s\n", 4224 (tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) ? "hw" : "sw"); 4225 printf("TCP checksum offload is %s\n", 4226 (tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ? "hw" : "sw"); 4227 printf("SCTP checksum offload is %s\n", 4228 (tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) ? "hw" : "sw"); 4229 printf("Outer-Ip checksum offload is %s\n", 4230 (tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ? "hw" : "sw"); 4231 printf("Outer-Udp checksum offload is %s\n", 4232 (tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) ? "hw" : "sw"); 4233 4234 /* display warnings if configuration is not supported by the NIC */ 4235 rte_eth_dev_info_get(port_id, &dev_info); 4236 if ((tx_offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) && 4237 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) == 0) { 4238 printf("Warning: hardware IP checksum enabled but not " 4239 "supported by port %d\n", port_id); 4240 } 4241 if ((tx_offloads & DEV_TX_OFFLOAD_UDP_CKSUM) && 4242 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) == 0) { 4243 printf("Warning: hardware UDP checksum enabled but not " 4244 "supported by port %d\n", port_id); 4245 } 4246 if ((tx_offloads & DEV_TX_OFFLOAD_TCP_CKSUM) && 4247 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) { 4248 printf("Warning: hardware TCP checksum enabled but not " 4249 "supported by port %d\n", port_id); 4250 } 4251 if ((tx_offloads & DEV_TX_OFFLOAD_SCTP_CKSUM) && 4252 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) == 0) { 4253 printf("Warning: hardware SCTP checksum enabled but not " 4254 "supported by port %d\n", port_id); 4255 } 4256 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) && 4257 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) == 0) { 4258 printf("Warning: hardware outer IP checksum enabled but not " 4259 "supported by port %d\n", port_id); 4260 } 4261 if ((tx_offloads & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) && 4262 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) 4263 == 0) { 4264 printf("Warning: hardware outer UDP checksum enabled but not " 4265 "supported by port %d\n", port_id); 4266 } 4267 } 4268 4269 static void 4270 cmd_csum_parsed(void *parsed_result, 4271 __attribute__((unused)) struct cmdline *cl, 4272 __attribute__((unused)) void *data) 4273 { 4274 struct cmd_csum_result *res = parsed_result; 4275 int hw = 0; 4276 uint64_t csum_offloads = 0; 4277 struct rte_eth_dev_info dev_info; 4278 4279 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) { 4280 printf("invalid port %d\n", res->port_id); 4281 return; 4282 } 4283 if (!port_is_stopped(res->port_id)) { 4284 printf("Please stop port %d first\n", res->port_id); 4285 return; 4286 } 4287 4288 rte_eth_dev_info_get(res->port_id, &dev_info); 4289 if (!strcmp(res->mode, "set")) { 4290 4291 if (!strcmp(res->hwsw, "hw")) 4292 hw = 1; 4293 4294 if (!strcmp(res->proto, "ip")) { 4295 if (hw == 0 || (dev_info.tx_offload_capa & 4296 DEV_TX_OFFLOAD_IPV4_CKSUM)) { 4297 csum_offloads |= DEV_TX_OFFLOAD_IPV4_CKSUM; 4298 } else { 4299 printf("IP checksum offload is not supported " 4300 "by port %u\n", res->port_id); 4301 } 4302 } else if (!strcmp(res->proto, "udp")) { 4303 if (hw == 0 || (dev_info.tx_offload_capa & 4304 DEV_TX_OFFLOAD_UDP_CKSUM)) { 4305 csum_offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; 4306 } else { 4307 printf("UDP checksum offload is not supported " 4308 "by port %u\n", res->port_id); 4309 } 4310 } else if (!strcmp(res->proto, "tcp")) { 4311 if (hw == 0 || (dev_info.tx_offload_capa & 4312 DEV_TX_OFFLOAD_TCP_CKSUM)) { 4313 csum_offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; 4314 } else { 4315 printf("TCP checksum offload is not supported " 4316 "by port %u\n", res->port_id); 4317 } 4318 } else if (!strcmp(res->proto, "sctp")) { 4319 if (hw == 0 || (dev_info.tx_offload_capa & 4320 DEV_TX_OFFLOAD_SCTP_CKSUM)) { 4321 csum_offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; 4322 } else { 4323 printf("SCTP checksum offload is not supported " 4324 "by port %u\n", res->port_id); 4325 } 4326 } else if (!strcmp(res->proto, "outer-ip")) { 4327 if (hw == 0 || (dev_info.tx_offload_capa & 4328 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) { 4329 csum_offloads |= 4330 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; 4331 } else { 4332 printf("Outer IP checksum offload is not " 4333 "supported by port %u\n", res->port_id); 4334 } 4335 } else if (!strcmp(res->proto, "outer-udp")) { 4336 if (hw == 0 || (dev_info.tx_offload_capa & 4337 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)) { 4338 csum_offloads |= 4339 DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; 4340 } else { 4341 printf("Outer UDP checksum offload is not " 4342 "supported by port %u\n", res->port_id); 4343 } 4344 } 4345 4346 if (hw) { 4347 ports[res->port_id].dev_conf.txmode.offloads |= 4348 csum_offloads; 4349 } else { 4350 ports[res->port_id].dev_conf.txmode.offloads &= 4351 (~csum_offloads); 4352 } 4353 } 4354 csum_show(res->port_id); 4355 4356 cmd_reconfig_device_queue(res->port_id, 1, 1); 4357 } 4358 4359 cmdline_parse_token_string_t cmd_csum_csum = 4360 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4361 csum, "csum"); 4362 cmdline_parse_token_string_t cmd_csum_mode = 4363 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4364 mode, "set"); 4365 cmdline_parse_token_string_t cmd_csum_proto = 4366 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4367 proto, "ip#tcp#udp#sctp#outer-ip#outer-udp"); 4368 cmdline_parse_token_string_t cmd_csum_hwsw = 4369 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4370 hwsw, "hw#sw"); 4371 cmdline_parse_token_num_t cmd_csum_portid = 4372 TOKEN_NUM_INITIALIZER(struct cmd_csum_result, 4373 port_id, UINT16); 4374 4375 cmdline_parse_inst_t cmd_csum_set = { 4376 .f = cmd_csum_parsed, 4377 .data = NULL, 4378 .help_str = "csum set ip|tcp|udp|sctp|outer-ip|outer-udp hw|sw <port_id>: " 4379 "Enable/Disable hardware calculation of L3/L4 checksum when " 4380 "using csum forward engine", 4381 .tokens = { 4382 (void *)&cmd_csum_csum, 4383 (void *)&cmd_csum_mode, 4384 (void *)&cmd_csum_proto, 4385 (void *)&cmd_csum_hwsw, 4386 (void *)&cmd_csum_portid, 4387 NULL, 4388 }, 4389 }; 4390 4391 cmdline_parse_token_string_t cmd_csum_mode_show = 4392 TOKEN_STRING_INITIALIZER(struct cmd_csum_result, 4393 mode, "show"); 4394 4395 cmdline_parse_inst_t cmd_csum_show = { 4396 .f = cmd_csum_parsed, 4397 .data = NULL, 4398 .help_str = "csum show <port_id>: Show checksum offload configuration", 4399 .tokens = { 4400 (void *)&cmd_csum_csum, 4401 (void *)&cmd_csum_mode_show, 4402 (void *)&cmd_csum_portid, 4403 NULL, 4404 }, 4405 }; 4406 4407 /* Enable/disable tunnel parsing */ 4408 struct cmd_csum_tunnel_result { 4409 cmdline_fixed_string_t csum; 4410 cmdline_fixed_string_t parse; 4411 cmdline_fixed_string_t onoff; 4412 portid_t port_id; 4413 }; 4414 4415 static void 4416 cmd_csum_tunnel_parsed(void *parsed_result, 4417 __attribute__((unused)) struct cmdline *cl, 4418 __attribute__((unused)) void *data) 4419 { 4420 struct cmd_csum_tunnel_result *res = parsed_result; 4421 4422 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4423 return; 4424 4425 if (!strcmp(res->onoff, "on")) 4426 ports[res->port_id].parse_tunnel = 1; 4427 else 4428 ports[res->port_id].parse_tunnel = 0; 4429 4430 csum_show(res->port_id); 4431 } 4432 4433 cmdline_parse_token_string_t cmd_csum_tunnel_csum = 4434 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4435 csum, "csum"); 4436 cmdline_parse_token_string_t cmd_csum_tunnel_parse = 4437 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4438 parse, "parse-tunnel"); 4439 cmdline_parse_token_string_t cmd_csum_tunnel_onoff = 4440 TOKEN_STRING_INITIALIZER(struct cmd_csum_tunnel_result, 4441 onoff, "on#off"); 4442 cmdline_parse_token_num_t cmd_csum_tunnel_portid = 4443 TOKEN_NUM_INITIALIZER(struct cmd_csum_tunnel_result, 4444 port_id, UINT16); 4445 4446 cmdline_parse_inst_t cmd_csum_tunnel = { 4447 .f = cmd_csum_tunnel_parsed, 4448 .data = NULL, 4449 .help_str = "csum parse-tunnel on|off <port_id>: " 4450 "Enable/Disable parsing of tunnels for csum engine", 4451 .tokens = { 4452 (void *)&cmd_csum_tunnel_csum, 4453 (void *)&cmd_csum_tunnel_parse, 4454 (void *)&cmd_csum_tunnel_onoff, 4455 (void *)&cmd_csum_tunnel_portid, 4456 NULL, 4457 }, 4458 }; 4459 4460 /* *** ENABLE HARDWARE SEGMENTATION IN TX NON-TUNNELED PACKETS *** */ 4461 struct cmd_tso_set_result { 4462 cmdline_fixed_string_t tso; 4463 cmdline_fixed_string_t mode; 4464 uint16_t tso_segsz; 4465 portid_t port_id; 4466 }; 4467 4468 static void 4469 cmd_tso_set_parsed(void *parsed_result, 4470 __attribute__((unused)) struct cmdline *cl, 4471 __attribute__((unused)) void *data) 4472 { 4473 struct cmd_tso_set_result *res = parsed_result; 4474 struct rte_eth_dev_info dev_info; 4475 4476 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4477 return; 4478 if (!port_is_stopped(res->port_id)) { 4479 printf("Please stop port %d first\n", res->port_id); 4480 return; 4481 } 4482 4483 if (!strcmp(res->mode, "set")) 4484 ports[res->port_id].tso_segsz = res->tso_segsz; 4485 4486 rte_eth_dev_info_get(res->port_id, &dev_info); 4487 if ((ports[res->port_id].tso_segsz != 0) && 4488 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4489 printf("Error: TSO is not supported by port %d\n", 4490 res->port_id); 4491 return; 4492 } 4493 4494 if (ports[res->port_id].tso_segsz == 0) { 4495 ports[res->port_id].dev_conf.txmode.offloads &= 4496 ~DEV_TX_OFFLOAD_TCP_TSO; 4497 printf("TSO for non-tunneled packets is disabled\n"); 4498 } else { 4499 ports[res->port_id].dev_conf.txmode.offloads |= 4500 DEV_TX_OFFLOAD_TCP_TSO; 4501 printf("TSO segment size for non-tunneled packets is %d\n", 4502 ports[res->port_id].tso_segsz); 4503 } 4504 4505 /* display warnings if configuration is not supported by the NIC */ 4506 rte_eth_dev_info_get(res->port_id, &dev_info); 4507 if ((ports[res->port_id].tso_segsz != 0) && 4508 (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0) { 4509 printf("Warning: TSO enabled but not " 4510 "supported by port %d\n", res->port_id); 4511 } 4512 4513 cmd_reconfig_device_queue(res->port_id, 1, 1); 4514 } 4515 4516 cmdline_parse_token_string_t cmd_tso_set_tso = 4517 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4518 tso, "tso"); 4519 cmdline_parse_token_string_t cmd_tso_set_mode = 4520 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4521 mode, "set"); 4522 cmdline_parse_token_num_t cmd_tso_set_tso_segsz = 4523 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4524 tso_segsz, UINT16); 4525 cmdline_parse_token_num_t cmd_tso_set_portid = 4526 TOKEN_NUM_INITIALIZER(struct cmd_tso_set_result, 4527 port_id, UINT16); 4528 4529 cmdline_parse_inst_t cmd_tso_set = { 4530 .f = cmd_tso_set_parsed, 4531 .data = NULL, 4532 .help_str = "tso set <tso_segsz> <port_id>: " 4533 "Set TSO segment size of non-tunneled packets for csum engine " 4534 "(0 to disable)", 4535 .tokens = { 4536 (void *)&cmd_tso_set_tso, 4537 (void *)&cmd_tso_set_mode, 4538 (void *)&cmd_tso_set_tso_segsz, 4539 (void *)&cmd_tso_set_portid, 4540 NULL, 4541 }, 4542 }; 4543 4544 cmdline_parse_token_string_t cmd_tso_show_mode = 4545 TOKEN_STRING_INITIALIZER(struct cmd_tso_set_result, 4546 mode, "show"); 4547 4548 4549 cmdline_parse_inst_t cmd_tso_show = { 4550 .f = cmd_tso_set_parsed, 4551 .data = NULL, 4552 .help_str = "tso show <port_id>: " 4553 "Show TSO segment size of non-tunneled packets for csum engine", 4554 .tokens = { 4555 (void *)&cmd_tso_set_tso, 4556 (void *)&cmd_tso_show_mode, 4557 (void *)&cmd_tso_set_portid, 4558 NULL, 4559 }, 4560 }; 4561 4562 /* *** ENABLE HARDWARE SEGMENTATION IN TX TUNNELED PACKETS *** */ 4563 struct cmd_tunnel_tso_set_result { 4564 cmdline_fixed_string_t tso; 4565 cmdline_fixed_string_t mode; 4566 uint16_t tso_segsz; 4567 portid_t port_id; 4568 }; 4569 4570 static struct rte_eth_dev_info 4571 check_tunnel_tso_nic_support(portid_t port_id) 4572 { 4573 struct rte_eth_dev_info dev_info; 4574 4575 rte_eth_dev_info_get(port_id, &dev_info); 4576 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO)) 4577 printf("Warning: VXLAN TUNNEL TSO not supported therefore " 4578 "not enabled for port %d\n", port_id); 4579 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO)) 4580 printf("Warning: GRE TUNNEL TSO not supported therefore " 4581 "not enabled for port %d\n", port_id); 4582 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO)) 4583 printf("Warning: IPIP TUNNEL TSO not supported therefore " 4584 "not enabled for port %d\n", port_id); 4585 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO)) 4586 printf("Warning: GENEVE TUNNEL TSO not supported therefore " 4587 "not enabled for port %d\n", port_id); 4588 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO)) 4589 printf("Warning: IP TUNNEL TSO not supported therefore " 4590 "not enabled for port %d\n", port_id); 4591 if (!(dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO)) 4592 printf("Warning: UDP TUNNEL TSO not supported therefore " 4593 "not enabled for port %d\n", port_id); 4594 return dev_info; 4595 } 4596 4597 static void 4598 cmd_tunnel_tso_set_parsed(void *parsed_result, 4599 __attribute__((unused)) struct cmdline *cl, 4600 __attribute__((unused)) void *data) 4601 { 4602 struct cmd_tunnel_tso_set_result *res = parsed_result; 4603 struct rte_eth_dev_info dev_info; 4604 4605 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 4606 return; 4607 if (!port_is_stopped(res->port_id)) { 4608 printf("Please stop port %d first\n", res->port_id); 4609 return; 4610 } 4611 4612 if (!strcmp(res->mode, "set")) 4613 ports[res->port_id].tunnel_tso_segsz = res->tso_segsz; 4614 4615 dev_info = check_tunnel_tso_nic_support(res->port_id); 4616 if (ports[res->port_id].tunnel_tso_segsz == 0) { 4617 ports[res->port_id].dev_conf.txmode.offloads &= 4618 ~(DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4619 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4620 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4621 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4622 DEV_TX_OFFLOAD_IP_TNL_TSO | 4623 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4624 printf("TSO for tunneled packets is disabled\n"); 4625 } else { 4626 uint64_t tso_offloads = (DEV_TX_OFFLOAD_VXLAN_TNL_TSO | 4627 DEV_TX_OFFLOAD_GRE_TNL_TSO | 4628 DEV_TX_OFFLOAD_IPIP_TNL_TSO | 4629 DEV_TX_OFFLOAD_GENEVE_TNL_TSO | 4630 DEV_TX_OFFLOAD_IP_TNL_TSO | 4631 DEV_TX_OFFLOAD_UDP_TNL_TSO); 4632 4633 ports[res->port_id].dev_conf.txmode.offloads |= 4634 (tso_offloads & dev_info.tx_offload_capa); 4635 printf("TSO segment size for tunneled packets is %d\n", 4636 ports[res->port_id].tunnel_tso_segsz); 4637 4638 /* Below conditions are needed to make it work: 4639 * (1) tunnel TSO is supported by the NIC; 4640 * (2) "csum parse_tunnel" must be set so that tunneled pkts 4641 * are recognized; 4642 * (3) for tunneled pkts with outer L3 of IPv4, 4643 * "csum set outer-ip" must be set to hw, because after tso, 4644 * total_len of outer IP header is changed, and the checksum 4645 * of outer IP header calculated by sw should be wrong; that 4646 * is not necessary for IPv6 tunneled pkts because there's no 4647 * checksum in IP header anymore. 4648 */ 4649 4650 if (!ports[res->port_id].parse_tunnel) 4651 printf("Warning: csum parse_tunnel must be set " 4652 "so that tunneled packets are recognized\n"); 4653 if (!(ports[res->port_id].dev_conf.txmode.offloads & 4654 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)) 4655 printf("Warning: csum set outer-ip must be set to hw " 4656 "if outer L3 is IPv4; not necessary for IPv6\n"); 4657 } 4658 4659 cmd_reconfig_device_queue(res->port_id, 1, 1); 4660 } 4661 4662 cmdline_parse_token_string_t cmd_tunnel_tso_set_tso = 4663 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4664 tso, "tunnel_tso"); 4665 cmdline_parse_token_string_t cmd_tunnel_tso_set_mode = 4666 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4667 mode, "set"); 4668 cmdline_parse_token_num_t cmd_tunnel_tso_set_tso_segsz = 4669 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4670 tso_segsz, UINT16); 4671 cmdline_parse_token_num_t cmd_tunnel_tso_set_portid = 4672 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_tso_set_result, 4673 port_id, UINT16); 4674 4675 cmdline_parse_inst_t cmd_tunnel_tso_set = { 4676 .f = cmd_tunnel_tso_set_parsed, 4677 .data = NULL, 4678 .help_str = "tunnel_tso set <tso_segsz> <port_id>: " 4679 "Set TSO segment size of tunneled packets for csum engine " 4680 "(0 to disable)", 4681 .tokens = { 4682 (void *)&cmd_tunnel_tso_set_tso, 4683 (void *)&cmd_tunnel_tso_set_mode, 4684 (void *)&cmd_tunnel_tso_set_tso_segsz, 4685 (void *)&cmd_tunnel_tso_set_portid, 4686 NULL, 4687 }, 4688 }; 4689 4690 cmdline_parse_token_string_t cmd_tunnel_tso_show_mode = 4691 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_tso_set_result, 4692 mode, "show"); 4693 4694 4695 cmdline_parse_inst_t cmd_tunnel_tso_show = { 4696 .f = cmd_tunnel_tso_set_parsed, 4697 .data = NULL, 4698 .help_str = "tunnel_tso show <port_id> " 4699 "Show TSO segment size of tunneled packets for csum engine", 4700 .tokens = { 4701 (void *)&cmd_tunnel_tso_set_tso, 4702 (void *)&cmd_tunnel_tso_show_mode, 4703 (void *)&cmd_tunnel_tso_set_portid, 4704 NULL, 4705 }, 4706 }; 4707 4708 /* *** SET GRO FOR A PORT *** */ 4709 struct cmd_gro_enable_result { 4710 cmdline_fixed_string_t cmd_set; 4711 cmdline_fixed_string_t cmd_port; 4712 cmdline_fixed_string_t cmd_keyword; 4713 cmdline_fixed_string_t cmd_onoff; 4714 portid_t cmd_pid; 4715 }; 4716 4717 static void 4718 cmd_gro_enable_parsed(void *parsed_result, 4719 __attribute__((unused)) struct cmdline *cl, 4720 __attribute__((unused)) void *data) 4721 { 4722 struct cmd_gro_enable_result *res; 4723 4724 res = parsed_result; 4725 if (!strcmp(res->cmd_keyword, "gro")) 4726 setup_gro(res->cmd_onoff, res->cmd_pid); 4727 } 4728 4729 cmdline_parse_token_string_t cmd_gro_enable_set = 4730 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4731 cmd_set, "set"); 4732 cmdline_parse_token_string_t cmd_gro_enable_port = 4733 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4734 cmd_keyword, "port"); 4735 cmdline_parse_token_num_t cmd_gro_enable_pid = 4736 TOKEN_NUM_INITIALIZER(struct cmd_gro_enable_result, 4737 cmd_pid, UINT16); 4738 cmdline_parse_token_string_t cmd_gro_enable_keyword = 4739 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4740 cmd_keyword, "gro"); 4741 cmdline_parse_token_string_t cmd_gro_enable_onoff = 4742 TOKEN_STRING_INITIALIZER(struct cmd_gro_enable_result, 4743 cmd_onoff, "on#off"); 4744 4745 cmdline_parse_inst_t cmd_gro_enable = { 4746 .f = cmd_gro_enable_parsed, 4747 .data = NULL, 4748 .help_str = "set port <port_id> gro on|off", 4749 .tokens = { 4750 (void *)&cmd_gro_enable_set, 4751 (void *)&cmd_gro_enable_port, 4752 (void *)&cmd_gro_enable_pid, 4753 (void *)&cmd_gro_enable_keyword, 4754 (void *)&cmd_gro_enable_onoff, 4755 NULL, 4756 }, 4757 }; 4758 4759 /* *** DISPLAY GRO CONFIGURATION *** */ 4760 struct cmd_gro_show_result { 4761 cmdline_fixed_string_t cmd_show; 4762 cmdline_fixed_string_t cmd_port; 4763 cmdline_fixed_string_t cmd_keyword; 4764 portid_t cmd_pid; 4765 }; 4766 4767 static void 4768 cmd_gro_show_parsed(void *parsed_result, 4769 __attribute__((unused)) struct cmdline *cl, 4770 __attribute__((unused)) void *data) 4771 { 4772 struct cmd_gro_show_result *res; 4773 4774 res = parsed_result; 4775 if (!strcmp(res->cmd_keyword, "gro")) 4776 show_gro(res->cmd_pid); 4777 } 4778 4779 cmdline_parse_token_string_t cmd_gro_show_show = 4780 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4781 cmd_show, "show"); 4782 cmdline_parse_token_string_t cmd_gro_show_port = 4783 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4784 cmd_port, "port"); 4785 cmdline_parse_token_num_t cmd_gro_show_pid = 4786 TOKEN_NUM_INITIALIZER(struct cmd_gro_show_result, 4787 cmd_pid, UINT16); 4788 cmdline_parse_token_string_t cmd_gro_show_keyword = 4789 TOKEN_STRING_INITIALIZER(struct cmd_gro_show_result, 4790 cmd_keyword, "gro"); 4791 4792 cmdline_parse_inst_t cmd_gro_show = { 4793 .f = cmd_gro_show_parsed, 4794 .data = NULL, 4795 .help_str = "show port <port_id> gro", 4796 .tokens = { 4797 (void *)&cmd_gro_show_show, 4798 (void *)&cmd_gro_show_port, 4799 (void *)&cmd_gro_show_pid, 4800 (void *)&cmd_gro_show_keyword, 4801 NULL, 4802 }, 4803 }; 4804 4805 /* *** SET FLUSH CYCLES FOR GRO *** */ 4806 struct cmd_gro_flush_result { 4807 cmdline_fixed_string_t cmd_set; 4808 cmdline_fixed_string_t cmd_keyword; 4809 cmdline_fixed_string_t cmd_flush; 4810 uint8_t cmd_cycles; 4811 }; 4812 4813 static void 4814 cmd_gro_flush_parsed(void *parsed_result, 4815 __attribute__((unused)) struct cmdline *cl, 4816 __attribute__((unused)) void *data) 4817 { 4818 struct cmd_gro_flush_result *res; 4819 4820 res = parsed_result; 4821 if ((!strcmp(res->cmd_keyword, "gro")) && 4822 (!strcmp(res->cmd_flush, "flush"))) 4823 setup_gro_flush_cycles(res->cmd_cycles); 4824 } 4825 4826 cmdline_parse_token_string_t cmd_gro_flush_set = 4827 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4828 cmd_set, "set"); 4829 cmdline_parse_token_string_t cmd_gro_flush_keyword = 4830 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4831 cmd_keyword, "gro"); 4832 cmdline_parse_token_string_t cmd_gro_flush_flush = 4833 TOKEN_STRING_INITIALIZER(struct cmd_gro_flush_result, 4834 cmd_flush, "flush"); 4835 cmdline_parse_token_num_t cmd_gro_flush_cycles = 4836 TOKEN_NUM_INITIALIZER(struct cmd_gro_flush_result, 4837 cmd_cycles, UINT8); 4838 4839 cmdline_parse_inst_t cmd_gro_flush = { 4840 .f = cmd_gro_flush_parsed, 4841 .data = NULL, 4842 .help_str = "set gro flush <cycles>", 4843 .tokens = { 4844 (void *)&cmd_gro_flush_set, 4845 (void *)&cmd_gro_flush_keyword, 4846 (void *)&cmd_gro_flush_flush, 4847 (void *)&cmd_gro_flush_cycles, 4848 NULL, 4849 }, 4850 }; 4851 4852 /* *** ENABLE/DISABLE GSO *** */ 4853 struct cmd_gso_enable_result { 4854 cmdline_fixed_string_t cmd_set; 4855 cmdline_fixed_string_t cmd_port; 4856 cmdline_fixed_string_t cmd_keyword; 4857 cmdline_fixed_string_t cmd_mode; 4858 portid_t cmd_pid; 4859 }; 4860 4861 static void 4862 cmd_gso_enable_parsed(void *parsed_result, 4863 __attribute__((unused)) struct cmdline *cl, 4864 __attribute__((unused)) void *data) 4865 { 4866 struct cmd_gso_enable_result *res; 4867 4868 res = parsed_result; 4869 if (!strcmp(res->cmd_keyword, "gso")) 4870 setup_gso(res->cmd_mode, res->cmd_pid); 4871 } 4872 4873 cmdline_parse_token_string_t cmd_gso_enable_set = 4874 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4875 cmd_set, "set"); 4876 cmdline_parse_token_string_t cmd_gso_enable_port = 4877 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4878 cmd_port, "port"); 4879 cmdline_parse_token_string_t cmd_gso_enable_keyword = 4880 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4881 cmd_keyword, "gso"); 4882 cmdline_parse_token_string_t cmd_gso_enable_mode = 4883 TOKEN_STRING_INITIALIZER(struct cmd_gso_enable_result, 4884 cmd_mode, "on#off"); 4885 cmdline_parse_token_num_t cmd_gso_enable_pid = 4886 TOKEN_NUM_INITIALIZER(struct cmd_gso_enable_result, 4887 cmd_pid, UINT16); 4888 4889 cmdline_parse_inst_t cmd_gso_enable = { 4890 .f = cmd_gso_enable_parsed, 4891 .data = NULL, 4892 .help_str = "set port <port_id> gso on|off", 4893 .tokens = { 4894 (void *)&cmd_gso_enable_set, 4895 (void *)&cmd_gso_enable_port, 4896 (void *)&cmd_gso_enable_pid, 4897 (void *)&cmd_gso_enable_keyword, 4898 (void *)&cmd_gso_enable_mode, 4899 NULL, 4900 }, 4901 }; 4902 4903 /* *** SET MAX PACKET LENGTH FOR GSO SEGMENTS *** */ 4904 struct cmd_gso_size_result { 4905 cmdline_fixed_string_t cmd_set; 4906 cmdline_fixed_string_t cmd_keyword; 4907 cmdline_fixed_string_t cmd_segsz; 4908 uint16_t cmd_size; 4909 }; 4910 4911 static void 4912 cmd_gso_size_parsed(void *parsed_result, 4913 __attribute__((unused)) struct cmdline *cl, 4914 __attribute__((unused)) void *data) 4915 { 4916 struct cmd_gso_size_result *res = parsed_result; 4917 4918 if (test_done == 0) { 4919 printf("Before setting GSO segsz, please first" 4920 " stop fowarding\n"); 4921 return; 4922 } 4923 4924 if (!strcmp(res->cmd_keyword, "gso") && 4925 !strcmp(res->cmd_segsz, "segsz")) { 4926 if (res->cmd_size < RTE_GSO_SEG_SIZE_MIN) 4927 printf("gso_size should be larger than %zu." 4928 " Please input a legal value\n", 4929 RTE_GSO_SEG_SIZE_MIN); 4930 else 4931 gso_max_segment_size = res->cmd_size; 4932 } 4933 } 4934 4935 cmdline_parse_token_string_t cmd_gso_size_set = 4936 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 4937 cmd_set, "set"); 4938 cmdline_parse_token_string_t cmd_gso_size_keyword = 4939 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 4940 cmd_keyword, "gso"); 4941 cmdline_parse_token_string_t cmd_gso_size_segsz = 4942 TOKEN_STRING_INITIALIZER(struct cmd_gso_size_result, 4943 cmd_segsz, "segsz"); 4944 cmdline_parse_token_num_t cmd_gso_size_size = 4945 TOKEN_NUM_INITIALIZER(struct cmd_gso_size_result, 4946 cmd_size, UINT16); 4947 4948 cmdline_parse_inst_t cmd_gso_size = { 4949 .f = cmd_gso_size_parsed, 4950 .data = NULL, 4951 .help_str = "set gso segsz <length>", 4952 .tokens = { 4953 (void *)&cmd_gso_size_set, 4954 (void *)&cmd_gso_size_keyword, 4955 (void *)&cmd_gso_size_segsz, 4956 (void *)&cmd_gso_size_size, 4957 NULL, 4958 }, 4959 }; 4960 4961 /* *** SHOW GSO CONFIGURATION *** */ 4962 struct cmd_gso_show_result { 4963 cmdline_fixed_string_t cmd_show; 4964 cmdline_fixed_string_t cmd_port; 4965 cmdline_fixed_string_t cmd_keyword; 4966 portid_t cmd_pid; 4967 }; 4968 4969 static void 4970 cmd_gso_show_parsed(void *parsed_result, 4971 __attribute__((unused)) struct cmdline *cl, 4972 __attribute__((unused)) void *data) 4973 { 4974 struct cmd_gso_show_result *res = parsed_result; 4975 4976 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 4977 printf("invalid port id %u\n", res->cmd_pid); 4978 return; 4979 } 4980 if (!strcmp(res->cmd_keyword, "gso")) { 4981 if (gso_ports[res->cmd_pid].enable) { 4982 printf("Max GSO'd packet size: %uB\n" 4983 "Supported GSO types: TCP/IPv4, " 4984 "UDP/IPv4, VxLAN with inner " 4985 "TCP/IPv4 packet, GRE with inner " 4986 "TCP/IPv4 packet\n", 4987 gso_max_segment_size); 4988 } else 4989 printf("GSO is not enabled on Port %u\n", res->cmd_pid); 4990 } 4991 } 4992 4993 cmdline_parse_token_string_t cmd_gso_show_show = 4994 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 4995 cmd_show, "show"); 4996 cmdline_parse_token_string_t cmd_gso_show_port = 4997 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 4998 cmd_port, "port"); 4999 cmdline_parse_token_string_t cmd_gso_show_keyword = 5000 TOKEN_STRING_INITIALIZER(struct cmd_gso_show_result, 5001 cmd_keyword, "gso"); 5002 cmdline_parse_token_num_t cmd_gso_show_pid = 5003 TOKEN_NUM_INITIALIZER(struct cmd_gso_show_result, 5004 cmd_pid, UINT16); 5005 5006 cmdline_parse_inst_t cmd_gso_show = { 5007 .f = cmd_gso_show_parsed, 5008 .data = NULL, 5009 .help_str = "show port <port_id> gso", 5010 .tokens = { 5011 (void *)&cmd_gso_show_show, 5012 (void *)&cmd_gso_show_port, 5013 (void *)&cmd_gso_show_pid, 5014 (void *)&cmd_gso_show_keyword, 5015 NULL, 5016 }, 5017 }; 5018 5019 /* *** ENABLE/DISABLE FLUSH ON RX STREAMS *** */ 5020 struct cmd_set_flush_rx { 5021 cmdline_fixed_string_t set; 5022 cmdline_fixed_string_t flush_rx; 5023 cmdline_fixed_string_t mode; 5024 }; 5025 5026 static void 5027 cmd_set_flush_rx_parsed(void *parsed_result, 5028 __attribute__((unused)) struct cmdline *cl, 5029 __attribute__((unused)) void *data) 5030 { 5031 struct cmd_set_flush_rx *res = parsed_result; 5032 no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5033 } 5034 5035 cmdline_parse_token_string_t cmd_setflushrx_set = 5036 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5037 set, "set"); 5038 cmdline_parse_token_string_t cmd_setflushrx_flush_rx = 5039 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5040 flush_rx, "flush_rx"); 5041 cmdline_parse_token_string_t cmd_setflushrx_mode = 5042 TOKEN_STRING_INITIALIZER(struct cmd_set_flush_rx, 5043 mode, "on#off"); 5044 5045 5046 cmdline_parse_inst_t cmd_set_flush_rx = { 5047 .f = cmd_set_flush_rx_parsed, 5048 .help_str = "set flush_rx on|off: Enable/Disable flush on rx streams", 5049 .data = NULL, 5050 .tokens = { 5051 (void *)&cmd_setflushrx_set, 5052 (void *)&cmd_setflushrx_flush_rx, 5053 (void *)&cmd_setflushrx_mode, 5054 NULL, 5055 }, 5056 }; 5057 5058 /* *** ENABLE/DISABLE LINK STATUS CHECK *** */ 5059 struct cmd_set_link_check { 5060 cmdline_fixed_string_t set; 5061 cmdline_fixed_string_t link_check; 5062 cmdline_fixed_string_t mode; 5063 }; 5064 5065 static void 5066 cmd_set_link_check_parsed(void *parsed_result, 5067 __attribute__((unused)) struct cmdline *cl, 5068 __attribute__((unused)) void *data) 5069 { 5070 struct cmd_set_link_check *res = parsed_result; 5071 no_link_check = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); 5072 } 5073 5074 cmdline_parse_token_string_t cmd_setlinkcheck_set = 5075 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5076 set, "set"); 5077 cmdline_parse_token_string_t cmd_setlinkcheck_link_check = 5078 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5079 link_check, "link_check"); 5080 cmdline_parse_token_string_t cmd_setlinkcheck_mode = 5081 TOKEN_STRING_INITIALIZER(struct cmd_set_link_check, 5082 mode, "on#off"); 5083 5084 5085 cmdline_parse_inst_t cmd_set_link_check = { 5086 .f = cmd_set_link_check_parsed, 5087 .help_str = "set link_check on|off: Enable/Disable link status check " 5088 "when starting/stopping a port", 5089 .data = NULL, 5090 .tokens = { 5091 (void *)&cmd_setlinkcheck_set, 5092 (void *)&cmd_setlinkcheck_link_check, 5093 (void *)&cmd_setlinkcheck_mode, 5094 NULL, 5095 }, 5096 }; 5097 5098 /* *** SET NIC BYPASS MODE *** */ 5099 struct cmd_set_bypass_mode_result { 5100 cmdline_fixed_string_t set; 5101 cmdline_fixed_string_t bypass; 5102 cmdline_fixed_string_t mode; 5103 cmdline_fixed_string_t value; 5104 portid_t port_id; 5105 }; 5106 5107 static void 5108 cmd_set_bypass_mode_parsed(void *parsed_result, 5109 __attribute__((unused)) struct cmdline *cl, 5110 __attribute__((unused)) void *data) 5111 { 5112 struct cmd_set_bypass_mode_result *res = parsed_result; 5113 portid_t port_id = res->port_id; 5114 int32_t rc = -EINVAL; 5115 5116 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5117 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5118 5119 if (!strcmp(res->value, "bypass")) 5120 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5121 else if (!strcmp(res->value, "isolate")) 5122 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5123 else 5124 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5125 5126 /* Set the bypass mode for the relevant port. */ 5127 rc = rte_pmd_ixgbe_bypass_state_set(port_id, &bypass_mode); 5128 #endif 5129 if (rc != 0) 5130 printf("\t Failed to set bypass mode for port = %d.\n", port_id); 5131 } 5132 5133 cmdline_parse_token_string_t cmd_setbypass_mode_set = 5134 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5135 set, "set"); 5136 cmdline_parse_token_string_t cmd_setbypass_mode_bypass = 5137 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5138 bypass, "bypass"); 5139 cmdline_parse_token_string_t cmd_setbypass_mode_mode = 5140 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5141 mode, "mode"); 5142 cmdline_parse_token_string_t cmd_setbypass_mode_value = 5143 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_mode_result, 5144 value, "normal#bypass#isolate"); 5145 cmdline_parse_token_num_t cmd_setbypass_mode_port = 5146 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_mode_result, 5147 port_id, UINT16); 5148 5149 cmdline_parse_inst_t cmd_set_bypass_mode = { 5150 .f = cmd_set_bypass_mode_parsed, 5151 .help_str = "set bypass mode normal|bypass|isolate <port_id>: " 5152 "Set the NIC bypass mode for port_id", 5153 .data = NULL, 5154 .tokens = { 5155 (void *)&cmd_setbypass_mode_set, 5156 (void *)&cmd_setbypass_mode_bypass, 5157 (void *)&cmd_setbypass_mode_mode, 5158 (void *)&cmd_setbypass_mode_value, 5159 (void *)&cmd_setbypass_mode_port, 5160 NULL, 5161 }, 5162 }; 5163 5164 /* *** SET NIC BYPASS EVENT *** */ 5165 struct cmd_set_bypass_event_result { 5166 cmdline_fixed_string_t set; 5167 cmdline_fixed_string_t bypass; 5168 cmdline_fixed_string_t event; 5169 cmdline_fixed_string_t event_value; 5170 cmdline_fixed_string_t mode; 5171 cmdline_fixed_string_t mode_value; 5172 portid_t port_id; 5173 }; 5174 5175 static void 5176 cmd_set_bypass_event_parsed(void *parsed_result, 5177 __attribute__((unused)) struct cmdline *cl, 5178 __attribute__((unused)) void *data) 5179 { 5180 int32_t rc = -EINVAL; 5181 struct cmd_set_bypass_event_result *res = parsed_result; 5182 portid_t port_id = res->port_id; 5183 5184 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5185 uint32_t bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5186 uint32_t bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5187 5188 if (!strcmp(res->event_value, "timeout")) 5189 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT; 5190 else if (!strcmp(res->event_value, "os_on")) 5191 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_ON; 5192 else if (!strcmp(res->event_value, "os_off")) 5193 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_OS_OFF; 5194 else if (!strcmp(res->event_value, "power_on")) 5195 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_ON; 5196 else if (!strcmp(res->event_value, "power_off")) 5197 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_POWER_OFF; 5198 else 5199 bypass_event = RTE_PMD_IXGBE_BYPASS_EVENT_NONE; 5200 5201 if (!strcmp(res->mode_value, "bypass")) 5202 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_BYPASS; 5203 else if (!strcmp(res->mode_value, "isolate")) 5204 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_ISOLATE; 5205 else 5206 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NORMAL; 5207 5208 /* Set the watchdog timeout. */ 5209 if (bypass_event == RTE_PMD_IXGBE_BYPASS_EVENT_TIMEOUT) { 5210 5211 rc = -EINVAL; 5212 if (RTE_PMD_IXGBE_BYPASS_TMT_VALID(bypass_timeout)) { 5213 rc = rte_pmd_ixgbe_bypass_wd_timeout_store(port_id, 5214 bypass_timeout); 5215 } 5216 if (rc != 0) { 5217 printf("Failed to set timeout value %u " 5218 "for port %d, errto code: %d.\n", 5219 bypass_timeout, port_id, rc); 5220 } 5221 } 5222 5223 /* Set the bypass event to transition to bypass mode. */ 5224 rc = rte_pmd_ixgbe_bypass_event_store(port_id, bypass_event, 5225 bypass_mode); 5226 #endif 5227 5228 if (rc != 0) 5229 printf("\t Failed to set bypass event for port = %d.\n", 5230 port_id); 5231 } 5232 5233 cmdline_parse_token_string_t cmd_setbypass_event_set = 5234 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5235 set, "set"); 5236 cmdline_parse_token_string_t cmd_setbypass_event_bypass = 5237 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5238 bypass, "bypass"); 5239 cmdline_parse_token_string_t cmd_setbypass_event_event = 5240 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5241 event, "event"); 5242 cmdline_parse_token_string_t cmd_setbypass_event_event_value = 5243 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5244 event_value, "none#timeout#os_off#os_on#power_on#power_off"); 5245 cmdline_parse_token_string_t cmd_setbypass_event_mode = 5246 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5247 mode, "mode"); 5248 cmdline_parse_token_string_t cmd_setbypass_event_mode_value = 5249 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_event_result, 5250 mode_value, "normal#bypass#isolate"); 5251 cmdline_parse_token_num_t cmd_setbypass_event_port = 5252 TOKEN_NUM_INITIALIZER(struct cmd_set_bypass_event_result, 5253 port_id, UINT16); 5254 5255 cmdline_parse_inst_t cmd_set_bypass_event = { 5256 .f = cmd_set_bypass_event_parsed, 5257 .help_str = "set bypass event none|timeout|os_on|os_off|power_on|" 5258 "power_off mode normal|bypass|isolate <port_id>: " 5259 "Set the NIC bypass event mode for port_id", 5260 .data = NULL, 5261 .tokens = { 5262 (void *)&cmd_setbypass_event_set, 5263 (void *)&cmd_setbypass_event_bypass, 5264 (void *)&cmd_setbypass_event_event, 5265 (void *)&cmd_setbypass_event_event_value, 5266 (void *)&cmd_setbypass_event_mode, 5267 (void *)&cmd_setbypass_event_mode_value, 5268 (void *)&cmd_setbypass_event_port, 5269 NULL, 5270 }, 5271 }; 5272 5273 5274 /* *** SET NIC BYPASS TIMEOUT *** */ 5275 struct cmd_set_bypass_timeout_result { 5276 cmdline_fixed_string_t set; 5277 cmdline_fixed_string_t bypass; 5278 cmdline_fixed_string_t timeout; 5279 cmdline_fixed_string_t value; 5280 }; 5281 5282 static void 5283 cmd_set_bypass_timeout_parsed(void *parsed_result, 5284 __attribute__((unused)) struct cmdline *cl, 5285 __attribute__((unused)) void *data) 5286 { 5287 __rte_unused struct cmd_set_bypass_timeout_result *res = parsed_result; 5288 5289 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5290 if (!strcmp(res->value, "1.5")) 5291 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_1_5_SEC; 5292 else if (!strcmp(res->value, "2")) 5293 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_2_SEC; 5294 else if (!strcmp(res->value, "3")) 5295 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_3_SEC; 5296 else if (!strcmp(res->value, "4")) 5297 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_4_SEC; 5298 else if (!strcmp(res->value, "8")) 5299 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_8_SEC; 5300 else if (!strcmp(res->value, "16")) 5301 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_16_SEC; 5302 else if (!strcmp(res->value, "32")) 5303 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_32_SEC; 5304 else 5305 bypass_timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5306 #endif 5307 } 5308 5309 cmdline_parse_token_string_t cmd_setbypass_timeout_set = 5310 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5311 set, "set"); 5312 cmdline_parse_token_string_t cmd_setbypass_timeout_bypass = 5313 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5314 bypass, "bypass"); 5315 cmdline_parse_token_string_t cmd_setbypass_timeout_timeout = 5316 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5317 timeout, "timeout"); 5318 cmdline_parse_token_string_t cmd_setbypass_timeout_value = 5319 TOKEN_STRING_INITIALIZER(struct cmd_set_bypass_timeout_result, 5320 value, "0#1.5#2#3#4#8#16#32"); 5321 5322 cmdline_parse_inst_t cmd_set_bypass_timeout = { 5323 .f = cmd_set_bypass_timeout_parsed, 5324 .help_str = "set bypass timeout 0|1.5|2|3|4|8|16|32: " 5325 "Set the NIC bypass watchdog timeout in seconds", 5326 .data = NULL, 5327 .tokens = { 5328 (void *)&cmd_setbypass_timeout_set, 5329 (void *)&cmd_setbypass_timeout_bypass, 5330 (void *)&cmd_setbypass_timeout_timeout, 5331 (void *)&cmd_setbypass_timeout_value, 5332 NULL, 5333 }, 5334 }; 5335 5336 /* *** SHOW NIC BYPASS MODE *** */ 5337 struct cmd_show_bypass_config_result { 5338 cmdline_fixed_string_t show; 5339 cmdline_fixed_string_t bypass; 5340 cmdline_fixed_string_t config; 5341 portid_t port_id; 5342 }; 5343 5344 static void 5345 cmd_show_bypass_config_parsed(void *parsed_result, 5346 __attribute__((unused)) struct cmdline *cl, 5347 __attribute__((unused)) void *data) 5348 { 5349 struct cmd_show_bypass_config_result *res = parsed_result; 5350 portid_t port_id = res->port_id; 5351 int rc = -EINVAL; 5352 #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS 5353 uint32_t event_mode; 5354 uint32_t bypass_mode; 5355 uint32_t timeout = bypass_timeout; 5356 int i; 5357 5358 static const char * const timeouts[RTE_PMD_IXGBE_BYPASS_TMT_NUM] = 5359 {"off", "1.5", "2", "3", "4", "8", "16", "32"}; 5360 static const char * const modes[RTE_PMD_IXGBE_BYPASS_MODE_NUM] = 5361 {"UNKNOWN", "normal", "bypass", "isolate"}; 5362 static const char * const events[RTE_PMD_IXGBE_BYPASS_EVENT_NUM] = { 5363 "NONE", 5364 "OS/board on", 5365 "power supply on", 5366 "OS/board off", 5367 "power supply off", 5368 "timeout"}; 5369 int num_events = (sizeof events) / (sizeof events[0]); 5370 5371 /* Display the bypass mode.*/ 5372 if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) != 0) { 5373 printf("\tFailed to get bypass mode for port = %d\n", port_id); 5374 return; 5375 } 5376 else { 5377 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(bypass_mode)) 5378 bypass_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5379 5380 printf("\tbypass mode = %s\n", modes[bypass_mode]); 5381 } 5382 5383 /* Display the bypass timeout.*/ 5384 if (!RTE_PMD_IXGBE_BYPASS_TMT_VALID(timeout)) 5385 timeout = RTE_PMD_IXGBE_BYPASS_TMT_OFF; 5386 5387 printf("\tbypass timeout = %s\n", timeouts[timeout]); 5388 5389 /* Display the bypass events and associated modes. */ 5390 for (i = RTE_PMD_IXGBE_BYPASS_EVENT_START; i < num_events; i++) { 5391 5392 if (rte_pmd_ixgbe_bypass_event_show(port_id, i, &event_mode)) { 5393 printf("\tFailed to get bypass mode for event = %s\n", 5394 events[i]); 5395 } else { 5396 if (!RTE_PMD_IXGBE_BYPASS_MODE_VALID(event_mode)) 5397 event_mode = RTE_PMD_IXGBE_BYPASS_MODE_NONE; 5398 5399 printf("\tbypass event: %-16s = %s\n", events[i], 5400 modes[event_mode]); 5401 } 5402 } 5403 #endif 5404 if (rc != 0) 5405 printf("\tFailed to get bypass configuration for port = %d\n", 5406 port_id); 5407 } 5408 5409 cmdline_parse_token_string_t cmd_showbypass_config_show = 5410 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5411 show, "show"); 5412 cmdline_parse_token_string_t cmd_showbypass_config_bypass = 5413 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5414 bypass, "bypass"); 5415 cmdline_parse_token_string_t cmd_showbypass_config_config = 5416 TOKEN_STRING_INITIALIZER(struct cmd_show_bypass_config_result, 5417 config, "config"); 5418 cmdline_parse_token_num_t cmd_showbypass_config_port = 5419 TOKEN_NUM_INITIALIZER(struct cmd_show_bypass_config_result, 5420 port_id, UINT16); 5421 5422 cmdline_parse_inst_t cmd_show_bypass_config = { 5423 .f = cmd_show_bypass_config_parsed, 5424 .help_str = "show bypass config <port_id>: " 5425 "Show the NIC bypass config for port_id", 5426 .data = NULL, 5427 .tokens = { 5428 (void *)&cmd_showbypass_config_show, 5429 (void *)&cmd_showbypass_config_bypass, 5430 (void *)&cmd_showbypass_config_config, 5431 (void *)&cmd_showbypass_config_port, 5432 NULL, 5433 }, 5434 }; 5435 5436 #ifdef RTE_LIBRTE_PMD_BOND 5437 /* *** SET BONDING MODE *** */ 5438 struct cmd_set_bonding_mode_result { 5439 cmdline_fixed_string_t set; 5440 cmdline_fixed_string_t bonding; 5441 cmdline_fixed_string_t mode; 5442 uint8_t value; 5443 portid_t port_id; 5444 }; 5445 5446 static void cmd_set_bonding_mode_parsed(void *parsed_result, 5447 __attribute__((unused)) struct cmdline *cl, 5448 __attribute__((unused)) void *data) 5449 { 5450 struct cmd_set_bonding_mode_result *res = parsed_result; 5451 portid_t port_id = res->port_id; 5452 5453 /* Set the bonding mode for the relevant port. */ 5454 if (0 != rte_eth_bond_mode_set(port_id, res->value)) 5455 printf("\t Failed to set bonding mode for port = %d.\n", port_id); 5456 } 5457 5458 cmdline_parse_token_string_t cmd_setbonding_mode_set = 5459 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5460 set, "set"); 5461 cmdline_parse_token_string_t cmd_setbonding_mode_bonding = 5462 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5463 bonding, "bonding"); 5464 cmdline_parse_token_string_t cmd_setbonding_mode_mode = 5465 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_mode_result, 5466 mode, "mode"); 5467 cmdline_parse_token_num_t cmd_setbonding_mode_value = 5468 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5469 value, UINT8); 5470 cmdline_parse_token_num_t cmd_setbonding_mode_port = 5471 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_mode_result, 5472 port_id, UINT16); 5473 5474 cmdline_parse_inst_t cmd_set_bonding_mode = { 5475 .f = cmd_set_bonding_mode_parsed, 5476 .help_str = "set bonding mode <mode_value> <port_id>: " 5477 "Set the bonding mode for port_id", 5478 .data = NULL, 5479 .tokens = { 5480 (void *) &cmd_setbonding_mode_set, 5481 (void *) &cmd_setbonding_mode_bonding, 5482 (void *) &cmd_setbonding_mode_mode, 5483 (void *) &cmd_setbonding_mode_value, 5484 (void *) &cmd_setbonding_mode_port, 5485 NULL 5486 } 5487 }; 5488 5489 /* *** SET BONDING SLOW_QUEUE SW/HW *** */ 5490 struct cmd_set_bonding_lacp_dedicated_queues_result { 5491 cmdline_fixed_string_t set; 5492 cmdline_fixed_string_t bonding; 5493 cmdline_fixed_string_t lacp; 5494 cmdline_fixed_string_t dedicated_queues; 5495 portid_t port_id; 5496 cmdline_fixed_string_t mode; 5497 }; 5498 5499 static void cmd_set_bonding_lacp_dedicated_queues_parsed(void *parsed_result, 5500 __attribute__((unused)) struct cmdline *cl, 5501 __attribute__((unused)) void *data) 5502 { 5503 struct cmd_set_bonding_lacp_dedicated_queues_result *res = parsed_result; 5504 portid_t port_id = res->port_id; 5505 struct rte_port *port; 5506 5507 port = &ports[port_id]; 5508 5509 /** Check if the port is not started **/ 5510 if (port->port_status != RTE_PORT_STOPPED) { 5511 printf("Please stop port %d first\n", port_id); 5512 return; 5513 } 5514 5515 if (!strcmp(res->mode, "enable")) { 5516 if (rte_eth_bond_8023ad_dedicated_queues_enable(port_id) == 0) 5517 printf("Dedicate queues for LACP control packets" 5518 " enabled\n"); 5519 else 5520 printf("Enabling dedicate queues for LACP control " 5521 "packets on port %d failed\n", port_id); 5522 } else if (!strcmp(res->mode, "disable")) { 5523 if (rte_eth_bond_8023ad_dedicated_queues_disable(port_id) == 0) 5524 printf("Dedicated queues for LACP control packets " 5525 "disabled\n"); 5526 else 5527 printf("Disabling dedicated queues for LACP control " 5528 "traffic on port %d failed\n", port_id); 5529 } 5530 } 5531 5532 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_set = 5533 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5534 set, "set"); 5535 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_bonding = 5536 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5537 bonding, "bonding"); 5538 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_lacp = 5539 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5540 lacp, "lacp"); 5541 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_dedicated_queues = 5542 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5543 dedicated_queues, "dedicated_queues"); 5544 cmdline_parse_token_num_t cmd_setbonding_lacp_dedicated_queues_port_id = 5545 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5546 port_id, UINT16); 5547 cmdline_parse_token_string_t cmd_setbonding_lacp_dedicated_queues_mode = 5548 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_lacp_dedicated_queues_result, 5549 mode, "enable#disable"); 5550 5551 cmdline_parse_inst_t cmd_set_lacp_dedicated_queues = { 5552 .f = cmd_set_bonding_lacp_dedicated_queues_parsed, 5553 .help_str = "set bonding lacp dedicated_queues <port_id> " 5554 "enable|disable: " 5555 "Enable/disable dedicated queues for LACP control traffic for port_id", 5556 .data = NULL, 5557 .tokens = { 5558 (void *)&cmd_setbonding_lacp_dedicated_queues_set, 5559 (void *)&cmd_setbonding_lacp_dedicated_queues_bonding, 5560 (void *)&cmd_setbonding_lacp_dedicated_queues_lacp, 5561 (void *)&cmd_setbonding_lacp_dedicated_queues_dedicated_queues, 5562 (void *)&cmd_setbonding_lacp_dedicated_queues_port_id, 5563 (void *)&cmd_setbonding_lacp_dedicated_queues_mode, 5564 NULL 5565 } 5566 }; 5567 5568 /* *** SET BALANCE XMIT POLICY *** */ 5569 struct cmd_set_bonding_balance_xmit_policy_result { 5570 cmdline_fixed_string_t set; 5571 cmdline_fixed_string_t bonding; 5572 cmdline_fixed_string_t balance_xmit_policy; 5573 portid_t port_id; 5574 cmdline_fixed_string_t policy; 5575 }; 5576 5577 static void cmd_set_bonding_balance_xmit_policy_parsed(void *parsed_result, 5578 __attribute__((unused)) struct cmdline *cl, 5579 __attribute__((unused)) void *data) 5580 { 5581 struct cmd_set_bonding_balance_xmit_policy_result *res = parsed_result; 5582 portid_t port_id = res->port_id; 5583 uint8_t policy; 5584 5585 if (!strcmp(res->policy, "l2")) { 5586 policy = BALANCE_XMIT_POLICY_LAYER2; 5587 } else if (!strcmp(res->policy, "l23")) { 5588 policy = BALANCE_XMIT_POLICY_LAYER23; 5589 } else if (!strcmp(res->policy, "l34")) { 5590 policy = BALANCE_XMIT_POLICY_LAYER34; 5591 } else { 5592 printf("\t Invalid xmit policy selection"); 5593 return; 5594 } 5595 5596 /* Set the bonding mode for the relevant port. */ 5597 if (0 != rte_eth_bond_xmit_policy_set(port_id, policy)) { 5598 printf("\t Failed to set bonding balance xmit policy for port = %d.\n", 5599 port_id); 5600 } 5601 } 5602 5603 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_set = 5604 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5605 set, "set"); 5606 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_bonding = 5607 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5608 bonding, "bonding"); 5609 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_balance_xmit_policy = 5610 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5611 balance_xmit_policy, "balance_xmit_policy"); 5612 cmdline_parse_token_num_t cmd_setbonding_balance_xmit_policy_port = 5613 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5614 port_id, UINT16); 5615 cmdline_parse_token_string_t cmd_setbonding_balance_xmit_policy_policy = 5616 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_balance_xmit_policy_result, 5617 policy, "l2#l23#l34"); 5618 5619 cmdline_parse_inst_t cmd_set_balance_xmit_policy = { 5620 .f = cmd_set_bonding_balance_xmit_policy_parsed, 5621 .help_str = "set bonding balance_xmit_policy <port_id> " 5622 "l2|l23|l34: " 5623 "Set the bonding balance_xmit_policy for port_id", 5624 .data = NULL, 5625 .tokens = { 5626 (void *)&cmd_setbonding_balance_xmit_policy_set, 5627 (void *)&cmd_setbonding_balance_xmit_policy_bonding, 5628 (void *)&cmd_setbonding_balance_xmit_policy_balance_xmit_policy, 5629 (void *)&cmd_setbonding_balance_xmit_policy_port, 5630 (void *)&cmd_setbonding_balance_xmit_policy_policy, 5631 NULL 5632 } 5633 }; 5634 5635 /* *** SHOW NIC BONDING CONFIGURATION *** */ 5636 struct cmd_show_bonding_config_result { 5637 cmdline_fixed_string_t show; 5638 cmdline_fixed_string_t bonding; 5639 cmdline_fixed_string_t config; 5640 portid_t port_id; 5641 }; 5642 5643 static void cmd_show_bonding_config_parsed(void *parsed_result, 5644 __attribute__((unused)) struct cmdline *cl, 5645 __attribute__((unused)) void *data) 5646 { 5647 struct cmd_show_bonding_config_result *res = parsed_result; 5648 int bonding_mode, agg_mode; 5649 portid_t slaves[RTE_MAX_ETHPORTS]; 5650 int num_slaves, num_active_slaves; 5651 int primary_id; 5652 int i; 5653 portid_t port_id = res->port_id; 5654 5655 /* Display the bonding mode.*/ 5656 bonding_mode = rte_eth_bond_mode_get(port_id); 5657 if (bonding_mode < 0) { 5658 printf("\tFailed to get bonding mode for port = %d\n", port_id); 5659 return; 5660 } else 5661 printf("\tBonding mode: %d\n", bonding_mode); 5662 5663 if (bonding_mode == BONDING_MODE_BALANCE) { 5664 int balance_xmit_policy; 5665 5666 balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id); 5667 if (balance_xmit_policy < 0) { 5668 printf("\tFailed to get balance xmit policy for port = %d\n", 5669 port_id); 5670 return; 5671 } else { 5672 printf("\tBalance Xmit Policy: "); 5673 5674 switch (balance_xmit_policy) { 5675 case BALANCE_XMIT_POLICY_LAYER2: 5676 printf("BALANCE_XMIT_POLICY_LAYER2"); 5677 break; 5678 case BALANCE_XMIT_POLICY_LAYER23: 5679 printf("BALANCE_XMIT_POLICY_LAYER23"); 5680 break; 5681 case BALANCE_XMIT_POLICY_LAYER34: 5682 printf("BALANCE_XMIT_POLICY_LAYER34"); 5683 break; 5684 } 5685 printf("\n"); 5686 } 5687 } 5688 5689 if (bonding_mode == BONDING_MODE_8023AD) { 5690 agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id); 5691 printf("\tIEEE802.3AD Aggregator Mode: "); 5692 switch (agg_mode) { 5693 case AGG_BANDWIDTH: 5694 printf("bandwidth"); 5695 break; 5696 case AGG_STABLE: 5697 printf("stable"); 5698 break; 5699 case AGG_COUNT: 5700 printf("count"); 5701 break; 5702 } 5703 printf("\n"); 5704 } 5705 5706 num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS); 5707 5708 if (num_slaves < 0) { 5709 printf("\tFailed to get slave list for port = %d\n", port_id); 5710 return; 5711 } 5712 if (num_slaves > 0) { 5713 printf("\tSlaves (%d): [", num_slaves); 5714 for (i = 0; i < num_slaves - 1; i++) 5715 printf("%d ", slaves[i]); 5716 5717 printf("%d]\n", slaves[num_slaves - 1]); 5718 } else { 5719 printf("\tSlaves: []\n"); 5720 5721 } 5722 5723 num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, 5724 RTE_MAX_ETHPORTS); 5725 5726 if (num_active_slaves < 0) { 5727 printf("\tFailed to get active slave list for port = %d\n", port_id); 5728 return; 5729 } 5730 if (num_active_slaves > 0) { 5731 printf("\tActive Slaves (%d): [", num_active_slaves); 5732 for (i = 0; i < num_active_slaves - 1; i++) 5733 printf("%d ", slaves[i]); 5734 5735 printf("%d]\n", slaves[num_active_slaves - 1]); 5736 5737 } else { 5738 printf("\tActive Slaves: []\n"); 5739 5740 } 5741 5742 primary_id = rte_eth_bond_primary_get(port_id); 5743 if (primary_id < 0) { 5744 printf("\tFailed to get primary slave for port = %d\n", port_id); 5745 return; 5746 } else 5747 printf("\tPrimary: [%d]\n", primary_id); 5748 5749 } 5750 5751 cmdline_parse_token_string_t cmd_showbonding_config_show = 5752 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5753 show, "show"); 5754 cmdline_parse_token_string_t cmd_showbonding_config_bonding = 5755 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5756 bonding, "bonding"); 5757 cmdline_parse_token_string_t cmd_showbonding_config_config = 5758 TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_config_result, 5759 config, "config"); 5760 cmdline_parse_token_num_t cmd_showbonding_config_port = 5761 TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_config_result, 5762 port_id, UINT16); 5763 5764 cmdline_parse_inst_t cmd_show_bonding_config = { 5765 .f = cmd_show_bonding_config_parsed, 5766 .help_str = "show bonding config <port_id>: " 5767 "Show the bonding config for port_id", 5768 .data = NULL, 5769 .tokens = { 5770 (void *)&cmd_showbonding_config_show, 5771 (void *)&cmd_showbonding_config_bonding, 5772 (void *)&cmd_showbonding_config_config, 5773 (void *)&cmd_showbonding_config_port, 5774 NULL 5775 } 5776 }; 5777 5778 /* *** SET BONDING PRIMARY *** */ 5779 struct cmd_set_bonding_primary_result { 5780 cmdline_fixed_string_t set; 5781 cmdline_fixed_string_t bonding; 5782 cmdline_fixed_string_t primary; 5783 portid_t slave_id; 5784 portid_t port_id; 5785 }; 5786 5787 static void cmd_set_bonding_primary_parsed(void *parsed_result, 5788 __attribute__((unused)) struct cmdline *cl, 5789 __attribute__((unused)) void *data) 5790 { 5791 struct cmd_set_bonding_primary_result *res = parsed_result; 5792 portid_t master_port_id = res->port_id; 5793 portid_t slave_port_id = res->slave_id; 5794 5795 /* Set the primary slave for a bonded device. */ 5796 if (0 != rte_eth_bond_primary_set(master_port_id, slave_port_id)) { 5797 printf("\t Failed to set primary slave for port = %d.\n", 5798 master_port_id); 5799 return; 5800 } 5801 init_port_config(); 5802 } 5803 5804 cmdline_parse_token_string_t cmd_setbonding_primary_set = 5805 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5806 set, "set"); 5807 cmdline_parse_token_string_t cmd_setbonding_primary_bonding = 5808 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5809 bonding, "bonding"); 5810 cmdline_parse_token_string_t cmd_setbonding_primary_primary = 5811 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_primary_result, 5812 primary, "primary"); 5813 cmdline_parse_token_num_t cmd_setbonding_primary_slave = 5814 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 5815 slave_id, UINT16); 5816 cmdline_parse_token_num_t cmd_setbonding_primary_port = 5817 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_primary_result, 5818 port_id, UINT16); 5819 5820 cmdline_parse_inst_t cmd_set_bonding_primary = { 5821 .f = cmd_set_bonding_primary_parsed, 5822 .help_str = "set bonding primary <slave_id> <port_id>: " 5823 "Set the primary slave for port_id", 5824 .data = NULL, 5825 .tokens = { 5826 (void *)&cmd_setbonding_primary_set, 5827 (void *)&cmd_setbonding_primary_bonding, 5828 (void *)&cmd_setbonding_primary_primary, 5829 (void *)&cmd_setbonding_primary_slave, 5830 (void *)&cmd_setbonding_primary_port, 5831 NULL 5832 } 5833 }; 5834 5835 /* *** ADD SLAVE *** */ 5836 struct cmd_add_bonding_slave_result { 5837 cmdline_fixed_string_t add; 5838 cmdline_fixed_string_t bonding; 5839 cmdline_fixed_string_t slave; 5840 portid_t slave_id; 5841 portid_t port_id; 5842 }; 5843 5844 static void cmd_add_bonding_slave_parsed(void *parsed_result, 5845 __attribute__((unused)) struct cmdline *cl, 5846 __attribute__((unused)) void *data) 5847 { 5848 struct cmd_add_bonding_slave_result *res = parsed_result; 5849 portid_t master_port_id = res->port_id; 5850 portid_t slave_port_id = res->slave_id; 5851 5852 /* add the slave for a bonded device. */ 5853 if (0 != rte_eth_bond_slave_add(master_port_id, slave_port_id)) { 5854 printf("\t Failed to add slave %d to master port = %d.\n", 5855 slave_port_id, master_port_id); 5856 return; 5857 } 5858 init_port_config(); 5859 set_port_slave_flag(slave_port_id); 5860 } 5861 5862 cmdline_parse_token_string_t cmd_addbonding_slave_add = 5863 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5864 add, "add"); 5865 cmdline_parse_token_string_t cmd_addbonding_slave_bonding = 5866 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5867 bonding, "bonding"); 5868 cmdline_parse_token_string_t cmd_addbonding_slave_slave = 5869 TOKEN_STRING_INITIALIZER(struct cmd_add_bonding_slave_result, 5870 slave, "slave"); 5871 cmdline_parse_token_num_t cmd_addbonding_slave_slaveid = 5872 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 5873 slave_id, UINT16); 5874 cmdline_parse_token_num_t cmd_addbonding_slave_port = 5875 TOKEN_NUM_INITIALIZER(struct cmd_add_bonding_slave_result, 5876 port_id, UINT16); 5877 5878 cmdline_parse_inst_t cmd_add_bonding_slave = { 5879 .f = cmd_add_bonding_slave_parsed, 5880 .help_str = "add bonding slave <slave_id> <port_id>: " 5881 "Add a slave device to a bonded device", 5882 .data = NULL, 5883 .tokens = { 5884 (void *)&cmd_addbonding_slave_add, 5885 (void *)&cmd_addbonding_slave_bonding, 5886 (void *)&cmd_addbonding_slave_slave, 5887 (void *)&cmd_addbonding_slave_slaveid, 5888 (void *)&cmd_addbonding_slave_port, 5889 NULL 5890 } 5891 }; 5892 5893 /* *** REMOVE SLAVE *** */ 5894 struct cmd_remove_bonding_slave_result { 5895 cmdline_fixed_string_t remove; 5896 cmdline_fixed_string_t bonding; 5897 cmdline_fixed_string_t slave; 5898 portid_t slave_id; 5899 portid_t port_id; 5900 }; 5901 5902 static void cmd_remove_bonding_slave_parsed(void *parsed_result, 5903 __attribute__((unused)) struct cmdline *cl, 5904 __attribute__((unused)) void *data) 5905 { 5906 struct cmd_remove_bonding_slave_result *res = parsed_result; 5907 portid_t master_port_id = res->port_id; 5908 portid_t slave_port_id = res->slave_id; 5909 5910 /* remove the slave from a bonded device. */ 5911 if (0 != rte_eth_bond_slave_remove(master_port_id, slave_port_id)) { 5912 printf("\t Failed to remove slave %d from master port = %d.\n", 5913 slave_port_id, master_port_id); 5914 return; 5915 } 5916 init_port_config(); 5917 clear_port_slave_flag(slave_port_id); 5918 } 5919 5920 cmdline_parse_token_string_t cmd_removebonding_slave_remove = 5921 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 5922 remove, "remove"); 5923 cmdline_parse_token_string_t cmd_removebonding_slave_bonding = 5924 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 5925 bonding, "bonding"); 5926 cmdline_parse_token_string_t cmd_removebonding_slave_slave = 5927 TOKEN_STRING_INITIALIZER(struct cmd_remove_bonding_slave_result, 5928 slave, "slave"); 5929 cmdline_parse_token_num_t cmd_removebonding_slave_slaveid = 5930 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 5931 slave_id, UINT16); 5932 cmdline_parse_token_num_t cmd_removebonding_slave_port = 5933 TOKEN_NUM_INITIALIZER(struct cmd_remove_bonding_slave_result, 5934 port_id, UINT16); 5935 5936 cmdline_parse_inst_t cmd_remove_bonding_slave = { 5937 .f = cmd_remove_bonding_slave_parsed, 5938 .help_str = "remove bonding slave <slave_id> <port_id>: " 5939 "Remove a slave device from a bonded device", 5940 .data = NULL, 5941 .tokens = { 5942 (void *)&cmd_removebonding_slave_remove, 5943 (void *)&cmd_removebonding_slave_bonding, 5944 (void *)&cmd_removebonding_slave_slave, 5945 (void *)&cmd_removebonding_slave_slaveid, 5946 (void *)&cmd_removebonding_slave_port, 5947 NULL 5948 } 5949 }; 5950 5951 /* *** CREATE BONDED DEVICE *** */ 5952 struct cmd_create_bonded_device_result { 5953 cmdline_fixed_string_t create; 5954 cmdline_fixed_string_t bonded; 5955 cmdline_fixed_string_t device; 5956 uint8_t mode; 5957 uint8_t socket; 5958 }; 5959 5960 static int bond_dev_num = 0; 5961 5962 static void cmd_create_bonded_device_parsed(void *parsed_result, 5963 __attribute__((unused)) struct cmdline *cl, 5964 __attribute__((unused)) void *data) 5965 { 5966 struct cmd_create_bonded_device_result *res = parsed_result; 5967 char ethdev_name[RTE_ETH_NAME_MAX_LEN]; 5968 int port_id; 5969 5970 if (test_done == 0) { 5971 printf("Please stop forwarding first\n"); 5972 return; 5973 } 5974 5975 snprintf(ethdev_name, RTE_ETH_NAME_MAX_LEN, "net_bonding_testpmd_%d", 5976 bond_dev_num++); 5977 5978 /* Create a new bonded device. */ 5979 port_id = rte_eth_bond_create(ethdev_name, res->mode, res->socket); 5980 if (port_id < 0) { 5981 printf("\t Failed to create bonded device.\n"); 5982 return; 5983 } else { 5984 printf("Created new bonded device %s on (port %d).\n", ethdev_name, 5985 port_id); 5986 5987 /* Update number of ports */ 5988 nb_ports = rte_eth_dev_count_avail(); 5989 reconfig(port_id, res->socket); 5990 rte_eth_promiscuous_enable(port_id); 5991 ports[port_id].need_setup = 0; 5992 ports[port_id].port_status = RTE_PORT_STOPPED; 5993 } 5994 5995 } 5996 5997 cmdline_parse_token_string_t cmd_createbonded_device_create = 5998 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 5999 create, "create"); 6000 cmdline_parse_token_string_t cmd_createbonded_device_bonded = 6001 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6002 bonded, "bonded"); 6003 cmdline_parse_token_string_t cmd_createbonded_device_device = 6004 TOKEN_STRING_INITIALIZER(struct cmd_create_bonded_device_result, 6005 device, "device"); 6006 cmdline_parse_token_num_t cmd_createbonded_device_mode = 6007 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6008 mode, UINT8); 6009 cmdline_parse_token_num_t cmd_createbonded_device_socket = 6010 TOKEN_NUM_INITIALIZER(struct cmd_create_bonded_device_result, 6011 socket, UINT8); 6012 6013 cmdline_parse_inst_t cmd_create_bonded_device = { 6014 .f = cmd_create_bonded_device_parsed, 6015 .help_str = "create bonded device <mode> <socket>: " 6016 "Create a new bonded device with specific bonding mode and socket", 6017 .data = NULL, 6018 .tokens = { 6019 (void *)&cmd_createbonded_device_create, 6020 (void *)&cmd_createbonded_device_bonded, 6021 (void *)&cmd_createbonded_device_device, 6022 (void *)&cmd_createbonded_device_mode, 6023 (void *)&cmd_createbonded_device_socket, 6024 NULL 6025 } 6026 }; 6027 6028 /* *** SET MAC ADDRESS IN BONDED DEVICE *** */ 6029 struct cmd_set_bond_mac_addr_result { 6030 cmdline_fixed_string_t set; 6031 cmdline_fixed_string_t bonding; 6032 cmdline_fixed_string_t mac_addr; 6033 uint16_t port_num; 6034 struct ether_addr address; 6035 }; 6036 6037 static void cmd_set_bond_mac_addr_parsed(void *parsed_result, 6038 __attribute__((unused)) struct cmdline *cl, 6039 __attribute__((unused)) void *data) 6040 { 6041 struct cmd_set_bond_mac_addr_result *res = parsed_result; 6042 int ret; 6043 6044 if (port_id_is_invalid(res->port_num, ENABLED_WARN)) 6045 return; 6046 6047 ret = rte_eth_bond_mac_address_set(res->port_num, &res->address); 6048 6049 /* check the return value and print it if is < 0 */ 6050 if (ret < 0) 6051 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6052 } 6053 6054 cmdline_parse_token_string_t cmd_set_bond_mac_addr_set = 6055 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, set, "set"); 6056 cmdline_parse_token_string_t cmd_set_bond_mac_addr_bonding = 6057 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, bonding, 6058 "bonding"); 6059 cmdline_parse_token_string_t cmd_set_bond_mac_addr_mac = 6060 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mac_addr_result, mac_addr, 6061 "mac_addr"); 6062 cmdline_parse_token_num_t cmd_set_bond_mac_addr_portnum = 6063 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mac_addr_result, 6064 port_num, UINT16); 6065 cmdline_parse_token_etheraddr_t cmd_set_bond_mac_addr_addr = 6066 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_bond_mac_addr_result, address); 6067 6068 cmdline_parse_inst_t cmd_set_bond_mac_addr = { 6069 .f = cmd_set_bond_mac_addr_parsed, 6070 .data = (void *) 0, 6071 .help_str = "set bonding mac_addr <port_id> <mac_addr>", 6072 .tokens = { 6073 (void *)&cmd_set_bond_mac_addr_set, 6074 (void *)&cmd_set_bond_mac_addr_bonding, 6075 (void *)&cmd_set_bond_mac_addr_mac, 6076 (void *)&cmd_set_bond_mac_addr_portnum, 6077 (void *)&cmd_set_bond_mac_addr_addr, 6078 NULL 6079 } 6080 }; 6081 6082 6083 /* *** SET LINK STATUS MONITORING POLLING PERIOD ON BONDED DEVICE *** */ 6084 struct cmd_set_bond_mon_period_result { 6085 cmdline_fixed_string_t set; 6086 cmdline_fixed_string_t bonding; 6087 cmdline_fixed_string_t mon_period; 6088 uint16_t port_num; 6089 uint32_t period_ms; 6090 }; 6091 6092 static void cmd_set_bond_mon_period_parsed(void *parsed_result, 6093 __attribute__((unused)) struct cmdline *cl, 6094 __attribute__((unused)) void *data) 6095 { 6096 struct cmd_set_bond_mon_period_result *res = parsed_result; 6097 int ret; 6098 6099 ret = rte_eth_bond_link_monitoring_set(res->port_num, res->period_ms); 6100 6101 /* check the return value and print it if is < 0 */ 6102 if (ret < 0) 6103 printf("set_bond_mac_addr error: (%s)\n", strerror(-ret)); 6104 } 6105 6106 cmdline_parse_token_string_t cmd_set_bond_mon_period_set = 6107 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6108 set, "set"); 6109 cmdline_parse_token_string_t cmd_set_bond_mon_period_bonding = 6110 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6111 bonding, "bonding"); 6112 cmdline_parse_token_string_t cmd_set_bond_mon_period_mon_period = 6113 TOKEN_STRING_INITIALIZER(struct cmd_set_bond_mon_period_result, 6114 mon_period, "mon_period"); 6115 cmdline_parse_token_num_t cmd_set_bond_mon_period_portnum = 6116 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6117 port_num, UINT16); 6118 cmdline_parse_token_num_t cmd_set_bond_mon_period_period_ms = 6119 TOKEN_NUM_INITIALIZER(struct cmd_set_bond_mon_period_result, 6120 period_ms, UINT32); 6121 6122 cmdline_parse_inst_t cmd_set_bond_mon_period = { 6123 .f = cmd_set_bond_mon_period_parsed, 6124 .data = (void *) 0, 6125 .help_str = "set bonding mon_period <port_id> <period_ms>", 6126 .tokens = { 6127 (void *)&cmd_set_bond_mon_period_set, 6128 (void *)&cmd_set_bond_mon_period_bonding, 6129 (void *)&cmd_set_bond_mon_period_mon_period, 6130 (void *)&cmd_set_bond_mon_period_portnum, 6131 (void *)&cmd_set_bond_mon_period_period_ms, 6132 NULL 6133 } 6134 }; 6135 6136 6137 6138 struct cmd_set_bonding_agg_mode_policy_result { 6139 cmdline_fixed_string_t set; 6140 cmdline_fixed_string_t bonding; 6141 cmdline_fixed_string_t agg_mode; 6142 uint16_t port_num; 6143 cmdline_fixed_string_t policy; 6144 }; 6145 6146 6147 static void 6148 cmd_set_bonding_agg_mode(void *parsed_result, 6149 __attribute__((unused)) struct cmdline *cl, 6150 __attribute__((unused)) void *data) 6151 { 6152 struct cmd_set_bonding_agg_mode_policy_result *res = parsed_result; 6153 uint8_t policy = AGG_BANDWIDTH; 6154 6155 if (!strcmp(res->policy, "bandwidth")) 6156 policy = AGG_BANDWIDTH; 6157 else if (!strcmp(res->policy, "stable")) 6158 policy = AGG_STABLE; 6159 else if (!strcmp(res->policy, "count")) 6160 policy = AGG_COUNT; 6161 6162 rte_eth_bond_8023ad_agg_selection_set(res->port_num, policy); 6163 } 6164 6165 6166 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_set = 6167 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6168 set, "set"); 6169 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_bonding = 6170 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6171 bonding, "bonding"); 6172 6173 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_agg_mode = 6174 TOKEN_STRING_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6175 agg_mode, "agg_mode"); 6176 6177 cmdline_parse_token_num_t cmd_set_bonding_agg_mode_portnum = 6178 TOKEN_NUM_INITIALIZER(struct cmd_set_bonding_agg_mode_policy_result, 6179 port_num, UINT16); 6180 6181 cmdline_parse_token_string_t cmd_set_bonding_agg_mode_policy_string = 6182 TOKEN_STRING_INITIALIZER( 6183 struct cmd_set_bonding_balance_xmit_policy_result, 6184 policy, "stable#bandwidth#count"); 6185 6186 cmdline_parse_inst_t cmd_set_bonding_agg_mode_policy = { 6187 .f = cmd_set_bonding_agg_mode, 6188 .data = (void *) 0, 6189 .help_str = "set bonding mode IEEE802.3AD aggregator policy <port_id> <agg_name>", 6190 .tokens = { 6191 (void *)&cmd_set_bonding_agg_mode_set, 6192 (void *)&cmd_set_bonding_agg_mode_bonding, 6193 (void *)&cmd_set_bonding_agg_mode_agg_mode, 6194 (void *)&cmd_set_bonding_agg_mode_portnum, 6195 (void *)&cmd_set_bonding_agg_mode_policy_string, 6196 NULL 6197 } 6198 }; 6199 6200 6201 #endif /* RTE_LIBRTE_PMD_BOND */ 6202 6203 /* *** SET FORWARDING MODE *** */ 6204 struct cmd_set_fwd_mode_result { 6205 cmdline_fixed_string_t set; 6206 cmdline_fixed_string_t fwd; 6207 cmdline_fixed_string_t mode; 6208 }; 6209 6210 static void cmd_set_fwd_mode_parsed(void *parsed_result, 6211 __attribute__((unused)) struct cmdline *cl, 6212 __attribute__((unused)) void *data) 6213 { 6214 struct cmd_set_fwd_mode_result *res = parsed_result; 6215 6216 retry_enabled = 0; 6217 set_pkt_forwarding_mode(res->mode); 6218 } 6219 6220 cmdline_parse_token_string_t cmd_setfwd_set = 6221 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, set, "set"); 6222 cmdline_parse_token_string_t cmd_setfwd_fwd = 6223 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd"); 6224 cmdline_parse_token_string_t cmd_setfwd_mode = 6225 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode, 6226 "" /* defined at init */); 6227 6228 cmdline_parse_inst_t cmd_set_fwd_mode = { 6229 .f = cmd_set_fwd_mode_parsed, 6230 .data = NULL, 6231 .help_str = NULL, /* defined at init */ 6232 .tokens = { 6233 (void *)&cmd_setfwd_set, 6234 (void *)&cmd_setfwd_fwd, 6235 (void *)&cmd_setfwd_mode, 6236 NULL, 6237 }, 6238 }; 6239 6240 static void cmd_set_fwd_mode_init(void) 6241 { 6242 char *modes, *c; 6243 static char token[128]; 6244 static char help[256]; 6245 cmdline_parse_token_string_t *token_struct; 6246 6247 modes = list_pkt_forwarding_modes(); 6248 snprintf(help, sizeof(help), "set fwd %s: " 6249 "Set packet forwarding mode", modes); 6250 cmd_set_fwd_mode.help_str = help; 6251 6252 /* string token separator is # */ 6253 for (c = token; *modes != '\0'; modes++) 6254 if (*modes == '|') 6255 *c++ = '#'; 6256 else 6257 *c++ = *modes; 6258 token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2]; 6259 token_struct->string_data.str = token; 6260 } 6261 6262 /* *** SET RETRY FORWARDING MODE *** */ 6263 struct cmd_set_fwd_retry_mode_result { 6264 cmdline_fixed_string_t set; 6265 cmdline_fixed_string_t fwd; 6266 cmdline_fixed_string_t mode; 6267 cmdline_fixed_string_t retry; 6268 }; 6269 6270 static void cmd_set_fwd_retry_mode_parsed(void *parsed_result, 6271 __attribute__((unused)) struct cmdline *cl, 6272 __attribute__((unused)) void *data) 6273 { 6274 struct cmd_set_fwd_retry_mode_result *res = parsed_result; 6275 6276 retry_enabled = 1; 6277 set_pkt_forwarding_mode(res->mode); 6278 } 6279 6280 cmdline_parse_token_string_t cmd_setfwd_retry_set = 6281 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6282 set, "set"); 6283 cmdline_parse_token_string_t cmd_setfwd_retry_fwd = 6284 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6285 fwd, "fwd"); 6286 cmdline_parse_token_string_t cmd_setfwd_retry_mode = 6287 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6288 mode, 6289 "" /* defined at init */); 6290 cmdline_parse_token_string_t cmd_setfwd_retry_retry = 6291 TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_retry_mode_result, 6292 retry, "retry"); 6293 6294 cmdline_parse_inst_t cmd_set_fwd_retry_mode = { 6295 .f = cmd_set_fwd_retry_mode_parsed, 6296 .data = NULL, 6297 .help_str = NULL, /* defined at init */ 6298 .tokens = { 6299 (void *)&cmd_setfwd_retry_set, 6300 (void *)&cmd_setfwd_retry_fwd, 6301 (void *)&cmd_setfwd_retry_mode, 6302 (void *)&cmd_setfwd_retry_retry, 6303 NULL, 6304 }, 6305 }; 6306 6307 static void cmd_set_fwd_retry_mode_init(void) 6308 { 6309 char *modes, *c; 6310 static char token[128]; 6311 static char help[256]; 6312 cmdline_parse_token_string_t *token_struct; 6313 6314 modes = list_pkt_forwarding_retry_modes(); 6315 snprintf(help, sizeof(help), "set fwd %s retry: " 6316 "Set packet forwarding mode with retry", modes); 6317 cmd_set_fwd_retry_mode.help_str = help; 6318 6319 /* string token separator is # */ 6320 for (c = token; *modes != '\0'; modes++) 6321 if (*modes == '|') 6322 *c++ = '#'; 6323 else 6324 *c++ = *modes; 6325 token_struct = (cmdline_parse_token_string_t *) 6326 cmd_set_fwd_retry_mode.tokens[2]; 6327 token_struct->string_data.str = token; 6328 } 6329 6330 /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */ 6331 struct cmd_set_burst_tx_retry_result { 6332 cmdline_fixed_string_t set; 6333 cmdline_fixed_string_t burst; 6334 cmdline_fixed_string_t tx; 6335 cmdline_fixed_string_t delay; 6336 uint32_t time; 6337 cmdline_fixed_string_t retry; 6338 uint32_t retry_num; 6339 }; 6340 6341 static void cmd_set_burst_tx_retry_parsed(void *parsed_result, 6342 __attribute__((unused)) struct cmdline *cl, 6343 __attribute__((unused)) void *data) 6344 { 6345 struct cmd_set_burst_tx_retry_result *res = parsed_result; 6346 6347 if (!strcmp(res->set, "set") && !strcmp(res->burst, "burst") 6348 && !strcmp(res->tx, "tx")) { 6349 if (!strcmp(res->delay, "delay")) 6350 burst_tx_delay_time = res->time; 6351 if (!strcmp(res->retry, "retry")) 6352 burst_tx_retry_num = res->retry_num; 6353 } 6354 6355 } 6356 6357 cmdline_parse_token_string_t cmd_set_burst_tx_retry_set = 6358 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, set, "set"); 6359 cmdline_parse_token_string_t cmd_set_burst_tx_retry_burst = 6360 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, burst, 6361 "burst"); 6362 cmdline_parse_token_string_t cmd_set_burst_tx_retry_tx = 6363 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, tx, "tx"); 6364 cmdline_parse_token_string_t cmd_set_burst_tx_retry_delay = 6365 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, delay, "delay"); 6366 cmdline_parse_token_num_t cmd_set_burst_tx_retry_time = 6367 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, time, UINT32); 6368 cmdline_parse_token_string_t cmd_set_burst_tx_retry_retry = 6369 TOKEN_STRING_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry, "retry"); 6370 cmdline_parse_token_num_t cmd_set_burst_tx_retry_retry_num = 6371 TOKEN_NUM_INITIALIZER(struct cmd_set_burst_tx_retry_result, retry_num, UINT32); 6372 6373 cmdline_parse_inst_t cmd_set_burst_tx_retry = { 6374 .f = cmd_set_burst_tx_retry_parsed, 6375 .help_str = "set burst tx delay <delay_usec> retry <num_retry>", 6376 .tokens = { 6377 (void *)&cmd_set_burst_tx_retry_set, 6378 (void *)&cmd_set_burst_tx_retry_burst, 6379 (void *)&cmd_set_burst_tx_retry_tx, 6380 (void *)&cmd_set_burst_tx_retry_delay, 6381 (void *)&cmd_set_burst_tx_retry_time, 6382 (void *)&cmd_set_burst_tx_retry_retry, 6383 (void *)&cmd_set_burst_tx_retry_retry_num, 6384 NULL, 6385 }, 6386 }; 6387 6388 /* *** SET PROMISC MODE *** */ 6389 struct cmd_set_promisc_mode_result { 6390 cmdline_fixed_string_t set; 6391 cmdline_fixed_string_t promisc; 6392 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6393 uint16_t port_num; /* valid if "allports" argument == 0 */ 6394 cmdline_fixed_string_t mode; 6395 }; 6396 6397 static void cmd_set_promisc_mode_parsed(void *parsed_result, 6398 __attribute__((unused)) struct cmdline *cl, 6399 void *allports) 6400 { 6401 struct cmd_set_promisc_mode_result *res = parsed_result; 6402 int enable; 6403 portid_t i; 6404 6405 if (!strcmp(res->mode, "on")) 6406 enable = 1; 6407 else 6408 enable = 0; 6409 6410 /* all ports */ 6411 if (allports) { 6412 RTE_ETH_FOREACH_DEV(i) { 6413 if (enable) 6414 rte_eth_promiscuous_enable(i); 6415 else 6416 rte_eth_promiscuous_disable(i); 6417 } 6418 } 6419 else { 6420 if (enable) 6421 rte_eth_promiscuous_enable(res->port_num); 6422 else 6423 rte_eth_promiscuous_disable(res->port_num); 6424 } 6425 } 6426 6427 cmdline_parse_token_string_t cmd_setpromisc_set = 6428 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, set, "set"); 6429 cmdline_parse_token_string_t cmd_setpromisc_promisc = 6430 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, promisc, 6431 "promisc"); 6432 cmdline_parse_token_string_t cmd_setpromisc_portall = 6433 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, port_all, 6434 "all"); 6435 cmdline_parse_token_num_t cmd_setpromisc_portnum = 6436 TOKEN_NUM_INITIALIZER(struct cmd_set_promisc_mode_result, port_num, 6437 UINT16); 6438 cmdline_parse_token_string_t cmd_setpromisc_mode = 6439 TOKEN_STRING_INITIALIZER(struct cmd_set_promisc_mode_result, mode, 6440 "on#off"); 6441 6442 cmdline_parse_inst_t cmd_set_promisc_mode_all = { 6443 .f = cmd_set_promisc_mode_parsed, 6444 .data = (void *)1, 6445 .help_str = "set promisc all on|off: Set promisc mode for all ports", 6446 .tokens = { 6447 (void *)&cmd_setpromisc_set, 6448 (void *)&cmd_setpromisc_promisc, 6449 (void *)&cmd_setpromisc_portall, 6450 (void *)&cmd_setpromisc_mode, 6451 NULL, 6452 }, 6453 }; 6454 6455 cmdline_parse_inst_t cmd_set_promisc_mode_one = { 6456 .f = cmd_set_promisc_mode_parsed, 6457 .data = (void *)0, 6458 .help_str = "set promisc <port_id> on|off: Set promisc mode on port_id", 6459 .tokens = { 6460 (void *)&cmd_setpromisc_set, 6461 (void *)&cmd_setpromisc_promisc, 6462 (void *)&cmd_setpromisc_portnum, 6463 (void *)&cmd_setpromisc_mode, 6464 NULL, 6465 }, 6466 }; 6467 6468 /* *** SET ALLMULTI MODE *** */ 6469 struct cmd_set_allmulti_mode_result { 6470 cmdline_fixed_string_t set; 6471 cmdline_fixed_string_t allmulti; 6472 cmdline_fixed_string_t port_all; /* valid if "allports" argument == 1 */ 6473 uint16_t port_num; /* valid if "allports" argument == 0 */ 6474 cmdline_fixed_string_t mode; 6475 }; 6476 6477 static void cmd_set_allmulti_mode_parsed(void *parsed_result, 6478 __attribute__((unused)) struct cmdline *cl, 6479 void *allports) 6480 { 6481 struct cmd_set_allmulti_mode_result *res = parsed_result; 6482 int enable; 6483 portid_t i; 6484 6485 if (!strcmp(res->mode, "on")) 6486 enable = 1; 6487 else 6488 enable = 0; 6489 6490 /* all ports */ 6491 if (allports) { 6492 RTE_ETH_FOREACH_DEV(i) { 6493 if (enable) 6494 rte_eth_allmulticast_enable(i); 6495 else 6496 rte_eth_allmulticast_disable(i); 6497 } 6498 } 6499 else { 6500 if (enable) 6501 rte_eth_allmulticast_enable(res->port_num); 6502 else 6503 rte_eth_allmulticast_disable(res->port_num); 6504 } 6505 } 6506 6507 cmdline_parse_token_string_t cmd_setallmulti_set = 6508 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, set, "set"); 6509 cmdline_parse_token_string_t cmd_setallmulti_allmulti = 6510 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, allmulti, 6511 "allmulti"); 6512 cmdline_parse_token_string_t cmd_setallmulti_portall = 6513 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, port_all, 6514 "all"); 6515 cmdline_parse_token_num_t cmd_setallmulti_portnum = 6516 TOKEN_NUM_INITIALIZER(struct cmd_set_allmulti_mode_result, port_num, 6517 UINT16); 6518 cmdline_parse_token_string_t cmd_setallmulti_mode = 6519 TOKEN_STRING_INITIALIZER(struct cmd_set_allmulti_mode_result, mode, 6520 "on#off"); 6521 6522 cmdline_parse_inst_t cmd_set_allmulti_mode_all = { 6523 .f = cmd_set_allmulti_mode_parsed, 6524 .data = (void *)1, 6525 .help_str = "set allmulti all on|off: Set allmulti mode for all ports", 6526 .tokens = { 6527 (void *)&cmd_setallmulti_set, 6528 (void *)&cmd_setallmulti_allmulti, 6529 (void *)&cmd_setallmulti_portall, 6530 (void *)&cmd_setallmulti_mode, 6531 NULL, 6532 }, 6533 }; 6534 6535 cmdline_parse_inst_t cmd_set_allmulti_mode_one = { 6536 .f = cmd_set_allmulti_mode_parsed, 6537 .data = (void *)0, 6538 .help_str = "set allmulti <port_id> on|off: " 6539 "Set allmulti mode on port_id", 6540 .tokens = { 6541 (void *)&cmd_setallmulti_set, 6542 (void *)&cmd_setallmulti_allmulti, 6543 (void *)&cmd_setallmulti_portnum, 6544 (void *)&cmd_setallmulti_mode, 6545 NULL, 6546 }, 6547 }; 6548 6549 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */ 6550 struct cmd_link_flow_ctrl_set_result { 6551 cmdline_fixed_string_t set; 6552 cmdline_fixed_string_t flow_ctrl; 6553 cmdline_fixed_string_t rx; 6554 cmdline_fixed_string_t rx_lfc_mode; 6555 cmdline_fixed_string_t tx; 6556 cmdline_fixed_string_t tx_lfc_mode; 6557 cmdline_fixed_string_t mac_ctrl_frame_fwd; 6558 cmdline_fixed_string_t mac_ctrl_frame_fwd_mode; 6559 cmdline_fixed_string_t autoneg_str; 6560 cmdline_fixed_string_t autoneg; 6561 cmdline_fixed_string_t hw_str; 6562 uint32_t high_water; 6563 cmdline_fixed_string_t lw_str; 6564 uint32_t low_water; 6565 cmdline_fixed_string_t pt_str; 6566 uint16_t pause_time; 6567 cmdline_fixed_string_t xon_str; 6568 uint16_t send_xon; 6569 portid_t port_id; 6570 }; 6571 6572 cmdline_parse_token_string_t cmd_lfc_set_set = 6573 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6574 set, "set"); 6575 cmdline_parse_token_string_t cmd_lfc_set_flow_ctrl = 6576 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6577 flow_ctrl, "flow_ctrl"); 6578 cmdline_parse_token_string_t cmd_lfc_set_rx = 6579 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6580 rx, "rx"); 6581 cmdline_parse_token_string_t cmd_lfc_set_rx_mode = 6582 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6583 rx_lfc_mode, "on#off"); 6584 cmdline_parse_token_string_t cmd_lfc_set_tx = 6585 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6586 tx, "tx"); 6587 cmdline_parse_token_string_t cmd_lfc_set_tx_mode = 6588 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6589 tx_lfc_mode, "on#off"); 6590 cmdline_parse_token_string_t cmd_lfc_set_high_water_str = 6591 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6592 hw_str, "high_water"); 6593 cmdline_parse_token_num_t cmd_lfc_set_high_water = 6594 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6595 high_water, UINT32); 6596 cmdline_parse_token_string_t cmd_lfc_set_low_water_str = 6597 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6598 lw_str, "low_water"); 6599 cmdline_parse_token_num_t cmd_lfc_set_low_water = 6600 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6601 low_water, UINT32); 6602 cmdline_parse_token_string_t cmd_lfc_set_pause_time_str = 6603 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6604 pt_str, "pause_time"); 6605 cmdline_parse_token_num_t cmd_lfc_set_pause_time = 6606 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6607 pause_time, UINT16); 6608 cmdline_parse_token_string_t cmd_lfc_set_send_xon_str = 6609 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6610 xon_str, "send_xon"); 6611 cmdline_parse_token_num_t cmd_lfc_set_send_xon = 6612 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6613 send_xon, UINT16); 6614 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode = 6615 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6616 mac_ctrl_frame_fwd, "mac_ctrl_frame_fwd"); 6617 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd = 6618 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6619 mac_ctrl_frame_fwd_mode, "on#off"); 6620 cmdline_parse_token_string_t cmd_lfc_set_autoneg_str = 6621 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6622 autoneg_str, "autoneg"); 6623 cmdline_parse_token_string_t cmd_lfc_set_autoneg = 6624 TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6625 autoneg, "on#off"); 6626 cmdline_parse_token_num_t cmd_lfc_set_portid = 6627 TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result, 6628 port_id, UINT16); 6629 6630 /* forward declaration */ 6631 static void 6632 cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl, 6633 void *data); 6634 6635 cmdline_parse_inst_t cmd_link_flow_control_set = { 6636 .f = cmd_link_flow_ctrl_set_parsed, 6637 .data = NULL, 6638 .help_str = "set flow_ctrl rx on|off tx on|off <high_water> " 6639 "<low_water> <pause_time> <send_xon> mac_ctrl_frame_fwd on|off " 6640 "autoneg on|off <port_id>: Configure the Ethernet flow control", 6641 .tokens = { 6642 (void *)&cmd_lfc_set_set, 6643 (void *)&cmd_lfc_set_flow_ctrl, 6644 (void *)&cmd_lfc_set_rx, 6645 (void *)&cmd_lfc_set_rx_mode, 6646 (void *)&cmd_lfc_set_tx, 6647 (void *)&cmd_lfc_set_tx_mode, 6648 (void *)&cmd_lfc_set_high_water, 6649 (void *)&cmd_lfc_set_low_water, 6650 (void *)&cmd_lfc_set_pause_time, 6651 (void *)&cmd_lfc_set_send_xon, 6652 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6653 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6654 (void *)&cmd_lfc_set_autoneg_str, 6655 (void *)&cmd_lfc_set_autoneg, 6656 (void *)&cmd_lfc_set_portid, 6657 NULL, 6658 }, 6659 }; 6660 6661 cmdline_parse_inst_t cmd_link_flow_control_set_rx = { 6662 .f = cmd_link_flow_ctrl_set_parsed, 6663 .data = (void *)&cmd_link_flow_control_set_rx, 6664 .help_str = "set flow_ctrl rx on|off <port_id>: " 6665 "Change rx flow control parameter", 6666 .tokens = { 6667 (void *)&cmd_lfc_set_set, 6668 (void *)&cmd_lfc_set_flow_ctrl, 6669 (void *)&cmd_lfc_set_rx, 6670 (void *)&cmd_lfc_set_rx_mode, 6671 (void *)&cmd_lfc_set_portid, 6672 NULL, 6673 }, 6674 }; 6675 6676 cmdline_parse_inst_t cmd_link_flow_control_set_tx = { 6677 .f = cmd_link_flow_ctrl_set_parsed, 6678 .data = (void *)&cmd_link_flow_control_set_tx, 6679 .help_str = "set flow_ctrl tx on|off <port_id>: " 6680 "Change tx flow control parameter", 6681 .tokens = { 6682 (void *)&cmd_lfc_set_set, 6683 (void *)&cmd_lfc_set_flow_ctrl, 6684 (void *)&cmd_lfc_set_tx, 6685 (void *)&cmd_lfc_set_tx_mode, 6686 (void *)&cmd_lfc_set_portid, 6687 NULL, 6688 }, 6689 }; 6690 6691 cmdline_parse_inst_t cmd_link_flow_control_set_hw = { 6692 .f = cmd_link_flow_ctrl_set_parsed, 6693 .data = (void *)&cmd_link_flow_control_set_hw, 6694 .help_str = "set flow_ctrl high_water <value> <port_id>: " 6695 "Change high water flow control parameter", 6696 .tokens = { 6697 (void *)&cmd_lfc_set_set, 6698 (void *)&cmd_lfc_set_flow_ctrl, 6699 (void *)&cmd_lfc_set_high_water_str, 6700 (void *)&cmd_lfc_set_high_water, 6701 (void *)&cmd_lfc_set_portid, 6702 NULL, 6703 }, 6704 }; 6705 6706 cmdline_parse_inst_t cmd_link_flow_control_set_lw = { 6707 .f = cmd_link_flow_ctrl_set_parsed, 6708 .data = (void *)&cmd_link_flow_control_set_lw, 6709 .help_str = "set flow_ctrl low_water <value> <port_id>: " 6710 "Change low water flow control parameter", 6711 .tokens = { 6712 (void *)&cmd_lfc_set_set, 6713 (void *)&cmd_lfc_set_flow_ctrl, 6714 (void *)&cmd_lfc_set_low_water_str, 6715 (void *)&cmd_lfc_set_low_water, 6716 (void *)&cmd_lfc_set_portid, 6717 NULL, 6718 }, 6719 }; 6720 6721 cmdline_parse_inst_t cmd_link_flow_control_set_pt = { 6722 .f = cmd_link_flow_ctrl_set_parsed, 6723 .data = (void *)&cmd_link_flow_control_set_pt, 6724 .help_str = "set flow_ctrl pause_time <value> <port_id>: " 6725 "Change pause time flow control parameter", 6726 .tokens = { 6727 (void *)&cmd_lfc_set_set, 6728 (void *)&cmd_lfc_set_flow_ctrl, 6729 (void *)&cmd_lfc_set_pause_time_str, 6730 (void *)&cmd_lfc_set_pause_time, 6731 (void *)&cmd_lfc_set_portid, 6732 NULL, 6733 }, 6734 }; 6735 6736 cmdline_parse_inst_t cmd_link_flow_control_set_xon = { 6737 .f = cmd_link_flow_ctrl_set_parsed, 6738 .data = (void *)&cmd_link_flow_control_set_xon, 6739 .help_str = "set flow_ctrl send_xon <value> <port_id>: " 6740 "Change send_xon flow control parameter", 6741 .tokens = { 6742 (void *)&cmd_lfc_set_set, 6743 (void *)&cmd_lfc_set_flow_ctrl, 6744 (void *)&cmd_lfc_set_send_xon_str, 6745 (void *)&cmd_lfc_set_send_xon, 6746 (void *)&cmd_lfc_set_portid, 6747 NULL, 6748 }, 6749 }; 6750 6751 cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = { 6752 .f = cmd_link_flow_ctrl_set_parsed, 6753 .data = (void *)&cmd_link_flow_control_set_macfwd, 6754 .help_str = "set flow_ctrl mac_ctrl_frame_fwd on|off <port_id>: " 6755 "Change mac ctrl fwd flow control parameter", 6756 .tokens = { 6757 (void *)&cmd_lfc_set_set, 6758 (void *)&cmd_lfc_set_flow_ctrl, 6759 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode, 6760 (void *)&cmd_lfc_set_mac_ctrl_frame_fwd, 6761 (void *)&cmd_lfc_set_portid, 6762 NULL, 6763 }, 6764 }; 6765 6766 cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = { 6767 .f = cmd_link_flow_ctrl_set_parsed, 6768 .data = (void *)&cmd_link_flow_control_set_autoneg, 6769 .help_str = "set flow_ctrl autoneg on|off <port_id>: " 6770 "Change autoneg flow control parameter", 6771 .tokens = { 6772 (void *)&cmd_lfc_set_set, 6773 (void *)&cmd_lfc_set_flow_ctrl, 6774 (void *)&cmd_lfc_set_autoneg_str, 6775 (void *)&cmd_lfc_set_autoneg, 6776 (void *)&cmd_lfc_set_portid, 6777 NULL, 6778 }, 6779 }; 6780 6781 static void 6782 cmd_link_flow_ctrl_set_parsed(void *parsed_result, 6783 __attribute__((unused)) struct cmdline *cl, 6784 void *data) 6785 { 6786 struct cmd_link_flow_ctrl_set_result *res = parsed_result; 6787 cmdline_parse_inst_t *cmd = data; 6788 struct rte_eth_fc_conf fc_conf; 6789 int rx_fc_en = 0; 6790 int tx_fc_en = 0; 6791 int ret; 6792 6793 /* 6794 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6795 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6796 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6797 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6798 */ 6799 static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = { 6800 {RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL} 6801 }; 6802 6803 /* Partial command line, retrieve current configuration */ 6804 if (cmd) { 6805 ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); 6806 if (ret != 0) { 6807 printf("cannot get current flow ctrl parameters, return" 6808 "code = %d\n", ret); 6809 return; 6810 } 6811 6812 if ((fc_conf.mode == RTE_FC_RX_PAUSE) || 6813 (fc_conf.mode == RTE_FC_FULL)) 6814 rx_fc_en = 1; 6815 if ((fc_conf.mode == RTE_FC_TX_PAUSE) || 6816 (fc_conf.mode == RTE_FC_FULL)) 6817 tx_fc_en = 1; 6818 } 6819 6820 if (!cmd || cmd == &cmd_link_flow_control_set_rx) 6821 rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0; 6822 6823 if (!cmd || cmd == &cmd_link_flow_control_set_tx) 6824 tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0; 6825 6826 fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en]; 6827 6828 if (!cmd || cmd == &cmd_link_flow_control_set_hw) 6829 fc_conf.high_water = res->high_water; 6830 6831 if (!cmd || cmd == &cmd_link_flow_control_set_lw) 6832 fc_conf.low_water = res->low_water; 6833 6834 if (!cmd || cmd == &cmd_link_flow_control_set_pt) 6835 fc_conf.pause_time = res->pause_time; 6836 6837 if (!cmd || cmd == &cmd_link_flow_control_set_xon) 6838 fc_conf.send_xon = res->send_xon; 6839 6840 if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) { 6841 if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) 6842 fc_conf.mac_ctrl_frame_fwd = 1; 6843 else 6844 fc_conf.mac_ctrl_frame_fwd = 0; 6845 } 6846 6847 if (!cmd || cmd == &cmd_link_flow_control_set_autoneg) 6848 fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0; 6849 6850 ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf); 6851 if (ret != 0) 6852 printf("bad flow contrl parameter, return code = %d \n", ret); 6853 } 6854 6855 /* *** SETUP ETHERNET PRIORITY FLOW CONTROL *** */ 6856 struct cmd_priority_flow_ctrl_set_result { 6857 cmdline_fixed_string_t set; 6858 cmdline_fixed_string_t pfc_ctrl; 6859 cmdline_fixed_string_t rx; 6860 cmdline_fixed_string_t rx_pfc_mode; 6861 cmdline_fixed_string_t tx; 6862 cmdline_fixed_string_t tx_pfc_mode; 6863 uint32_t high_water; 6864 uint32_t low_water; 6865 uint16_t pause_time; 6866 uint8_t priority; 6867 portid_t port_id; 6868 }; 6869 6870 static void 6871 cmd_priority_flow_ctrl_set_parsed(void *parsed_result, 6872 __attribute__((unused)) struct cmdline *cl, 6873 __attribute__((unused)) void *data) 6874 { 6875 struct cmd_priority_flow_ctrl_set_result *res = parsed_result; 6876 struct rte_eth_pfc_conf pfc_conf; 6877 int rx_fc_enable, tx_fc_enable; 6878 int ret; 6879 6880 /* 6881 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate 6882 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side. 6883 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate 6884 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side. 6885 */ 6886 static enum rte_eth_fc_mode rx_tx_onoff_2_pfc_mode[2][2] = { 6887 {RTE_FC_NONE, RTE_FC_RX_PAUSE}, {RTE_FC_TX_PAUSE, RTE_FC_FULL} 6888 }; 6889 6890 rx_fc_enable = (!strncmp(res->rx_pfc_mode, "on",2)) ? 1 : 0; 6891 tx_fc_enable = (!strncmp(res->tx_pfc_mode, "on",2)) ? 1 : 0; 6892 pfc_conf.fc.mode = rx_tx_onoff_2_pfc_mode[rx_fc_enable][tx_fc_enable]; 6893 pfc_conf.fc.high_water = res->high_water; 6894 pfc_conf.fc.low_water = res->low_water; 6895 pfc_conf.fc.pause_time = res->pause_time; 6896 pfc_conf.priority = res->priority; 6897 6898 ret = rte_eth_dev_priority_flow_ctrl_set(res->port_id, &pfc_conf); 6899 if (ret != 0) 6900 printf("bad priority flow contrl parameter, return code = %d \n", ret); 6901 } 6902 6903 cmdline_parse_token_string_t cmd_pfc_set_set = 6904 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6905 set, "set"); 6906 cmdline_parse_token_string_t cmd_pfc_set_flow_ctrl = 6907 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6908 pfc_ctrl, "pfc_ctrl"); 6909 cmdline_parse_token_string_t cmd_pfc_set_rx = 6910 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6911 rx, "rx"); 6912 cmdline_parse_token_string_t cmd_pfc_set_rx_mode = 6913 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6914 rx_pfc_mode, "on#off"); 6915 cmdline_parse_token_string_t cmd_pfc_set_tx = 6916 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6917 tx, "tx"); 6918 cmdline_parse_token_string_t cmd_pfc_set_tx_mode = 6919 TOKEN_STRING_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6920 tx_pfc_mode, "on#off"); 6921 cmdline_parse_token_num_t cmd_pfc_set_high_water = 6922 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6923 high_water, UINT32); 6924 cmdline_parse_token_num_t cmd_pfc_set_low_water = 6925 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6926 low_water, UINT32); 6927 cmdline_parse_token_num_t cmd_pfc_set_pause_time = 6928 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6929 pause_time, UINT16); 6930 cmdline_parse_token_num_t cmd_pfc_set_priority = 6931 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6932 priority, UINT8); 6933 cmdline_parse_token_num_t cmd_pfc_set_portid = 6934 TOKEN_NUM_INITIALIZER(struct cmd_priority_flow_ctrl_set_result, 6935 port_id, UINT16); 6936 6937 cmdline_parse_inst_t cmd_priority_flow_control_set = { 6938 .f = cmd_priority_flow_ctrl_set_parsed, 6939 .data = NULL, 6940 .help_str = "set pfc_ctrl rx on|off tx on|off <high_water> <low_water> " 6941 "<pause_time> <priority> <port_id>: " 6942 "Configure the Ethernet priority flow control", 6943 .tokens = { 6944 (void *)&cmd_pfc_set_set, 6945 (void *)&cmd_pfc_set_flow_ctrl, 6946 (void *)&cmd_pfc_set_rx, 6947 (void *)&cmd_pfc_set_rx_mode, 6948 (void *)&cmd_pfc_set_tx, 6949 (void *)&cmd_pfc_set_tx_mode, 6950 (void *)&cmd_pfc_set_high_water, 6951 (void *)&cmd_pfc_set_low_water, 6952 (void *)&cmd_pfc_set_pause_time, 6953 (void *)&cmd_pfc_set_priority, 6954 (void *)&cmd_pfc_set_portid, 6955 NULL, 6956 }, 6957 }; 6958 6959 /* *** RESET CONFIGURATION *** */ 6960 struct cmd_reset_result { 6961 cmdline_fixed_string_t reset; 6962 cmdline_fixed_string_t def; 6963 }; 6964 6965 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result, 6966 struct cmdline *cl, 6967 __attribute__((unused)) void *data) 6968 { 6969 cmdline_printf(cl, "Reset to default forwarding configuration...\n"); 6970 set_def_fwd_config(); 6971 } 6972 6973 cmdline_parse_token_string_t cmd_reset_set = 6974 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, reset, "set"); 6975 cmdline_parse_token_string_t cmd_reset_def = 6976 TOKEN_STRING_INITIALIZER(struct cmd_reset_result, def, 6977 "default"); 6978 6979 cmdline_parse_inst_t cmd_reset = { 6980 .f = cmd_reset_parsed, 6981 .data = NULL, 6982 .help_str = "set default: Reset default forwarding configuration", 6983 .tokens = { 6984 (void *)&cmd_reset_set, 6985 (void *)&cmd_reset_def, 6986 NULL, 6987 }, 6988 }; 6989 6990 /* *** START FORWARDING *** */ 6991 struct cmd_start_result { 6992 cmdline_fixed_string_t start; 6993 }; 6994 6995 cmdline_parse_token_string_t cmd_start_start = 6996 TOKEN_STRING_INITIALIZER(struct cmd_start_result, start, "start"); 6997 6998 static void cmd_start_parsed(__attribute__((unused)) void *parsed_result, 6999 __attribute__((unused)) struct cmdline *cl, 7000 __attribute__((unused)) void *data) 7001 { 7002 start_packet_forwarding(0); 7003 } 7004 7005 cmdline_parse_inst_t cmd_start = { 7006 .f = cmd_start_parsed, 7007 .data = NULL, 7008 .help_str = "start: Start packet forwarding", 7009 .tokens = { 7010 (void *)&cmd_start_start, 7011 NULL, 7012 }, 7013 }; 7014 7015 /* *** START FORWARDING WITH ONE TX BURST FIRST *** */ 7016 struct cmd_start_tx_first_result { 7017 cmdline_fixed_string_t start; 7018 cmdline_fixed_string_t tx_first; 7019 }; 7020 7021 static void 7022 cmd_start_tx_first_parsed(__attribute__((unused)) void *parsed_result, 7023 __attribute__((unused)) struct cmdline *cl, 7024 __attribute__((unused)) void *data) 7025 { 7026 start_packet_forwarding(1); 7027 } 7028 7029 cmdline_parse_token_string_t cmd_start_tx_first_start = 7030 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, start, 7031 "start"); 7032 cmdline_parse_token_string_t cmd_start_tx_first_tx_first = 7033 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_result, 7034 tx_first, "tx_first"); 7035 7036 cmdline_parse_inst_t cmd_start_tx_first = { 7037 .f = cmd_start_tx_first_parsed, 7038 .data = NULL, 7039 .help_str = "start tx_first: Start packet forwarding, " 7040 "after sending 1 burst of packets", 7041 .tokens = { 7042 (void *)&cmd_start_tx_first_start, 7043 (void *)&cmd_start_tx_first_tx_first, 7044 NULL, 7045 }, 7046 }; 7047 7048 /* *** START FORWARDING WITH N TX BURST FIRST *** */ 7049 struct cmd_start_tx_first_n_result { 7050 cmdline_fixed_string_t start; 7051 cmdline_fixed_string_t tx_first; 7052 uint32_t tx_num; 7053 }; 7054 7055 static void 7056 cmd_start_tx_first_n_parsed(void *parsed_result, 7057 __attribute__((unused)) struct cmdline *cl, 7058 __attribute__((unused)) void *data) 7059 { 7060 struct cmd_start_tx_first_n_result *res = parsed_result; 7061 7062 start_packet_forwarding(res->tx_num); 7063 } 7064 7065 cmdline_parse_token_string_t cmd_start_tx_first_n_start = 7066 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7067 start, "start"); 7068 cmdline_parse_token_string_t cmd_start_tx_first_n_tx_first = 7069 TOKEN_STRING_INITIALIZER(struct cmd_start_tx_first_n_result, 7070 tx_first, "tx_first"); 7071 cmdline_parse_token_num_t cmd_start_tx_first_n_tx_num = 7072 TOKEN_NUM_INITIALIZER(struct cmd_start_tx_first_n_result, 7073 tx_num, UINT32); 7074 7075 cmdline_parse_inst_t cmd_start_tx_first_n = { 7076 .f = cmd_start_tx_first_n_parsed, 7077 .data = NULL, 7078 .help_str = "start tx_first <num>: " 7079 "packet forwarding, after sending <num> bursts of packets", 7080 .tokens = { 7081 (void *)&cmd_start_tx_first_n_start, 7082 (void *)&cmd_start_tx_first_n_tx_first, 7083 (void *)&cmd_start_tx_first_n_tx_num, 7084 NULL, 7085 }, 7086 }; 7087 7088 /* *** SET LINK UP *** */ 7089 struct cmd_set_link_up_result { 7090 cmdline_fixed_string_t set; 7091 cmdline_fixed_string_t link_up; 7092 cmdline_fixed_string_t port; 7093 portid_t port_id; 7094 }; 7095 7096 cmdline_parse_token_string_t cmd_set_link_up_set = 7097 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, set, "set"); 7098 cmdline_parse_token_string_t cmd_set_link_up_link_up = 7099 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, link_up, 7100 "link-up"); 7101 cmdline_parse_token_string_t cmd_set_link_up_port = 7102 TOKEN_STRING_INITIALIZER(struct cmd_set_link_up_result, port, "port"); 7103 cmdline_parse_token_num_t cmd_set_link_up_port_id = 7104 TOKEN_NUM_INITIALIZER(struct cmd_set_link_up_result, port_id, UINT16); 7105 7106 static void cmd_set_link_up_parsed(__attribute__((unused)) void *parsed_result, 7107 __attribute__((unused)) struct cmdline *cl, 7108 __attribute__((unused)) void *data) 7109 { 7110 struct cmd_set_link_up_result *res = parsed_result; 7111 dev_set_link_up(res->port_id); 7112 } 7113 7114 cmdline_parse_inst_t cmd_set_link_up = { 7115 .f = cmd_set_link_up_parsed, 7116 .data = NULL, 7117 .help_str = "set link-up port <port id>", 7118 .tokens = { 7119 (void *)&cmd_set_link_up_set, 7120 (void *)&cmd_set_link_up_link_up, 7121 (void *)&cmd_set_link_up_port, 7122 (void *)&cmd_set_link_up_port_id, 7123 NULL, 7124 }, 7125 }; 7126 7127 /* *** SET LINK DOWN *** */ 7128 struct cmd_set_link_down_result { 7129 cmdline_fixed_string_t set; 7130 cmdline_fixed_string_t link_down; 7131 cmdline_fixed_string_t port; 7132 portid_t port_id; 7133 }; 7134 7135 cmdline_parse_token_string_t cmd_set_link_down_set = 7136 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, set, "set"); 7137 cmdline_parse_token_string_t cmd_set_link_down_link_down = 7138 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, link_down, 7139 "link-down"); 7140 cmdline_parse_token_string_t cmd_set_link_down_port = 7141 TOKEN_STRING_INITIALIZER(struct cmd_set_link_down_result, port, "port"); 7142 cmdline_parse_token_num_t cmd_set_link_down_port_id = 7143 TOKEN_NUM_INITIALIZER(struct cmd_set_link_down_result, port_id, UINT16); 7144 7145 static void cmd_set_link_down_parsed( 7146 __attribute__((unused)) void *parsed_result, 7147 __attribute__((unused)) struct cmdline *cl, 7148 __attribute__((unused)) void *data) 7149 { 7150 struct cmd_set_link_down_result *res = parsed_result; 7151 dev_set_link_down(res->port_id); 7152 } 7153 7154 cmdline_parse_inst_t cmd_set_link_down = { 7155 .f = cmd_set_link_down_parsed, 7156 .data = NULL, 7157 .help_str = "set link-down port <port id>", 7158 .tokens = { 7159 (void *)&cmd_set_link_down_set, 7160 (void *)&cmd_set_link_down_link_down, 7161 (void *)&cmd_set_link_down_port, 7162 (void *)&cmd_set_link_down_port_id, 7163 NULL, 7164 }, 7165 }; 7166 7167 /* *** SHOW CFG *** */ 7168 struct cmd_showcfg_result { 7169 cmdline_fixed_string_t show; 7170 cmdline_fixed_string_t cfg; 7171 cmdline_fixed_string_t what; 7172 }; 7173 7174 static void cmd_showcfg_parsed(void *parsed_result, 7175 __attribute__((unused)) struct cmdline *cl, 7176 __attribute__((unused)) void *data) 7177 { 7178 struct cmd_showcfg_result *res = parsed_result; 7179 if (!strcmp(res->what, "rxtx")) 7180 rxtx_config_display(); 7181 else if (!strcmp(res->what, "cores")) 7182 fwd_lcores_config_display(); 7183 else if (!strcmp(res->what, "fwd")) 7184 pkt_fwd_config_display(&cur_fwd_config); 7185 else if (!strcmp(res->what, "txpkts")) 7186 show_tx_pkt_segments(); 7187 } 7188 7189 cmdline_parse_token_string_t cmd_showcfg_show = 7190 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, show, "show"); 7191 cmdline_parse_token_string_t cmd_showcfg_port = 7192 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, cfg, "config"); 7193 cmdline_parse_token_string_t cmd_showcfg_what = 7194 TOKEN_STRING_INITIALIZER(struct cmd_showcfg_result, what, 7195 "rxtx#cores#fwd#txpkts"); 7196 7197 cmdline_parse_inst_t cmd_showcfg = { 7198 .f = cmd_showcfg_parsed, 7199 .data = NULL, 7200 .help_str = "show config rxtx|cores|fwd|txpkts", 7201 .tokens = { 7202 (void *)&cmd_showcfg_show, 7203 (void *)&cmd_showcfg_port, 7204 (void *)&cmd_showcfg_what, 7205 NULL, 7206 }, 7207 }; 7208 7209 /* *** SHOW ALL PORT INFO *** */ 7210 struct cmd_showportall_result { 7211 cmdline_fixed_string_t show; 7212 cmdline_fixed_string_t port; 7213 cmdline_fixed_string_t what; 7214 cmdline_fixed_string_t all; 7215 }; 7216 7217 static void cmd_showportall_parsed(void *parsed_result, 7218 __attribute__((unused)) struct cmdline *cl, 7219 __attribute__((unused)) void *data) 7220 { 7221 portid_t i; 7222 7223 struct cmd_showportall_result *res = parsed_result; 7224 if (!strcmp(res->show, "clear")) { 7225 if (!strcmp(res->what, "stats")) 7226 RTE_ETH_FOREACH_DEV(i) 7227 nic_stats_clear(i); 7228 else if (!strcmp(res->what, "xstats")) 7229 RTE_ETH_FOREACH_DEV(i) 7230 nic_xstats_clear(i); 7231 } else if (!strcmp(res->what, "info")) 7232 RTE_ETH_FOREACH_DEV(i) 7233 port_infos_display(i); 7234 else if (!strcmp(res->what, "summary")) { 7235 port_summary_header_display(); 7236 RTE_ETH_FOREACH_DEV(i) 7237 port_summary_display(i); 7238 } 7239 else if (!strcmp(res->what, "stats")) 7240 RTE_ETH_FOREACH_DEV(i) 7241 nic_stats_display(i); 7242 else if (!strcmp(res->what, "xstats")) 7243 RTE_ETH_FOREACH_DEV(i) 7244 nic_xstats_display(i); 7245 else if (!strcmp(res->what, "fdir")) 7246 RTE_ETH_FOREACH_DEV(i) 7247 fdir_get_infos(i); 7248 else if (!strcmp(res->what, "stat_qmap")) 7249 RTE_ETH_FOREACH_DEV(i) 7250 nic_stats_mapping_display(i); 7251 else if (!strcmp(res->what, "dcb_tc")) 7252 RTE_ETH_FOREACH_DEV(i) 7253 port_dcb_info_display(i); 7254 else if (!strcmp(res->what, "cap")) 7255 RTE_ETH_FOREACH_DEV(i) 7256 port_offload_cap_display(i); 7257 } 7258 7259 cmdline_parse_token_string_t cmd_showportall_show = 7260 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, show, 7261 "show#clear"); 7262 cmdline_parse_token_string_t cmd_showportall_port = 7263 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); 7264 cmdline_parse_token_string_t cmd_showportall_what = 7265 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, 7266 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7267 cmdline_parse_token_string_t cmd_showportall_all = 7268 TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); 7269 cmdline_parse_inst_t cmd_showportall = { 7270 .f = cmd_showportall_parsed, 7271 .data = NULL, 7272 .help_str = "show|clear port " 7273 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all", 7274 .tokens = { 7275 (void *)&cmd_showportall_show, 7276 (void *)&cmd_showportall_port, 7277 (void *)&cmd_showportall_what, 7278 (void *)&cmd_showportall_all, 7279 NULL, 7280 }, 7281 }; 7282 7283 /* *** SHOW PORT INFO *** */ 7284 struct cmd_showport_result { 7285 cmdline_fixed_string_t show; 7286 cmdline_fixed_string_t port; 7287 cmdline_fixed_string_t what; 7288 uint16_t portnum; 7289 }; 7290 7291 static void cmd_showport_parsed(void *parsed_result, 7292 __attribute__((unused)) struct cmdline *cl, 7293 __attribute__((unused)) void *data) 7294 { 7295 struct cmd_showport_result *res = parsed_result; 7296 if (!strcmp(res->show, "clear")) { 7297 if (!strcmp(res->what, "stats")) 7298 nic_stats_clear(res->portnum); 7299 else if (!strcmp(res->what, "xstats")) 7300 nic_xstats_clear(res->portnum); 7301 } else if (!strcmp(res->what, "info")) 7302 port_infos_display(res->portnum); 7303 else if (!strcmp(res->what, "summary")) { 7304 port_summary_header_display(); 7305 port_summary_display(res->portnum); 7306 } 7307 else if (!strcmp(res->what, "stats")) 7308 nic_stats_display(res->portnum); 7309 else if (!strcmp(res->what, "xstats")) 7310 nic_xstats_display(res->portnum); 7311 else if (!strcmp(res->what, "fdir")) 7312 fdir_get_infos(res->portnum); 7313 else if (!strcmp(res->what, "stat_qmap")) 7314 nic_stats_mapping_display(res->portnum); 7315 else if (!strcmp(res->what, "dcb_tc")) 7316 port_dcb_info_display(res->portnum); 7317 else if (!strcmp(res->what, "cap")) 7318 port_offload_cap_display(res->portnum); 7319 } 7320 7321 cmdline_parse_token_string_t cmd_showport_show = 7322 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, show, 7323 "show#clear"); 7324 cmdline_parse_token_string_t cmd_showport_port = 7325 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); 7326 cmdline_parse_token_string_t cmd_showport_what = 7327 TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, 7328 "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); 7329 cmdline_parse_token_num_t cmd_showport_portnum = 7330 TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT16); 7331 7332 cmdline_parse_inst_t cmd_showport = { 7333 .f = cmd_showport_parsed, 7334 .data = NULL, 7335 .help_str = "show|clear port " 7336 "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap " 7337 "<port_id>", 7338 .tokens = { 7339 (void *)&cmd_showport_show, 7340 (void *)&cmd_showport_port, 7341 (void *)&cmd_showport_what, 7342 (void *)&cmd_showport_portnum, 7343 NULL, 7344 }, 7345 }; 7346 7347 /* *** SHOW QUEUE INFO *** */ 7348 struct cmd_showqueue_result { 7349 cmdline_fixed_string_t show; 7350 cmdline_fixed_string_t type; 7351 cmdline_fixed_string_t what; 7352 uint16_t portnum; 7353 uint16_t queuenum; 7354 }; 7355 7356 static void 7357 cmd_showqueue_parsed(void *parsed_result, 7358 __attribute__((unused)) struct cmdline *cl, 7359 __attribute__((unused)) void *data) 7360 { 7361 struct cmd_showqueue_result *res = parsed_result; 7362 7363 if (!strcmp(res->type, "rxq")) 7364 rx_queue_infos_display(res->portnum, res->queuenum); 7365 else if (!strcmp(res->type, "txq")) 7366 tx_queue_infos_display(res->portnum, res->queuenum); 7367 } 7368 7369 cmdline_parse_token_string_t cmd_showqueue_show = 7370 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, show, "show"); 7371 cmdline_parse_token_string_t cmd_showqueue_type = 7372 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, type, "rxq#txq"); 7373 cmdline_parse_token_string_t cmd_showqueue_what = 7374 TOKEN_STRING_INITIALIZER(struct cmd_showqueue_result, what, "info"); 7375 cmdline_parse_token_num_t cmd_showqueue_portnum = 7376 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, portnum, UINT16); 7377 cmdline_parse_token_num_t cmd_showqueue_queuenum = 7378 TOKEN_NUM_INITIALIZER(struct cmd_showqueue_result, queuenum, UINT16); 7379 7380 cmdline_parse_inst_t cmd_showqueue = { 7381 .f = cmd_showqueue_parsed, 7382 .data = NULL, 7383 .help_str = "show rxq|txq info <port_id> <queue_id>", 7384 .tokens = { 7385 (void *)&cmd_showqueue_show, 7386 (void *)&cmd_showqueue_type, 7387 (void *)&cmd_showqueue_what, 7388 (void *)&cmd_showqueue_portnum, 7389 (void *)&cmd_showqueue_queuenum, 7390 NULL, 7391 }, 7392 }; 7393 7394 /* show/clear fwd engine statistics */ 7395 struct fwd_result { 7396 cmdline_fixed_string_t action; 7397 cmdline_fixed_string_t fwd; 7398 cmdline_fixed_string_t stats; 7399 cmdline_fixed_string_t all; 7400 }; 7401 7402 cmdline_parse_token_string_t cmd_fwd_action = 7403 TOKEN_STRING_INITIALIZER(struct fwd_result, action, "show#clear"); 7404 cmdline_parse_token_string_t cmd_fwd_fwd = 7405 TOKEN_STRING_INITIALIZER(struct fwd_result, fwd, "fwd"); 7406 cmdline_parse_token_string_t cmd_fwd_stats = 7407 TOKEN_STRING_INITIALIZER(struct fwd_result, stats, "stats"); 7408 cmdline_parse_token_string_t cmd_fwd_all = 7409 TOKEN_STRING_INITIALIZER(struct fwd_result, all, "all"); 7410 7411 static void 7412 cmd_showfwdall_parsed(void *parsed_result, 7413 __rte_unused struct cmdline *cl, 7414 __rte_unused void *data) 7415 { 7416 struct fwd_result *res = parsed_result; 7417 7418 if (!strcmp(res->action, "show")) 7419 fwd_stats_display(); 7420 else 7421 fwd_stats_reset(); 7422 } 7423 7424 static cmdline_parse_inst_t cmd_showfwdall = { 7425 .f = cmd_showfwdall_parsed, 7426 .data = NULL, 7427 .help_str = "show|clear fwd stats all", 7428 .tokens = { 7429 (void *)&cmd_fwd_action, 7430 (void *)&cmd_fwd_fwd, 7431 (void *)&cmd_fwd_stats, 7432 (void *)&cmd_fwd_all, 7433 NULL, 7434 }, 7435 }; 7436 7437 /* *** READ PORT REGISTER *** */ 7438 struct cmd_read_reg_result { 7439 cmdline_fixed_string_t read; 7440 cmdline_fixed_string_t reg; 7441 portid_t port_id; 7442 uint32_t reg_off; 7443 }; 7444 7445 static void 7446 cmd_read_reg_parsed(void *parsed_result, 7447 __attribute__((unused)) struct cmdline *cl, 7448 __attribute__((unused)) void *data) 7449 { 7450 struct cmd_read_reg_result *res = parsed_result; 7451 port_reg_display(res->port_id, res->reg_off); 7452 } 7453 7454 cmdline_parse_token_string_t cmd_read_reg_read = 7455 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, read, "read"); 7456 cmdline_parse_token_string_t cmd_read_reg_reg = 7457 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_result, reg, "reg"); 7458 cmdline_parse_token_num_t cmd_read_reg_port_id = 7459 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, port_id, UINT16); 7460 cmdline_parse_token_num_t cmd_read_reg_reg_off = 7461 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_result, reg_off, UINT32); 7462 7463 cmdline_parse_inst_t cmd_read_reg = { 7464 .f = cmd_read_reg_parsed, 7465 .data = NULL, 7466 .help_str = "read reg <port_id> <reg_off>", 7467 .tokens = { 7468 (void *)&cmd_read_reg_read, 7469 (void *)&cmd_read_reg_reg, 7470 (void *)&cmd_read_reg_port_id, 7471 (void *)&cmd_read_reg_reg_off, 7472 NULL, 7473 }, 7474 }; 7475 7476 /* *** READ PORT REGISTER BIT FIELD *** */ 7477 struct cmd_read_reg_bit_field_result { 7478 cmdline_fixed_string_t read; 7479 cmdline_fixed_string_t regfield; 7480 portid_t port_id; 7481 uint32_t reg_off; 7482 uint8_t bit1_pos; 7483 uint8_t bit2_pos; 7484 }; 7485 7486 static void 7487 cmd_read_reg_bit_field_parsed(void *parsed_result, 7488 __attribute__((unused)) struct cmdline *cl, 7489 __attribute__((unused)) void *data) 7490 { 7491 struct cmd_read_reg_bit_field_result *res = parsed_result; 7492 port_reg_bit_field_display(res->port_id, res->reg_off, 7493 res->bit1_pos, res->bit2_pos); 7494 } 7495 7496 cmdline_parse_token_string_t cmd_read_reg_bit_field_read = 7497 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, read, 7498 "read"); 7499 cmdline_parse_token_string_t cmd_read_reg_bit_field_regfield = 7500 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_field_result, 7501 regfield, "regfield"); 7502 cmdline_parse_token_num_t cmd_read_reg_bit_field_port_id = 7503 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, port_id, 7504 UINT16); 7505 cmdline_parse_token_num_t cmd_read_reg_bit_field_reg_off = 7506 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, reg_off, 7507 UINT32); 7508 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit1_pos = 7509 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit1_pos, 7510 UINT8); 7511 cmdline_parse_token_num_t cmd_read_reg_bit_field_bit2_pos = 7512 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_field_result, bit2_pos, 7513 UINT8); 7514 7515 cmdline_parse_inst_t cmd_read_reg_bit_field = { 7516 .f = cmd_read_reg_bit_field_parsed, 7517 .data = NULL, 7518 .help_str = "read regfield <port_id> <reg_off> <bit_x> <bit_y>: " 7519 "Read register bit field between bit_x and bit_y included", 7520 .tokens = { 7521 (void *)&cmd_read_reg_bit_field_read, 7522 (void *)&cmd_read_reg_bit_field_regfield, 7523 (void *)&cmd_read_reg_bit_field_port_id, 7524 (void *)&cmd_read_reg_bit_field_reg_off, 7525 (void *)&cmd_read_reg_bit_field_bit1_pos, 7526 (void *)&cmd_read_reg_bit_field_bit2_pos, 7527 NULL, 7528 }, 7529 }; 7530 7531 /* *** READ PORT REGISTER BIT *** */ 7532 struct cmd_read_reg_bit_result { 7533 cmdline_fixed_string_t read; 7534 cmdline_fixed_string_t regbit; 7535 portid_t port_id; 7536 uint32_t reg_off; 7537 uint8_t bit_pos; 7538 }; 7539 7540 static void 7541 cmd_read_reg_bit_parsed(void *parsed_result, 7542 __attribute__((unused)) struct cmdline *cl, 7543 __attribute__((unused)) void *data) 7544 { 7545 struct cmd_read_reg_bit_result *res = parsed_result; 7546 port_reg_bit_display(res->port_id, res->reg_off, res->bit_pos); 7547 } 7548 7549 cmdline_parse_token_string_t cmd_read_reg_bit_read = 7550 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, read, "read"); 7551 cmdline_parse_token_string_t cmd_read_reg_bit_regbit = 7552 TOKEN_STRING_INITIALIZER(struct cmd_read_reg_bit_result, 7553 regbit, "regbit"); 7554 cmdline_parse_token_num_t cmd_read_reg_bit_port_id = 7555 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, port_id, UINT16); 7556 cmdline_parse_token_num_t cmd_read_reg_bit_reg_off = 7557 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, reg_off, UINT32); 7558 cmdline_parse_token_num_t cmd_read_reg_bit_bit_pos = 7559 TOKEN_NUM_INITIALIZER(struct cmd_read_reg_bit_result, bit_pos, UINT8); 7560 7561 cmdline_parse_inst_t cmd_read_reg_bit = { 7562 .f = cmd_read_reg_bit_parsed, 7563 .data = NULL, 7564 .help_str = "read regbit <port_id> <reg_off> <bit_x>: 0 <= bit_x <= 31", 7565 .tokens = { 7566 (void *)&cmd_read_reg_bit_read, 7567 (void *)&cmd_read_reg_bit_regbit, 7568 (void *)&cmd_read_reg_bit_port_id, 7569 (void *)&cmd_read_reg_bit_reg_off, 7570 (void *)&cmd_read_reg_bit_bit_pos, 7571 NULL, 7572 }, 7573 }; 7574 7575 /* *** WRITE PORT REGISTER *** */ 7576 struct cmd_write_reg_result { 7577 cmdline_fixed_string_t write; 7578 cmdline_fixed_string_t reg; 7579 portid_t port_id; 7580 uint32_t reg_off; 7581 uint32_t value; 7582 }; 7583 7584 static void 7585 cmd_write_reg_parsed(void *parsed_result, 7586 __attribute__((unused)) struct cmdline *cl, 7587 __attribute__((unused)) void *data) 7588 { 7589 struct cmd_write_reg_result *res = parsed_result; 7590 port_reg_set(res->port_id, res->reg_off, res->value); 7591 } 7592 7593 cmdline_parse_token_string_t cmd_write_reg_write = 7594 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, write, "write"); 7595 cmdline_parse_token_string_t cmd_write_reg_reg = 7596 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_result, reg, "reg"); 7597 cmdline_parse_token_num_t cmd_write_reg_port_id = 7598 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, port_id, UINT16); 7599 cmdline_parse_token_num_t cmd_write_reg_reg_off = 7600 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, reg_off, UINT32); 7601 cmdline_parse_token_num_t cmd_write_reg_value = 7602 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_result, value, UINT32); 7603 7604 cmdline_parse_inst_t cmd_write_reg = { 7605 .f = cmd_write_reg_parsed, 7606 .data = NULL, 7607 .help_str = "write reg <port_id> <reg_off> <reg_value>", 7608 .tokens = { 7609 (void *)&cmd_write_reg_write, 7610 (void *)&cmd_write_reg_reg, 7611 (void *)&cmd_write_reg_port_id, 7612 (void *)&cmd_write_reg_reg_off, 7613 (void *)&cmd_write_reg_value, 7614 NULL, 7615 }, 7616 }; 7617 7618 /* *** WRITE PORT REGISTER BIT FIELD *** */ 7619 struct cmd_write_reg_bit_field_result { 7620 cmdline_fixed_string_t write; 7621 cmdline_fixed_string_t regfield; 7622 portid_t port_id; 7623 uint32_t reg_off; 7624 uint8_t bit1_pos; 7625 uint8_t bit2_pos; 7626 uint32_t value; 7627 }; 7628 7629 static void 7630 cmd_write_reg_bit_field_parsed(void *parsed_result, 7631 __attribute__((unused)) struct cmdline *cl, 7632 __attribute__((unused)) void *data) 7633 { 7634 struct cmd_write_reg_bit_field_result *res = parsed_result; 7635 port_reg_bit_field_set(res->port_id, res->reg_off, 7636 res->bit1_pos, res->bit2_pos, res->value); 7637 } 7638 7639 cmdline_parse_token_string_t cmd_write_reg_bit_field_write = 7640 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, write, 7641 "write"); 7642 cmdline_parse_token_string_t cmd_write_reg_bit_field_regfield = 7643 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_field_result, 7644 regfield, "regfield"); 7645 cmdline_parse_token_num_t cmd_write_reg_bit_field_port_id = 7646 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, port_id, 7647 UINT16); 7648 cmdline_parse_token_num_t cmd_write_reg_bit_field_reg_off = 7649 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, reg_off, 7650 UINT32); 7651 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit1_pos = 7652 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit1_pos, 7653 UINT8); 7654 cmdline_parse_token_num_t cmd_write_reg_bit_field_bit2_pos = 7655 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, bit2_pos, 7656 UINT8); 7657 cmdline_parse_token_num_t cmd_write_reg_bit_field_value = 7658 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_field_result, value, 7659 UINT32); 7660 7661 cmdline_parse_inst_t cmd_write_reg_bit_field = { 7662 .f = cmd_write_reg_bit_field_parsed, 7663 .data = NULL, 7664 .help_str = "write regfield <port_id> <reg_off> <bit_x> <bit_y> " 7665 "<reg_value>: " 7666 "Set register bit field between bit_x and bit_y included", 7667 .tokens = { 7668 (void *)&cmd_write_reg_bit_field_write, 7669 (void *)&cmd_write_reg_bit_field_regfield, 7670 (void *)&cmd_write_reg_bit_field_port_id, 7671 (void *)&cmd_write_reg_bit_field_reg_off, 7672 (void *)&cmd_write_reg_bit_field_bit1_pos, 7673 (void *)&cmd_write_reg_bit_field_bit2_pos, 7674 (void *)&cmd_write_reg_bit_field_value, 7675 NULL, 7676 }, 7677 }; 7678 7679 /* *** WRITE PORT REGISTER BIT *** */ 7680 struct cmd_write_reg_bit_result { 7681 cmdline_fixed_string_t write; 7682 cmdline_fixed_string_t regbit; 7683 portid_t port_id; 7684 uint32_t reg_off; 7685 uint8_t bit_pos; 7686 uint8_t value; 7687 }; 7688 7689 static void 7690 cmd_write_reg_bit_parsed(void *parsed_result, 7691 __attribute__((unused)) struct cmdline *cl, 7692 __attribute__((unused)) void *data) 7693 { 7694 struct cmd_write_reg_bit_result *res = parsed_result; 7695 port_reg_bit_set(res->port_id, res->reg_off, res->bit_pos, res->value); 7696 } 7697 7698 cmdline_parse_token_string_t cmd_write_reg_bit_write = 7699 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, write, 7700 "write"); 7701 cmdline_parse_token_string_t cmd_write_reg_bit_regbit = 7702 TOKEN_STRING_INITIALIZER(struct cmd_write_reg_bit_result, 7703 regbit, "regbit"); 7704 cmdline_parse_token_num_t cmd_write_reg_bit_port_id = 7705 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, port_id, UINT16); 7706 cmdline_parse_token_num_t cmd_write_reg_bit_reg_off = 7707 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, reg_off, UINT32); 7708 cmdline_parse_token_num_t cmd_write_reg_bit_bit_pos = 7709 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, bit_pos, UINT8); 7710 cmdline_parse_token_num_t cmd_write_reg_bit_value = 7711 TOKEN_NUM_INITIALIZER(struct cmd_write_reg_bit_result, value, UINT8); 7712 7713 cmdline_parse_inst_t cmd_write_reg_bit = { 7714 .f = cmd_write_reg_bit_parsed, 7715 .data = NULL, 7716 .help_str = "write regbit <port_id> <reg_off> <bit_x> 0|1: " 7717 "0 <= bit_x <= 31", 7718 .tokens = { 7719 (void *)&cmd_write_reg_bit_write, 7720 (void *)&cmd_write_reg_bit_regbit, 7721 (void *)&cmd_write_reg_bit_port_id, 7722 (void *)&cmd_write_reg_bit_reg_off, 7723 (void *)&cmd_write_reg_bit_bit_pos, 7724 (void *)&cmd_write_reg_bit_value, 7725 NULL, 7726 }, 7727 }; 7728 7729 /* *** READ A RING DESCRIPTOR OF A PORT RX/TX QUEUE *** */ 7730 struct cmd_read_rxd_txd_result { 7731 cmdline_fixed_string_t read; 7732 cmdline_fixed_string_t rxd_txd; 7733 portid_t port_id; 7734 uint16_t queue_id; 7735 uint16_t desc_id; 7736 }; 7737 7738 static void 7739 cmd_read_rxd_txd_parsed(void *parsed_result, 7740 __attribute__((unused)) struct cmdline *cl, 7741 __attribute__((unused)) void *data) 7742 { 7743 struct cmd_read_rxd_txd_result *res = parsed_result; 7744 7745 if (!strcmp(res->rxd_txd, "rxd")) 7746 rx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7747 else if (!strcmp(res->rxd_txd, "txd")) 7748 tx_ring_desc_display(res->port_id, res->queue_id, res->desc_id); 7749 } 7750 7751 cmdline_parse_token_string_t cmd_read_rxd_txd_read = 7752 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, read, "read"); 7753 cmdline_parse_token_string_t cmd_read_rxd_txd_rxd_txd = 7754 TOKEN_STRING_INITIALIZER(struct cmd_read_rxd_txd_result, rxd_txd, 7755 "rxd#txd"); 7756 cmdline_parse_token_num_t cmd_read_rxd_txd_port_id = 7757 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, port_id, UINT16); 7758 cmdline_parse_token_num_t cmd_read_rxd_txd_queue_id = 7759 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, queue_id, UINT16); 7760 cmdline_parse_token_num_t cmd_read_rxd_txd_desc_id = 7761 TOKEN_NUM_INITIALIZER(struct cmd_read_rxd_txd_result, desc_id, UINT16); 7762 7763 cmdline_parse_inst_t cmd_read_rxd_txd = { 7764 .f = cmd_read_rxd_txd_parsed, 7765 .data = NULL, 7766 .help_str = "read rxd|txd <port_id> <queue_id> <desc_id>", 7767 .tokens = { 7768 (void *)&cmd_read_rxd_txd_read, 7769 (void *)&cmd_read_rxd_txd_rxd_txd, 7770 (void *)&cmd_read_rxd_txd_port_id, 7771 (void *)&cmd_read_rxd_txd_queue_id, 7772 (void *)&cmd_read_rxd_txd_desc_id, 7773 NULL, 7774 }, 7775 }; 7776 7777 /* *** QUIT *** */ 7778 struct cmd_quit_result { 7779 cmdline_fixed_string_t quit; 7780 }; 7781 7782 static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result, 7783 struct cmdline *cl, 7784 __attribute__((unused)) void *data) 7785 { 7786 cmdline_quit(cl); 7787 } 7788 7789 cmdline_parse_token_string_t cmd_quit_quit = 7790 TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit"); 7791 7792 cmdline_parse_inst_t cmd_quit = { 7793 .f = cmd_quit_parsed, 7794 .data = NULL, 7795 .help_str = "quit: Exit application", 7796 .tokens = { 7797 (void *)&cmd_quit_quit, 7798 NULL, 7799 }, 7800 }; 7801 7802 /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */ 7803 struct cmd_mac_addr_result { 7804 cmdline_fixed_string_t mac_addr_cmd; 7805 cmdline_fixed_string_t what; 7806 uint16_t port_num; 7807 struct ether_addr address; 7808 }; 7809 7810 static void cmd_mac_addr_parsed(void *parsed_result, 7811 __attribute__((unused)) struct cmdline *cl, 7812 __attribute__((unused)) void *data) 7813 { 7814 struct cmd_mac_addr_result *res = parsed_result; 7815 int ret; 7816 7817 if (strcmp(res->what, "add") == 0) 7818 ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0); 7819 else if (strcmp(res->what, "set") == 0) 7820 ret = rte_eth_dev_default_mac_addr_set(res->port_num, 7821 &res->address); 7822 else 7823 ret = rte_eth_dev_mac_addr_remove(res->port_num, &res->address); 7824 7825 /* check the return value and print it if is < 0 */ 7826 if(ret < 0) 7827 printf("mac_addr_cmd error: (%s)\n", strerror(-ret)); 7828 7829 } 7830 7831 cmdline_parse_token_string_t cmd_mac_addr_cmd = 7832 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, mac_addr_cmd, 7833 "mac_addr"); 7834 cmdline_parse_token_string_t cmd_mac_addr_what = 7835 TOKEN_STRING_INITIALIZER(struct cmd_mac_addr_result, what, 7836 "add#remove#set"); 7837 cmdline_parse_token_num_t cmd_mac_addr_portnum = 7838 TOKEN_NUM_INITIALIZER(struct cmd_mac_addr_result, port_num, 7839 UINT16); 7840 cmdline_parse_token_etheraddr_t cmd_mac_addr_addr = 7841 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 7842 7843 cmdline_parse_inst_t cmd_mac_addr = { 7844 .f = cmd_mac_addr_parsed, 7845 .data = (void *)0, 7846 .help_str = "mac_addr add|remove|set <port_id> <mac_addr>: " 7847 "Add/Remove/Set MAC address on port_id", 7848 .tokens = { 7849 (void *)&cmd_mac_addr_cmd, 7850 (void *)&cmd_mac_addr_what, 7851 (void *)&cmd_mac_addr_portnum, 7852 (void *)&cmd_mac_addr_addr, 7853 NULL, 7854 }, 7855 }; 7856 7857 /* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */ 7858 struct cmd_eth_peer_result { 7859 cmdline_fixed_string_t set; 7860 cmdline_fixed_string_t eth_peer; 7861 portid_t port_id; 7862 cmdline_fixed_string_t peer_addr; 7863 }; 7864 7865 static void cmd_set_eth_peer_parsed(void *parsed_result, 7866 __attribute__((unused)) struct cmdline *cl, 7867 __attribute__((unused)) void *data) 7868 { 7869 struct cmd_eth_peer_result *res = parsed_result; 7870 7871 if (test_done == 0) { 7872 printf("Please stop forwarding first\n"); 7873 return; 7874 } 7875 if (!strcmp(res->eth_peer, "eth-peer")) { 7876 set_fwd_eth_peer(res->port_id, res->peer_addr); 7877 fwd_config_setup(); 7878 } 7879 } 7880 cmdline_parse_token_string_t cmd_eth_peer_set = 7881 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set"); 7882 cmdline_parse_token_string_t cmd_eth_peer = 7883 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, "eth-peer"); 7884 cmdline_parse_token_num_t cmd_eth_peer_port_id = 7885 TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16); 7886 cmdline_parse_token_string_t cmd_eth_peer_addr = 7887 TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL); 7888 7889 cmdline_parse_inst_t cmd_set_fwd_eth_peer = { 7890 .f = cmd_set_eth_peer_parsed, 7891 .data = NULL, 7892 .help_str = "set eth-peer <port_id> <peer_mac>", 7893 .tokens = { 7894 (void *)&cmd_eth_peer_set, 7895 (void *)&cmd_eth_peer, 7896 (void *)&cmd_eth_peer_port_id, 7897 (void *)&cmd_eth_peer_addr, 7898 NULL, 7899 }, 7900 }; 7901 7902 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */ 7903 struct cmd_set_qmap_result { 7904 cmdline_fixed_string_t set; 7905 cmdline_fixed_string_t qmap; 7906 cmdline_fixed_string_t what; 7907 portid_t port_id; 7908 uint16_t queue_id; 7909 uint8_t map_value; 7910 }; 7911 7912 static void 7913 cmd_set_qmap_parsed(void *parsed_result, 7914 __attribute__((unused)) struct cmdline *cl, 7915 __attribute__((unused)) void *data) 7916 { 7917 struct cmd_set_qmap_result *res = parsed_result; 7918 int is_rx = (strcmp(res->what, "tx") == 0) ? 0 : 1; 7919 7920 set_qmap(res->port_id, (uint8_t)is_rx, res->queue_id, res->map_value); 7921 } 7922 7923 cmdline_parse_token_string_t cmd_setqmap_set = 7924 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7925 set, "set"); 7926 cmdline_parse_token_string_t cmd_setqmap_qmap = 7927 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7928 qmap, "stat_qmap"); 7929 cmdline_parse_token_string_t cmd_setqmap_what = 7930 TOKEN_STRING_INITIALIZER(struct cmd_set_qmap_result, 7931 what, "tx#rx"); 7932 cmdline_parse_token_num_t cmd_setqmap_portid = 7933 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7934 port_id, UINT16); 7935 cmdline_parse_token_num_t cmd_setqmap_queueid = 7936 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7937 queue_id, UINT16); 7938 cmdline_parse_token_num_t cmd_setqmap_mapvalue = 7939 TOKEN_NUM_INITIALIZER(struct cmd_set_qmap_result, 7940 map_value, UINT8); 7941 7942 cmdline_parse_inst_t cmd_set_qmap = { 7943 .f = cmd_set_qmap_parsed, 7944 .data = NULL, 7945 .help_str = "set stat_qmap rx|tx <port_id> <queue_id> <map_value>: " 7946 "Set statistics mapping value on tx|rx queue_id of port_id", 7947 .tokens = { 7948 (void *)&cmd_setqmap_set, 7949 (void *)&cmd_setqmap_qmap, 7950 (void *)&cmd_setqmap_what, 7951 (void *)&cmd_setqmap_portid, 7952 (void *)&cmd_setqmap_queueid, 7953 (void *)&cmd_setqmap_mapvalue, 7954 NULL, 7955 }, 7956 }; 7957 7958 /* *** SET OPTION TO HIDE ZERO VALUES FOR XSTATS DISPLAY *** */ 7959 struct cmd_set_xstats_hide_zero_result { 7960 cmdline_fixed_string_t keyword; 7961 cmdline_fixed_string_t name; 7962 cmdline_fixed_string_t on_off; 7963 }; 7964 7965 static void 7966 cmd_set_xstats_hide_zero_parsed(void *parsed_result, 7967 __attribute__((unused)) struct cmdline *cl, 7968 __attribute__((unused)) void *data) 7969 { 7970 struct cmd_set_xstats_hide_zero_result *res; 7971 uint16_t on_off = 0; 7972 7973 res = parsed_result; 7974 on_off = !strcmp(res->on_off, "on") ? 1 : 0; 7975 set_xstats_hide_zero(on_off); 7976 } 7977 7978 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_keyword = 7979 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 7980 keyword, "set"); 7981 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_name = 7982 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 7983 name, "xstats-hide-zero"); 7984 cmdline_parse_token_string_t cmd_set_xstats_hide_zero_on_off = 7985 TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_zero_result, 7986 on_off, "on#off"); 7987 7988 cmdline_parse_inst_t cmd_set_xstats_hide_zero = { 7989 .f = cmd_set_xstats_hide_zero_parsed, 7990 .data = NULL, 7991 .help_str = "set xstats-hide-zero on|off", 7992 .tokens = { 7993 (void *)&cmd_set_xstats_hide_zero_keyword, 7994 (void *)&cmd_set_xstats_hide_zero_name, 7995 (void *)&cmd_set_xstats_hide_zero_on_off, 7996 NULL, 7997 }, 7998 }; 7999 8000 /* *** CONFIGURE UNICAST HASH TABLE *** */ 8001 struct cmd_set_uc_hash_table { 8002 cmdline_fixed_string_t set; 8003 cmdline_fixed_string_t port; 8004 portid_t port_id; 8005 cmdline_fixed_string_t what; 8006 struct ether_addr address; 8007 cmdline_fixed_string_t mode; 8008 }; 8009 8010 static void 8011 cmd_set_uc_hash_parsed(void *parsed_result, 8012 __attribute__((unused)) struct cmdline *cl, 8013 __attribute__((unused)) void *data) 8014 { 8015 int ret=0; 8016 struct cmd_set_uc_hash_table *res = parsed_result; 8017 8018 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8019 8020 if (strcmp(res->what, "uta") == 0) 8021 ret = rte_eth_dev_uc_hash_table_set(res->port_id, 8022 &res->address,(uint8_t)is_on); 8023 if (ret < 0) 8024 printf("bad unicast hash table parameter, return code = %d \n", ret); 8025 8026 } 8027 8028 cmdline_parse_token_string_t cmd_set_uc_hash_set = 8029 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8030 set, "set"); 8031 cmdline_parse_token_string_t cmd_set_uc_hash_port = 8032 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8033 port, "port"); 8034 cmdline_parse_token_num_t cmd_set_uc_hash_portid = 8035 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_hash_table, 8036 port_id, UINT16); 8037 cmdline_parse_token_string_t cmd_set_uc_hash_what = 8038 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8039 what, "uta"); 8040 cmdline_parse_token_etheraddr_t cmd_set_uc_hash_mac = 8041 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_uc_hash_table, 8042 address); 8043 cmdline_parse_token_string_t cmd_set_uc_hash_mode = 8044 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_hash_table, 8045 mode, "on#off"); 8046 8047 cmdline_parse_inst_t cmd_set_uc_hash_filter = { 8048 .f = cmd_set_uc_hash_parsed, 8049 .data = NULL, 8050 .help_str = "set port <port_id> uta <mac_addr> on|off)", 8051 .tokens = { 8052 (void *)&cmd_set_uc_hash_set, 8053 (void *)&cmd_set_uc_hash_port, 8054 (void *)&cmd_set_uc_hash_portid, 8055 (void *)&cmd_set_uc_hash_what, 8056 (void *)&cmd_set_uc_hash_mac, 8057 (void *)&cmd_set_uc_hash_mode, 8058 NULL, 8059 }, 8060 }; 8061 8062 struct cmd_set_uc_all_hash_table { 8063 cmdline_fixed_string_t set; 8064 cmdline_fixed_string_t port; 8065 portid_t port_id; 8066 cmdline_fixed_string_t what; 8067 cmdline_fixed_string_t value; 8068 cmdline_fixed_string_t mode; 8069 }; 8070 8071 static void 8072 cmd_set_uc_all_hash_parsed(void *parsed_result, 8073 __attribute__((unused)) struct cmdline *cl, 8074 __attribute__((unused)) void *data) 8075 { 8076 int ret=0; 8077 struct cmd_set_uc_all_hash_table *res = parsed_result; 8078 8079 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8080 8081 if ((strcmp(res->what, "uta") == 0) && 8082 (strcmp(res->value, "all") == 0)) 8083 ret = rte_eth_dev_uc_all_hash_table_set(res->port_id,(uint8_t) is_on); 8084 if (ret < 0) 8085 printf("bad unicast hash table parameter," 8086 "return code = %d \n", ret); 8087 } 8088 8089 cmdline_parse_token_string_t cmd_set_uc_all_hash_set = 8090 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8091 set, "set"); 8092 cmdline_parse_token_string_t cmd_set_uc_all_hash_port = 8093 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8094 port, "port"); 8095 cmdline_parse_token_num_t cmd_set_uc_all_hash_portid = 8096 TOKEN_NUM_INITIALIZER(struct cmd_set_uc_all_hash_table, 8097 port_id, UINT16); 8098 cmdline_parse_token_string_t cmd_set_uc_all_hash_what = 8099 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8100 what, "uta"); 8101 cmdline_parse_token_string_t cmd_set_uc_all_hash_value = 8102 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8103 value,"all"); 8104 cmdline_parse_token_string_t cmd_set_uc_all_hash_mode = 8105 TOKEN_STRING_INITIALIZER(struct cmd_set_uc_all_hash_table, 8106 mode, "on#off"); 8107 8108 cmdline_parse_inst_t cmd_set_uc_all_hash_filter = { 8109 .f = cmd_set_uc_all_hash_parsed, 8110 .data = NULL, 8111 .help_str = "set port <port_id> uta all on|off", 8112 .tokens = { 8113 (void *)&cmd_set_uc_all_hash_set, 8114 (void *)&cmd_set_uc_all_hash_port, 8115 (void *)&cmd_set_uc_all_hash_portid, 8116 (void *)&cmd_set_uc_all_hash_what, 8117 (void *)&cmd_set_uc_all_hash_value, 8118 (void *)&cmd_set_uc_all_hash_mode, 8119 NULL, 8120 }, 8121 }; 8122 8123 /* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */ 8124 struct cmd_set_vf_macvlan_filter { 8125 cmdline_fixed_string_t set; 8126 cmdline_fixed_string_t port; 8127 portid_t port_id; 8128 cmdline_fixed_string_t vf; 8129 uint8_t vf_id; 8130 struct ether_addr address; 8131 cmdline_fixed_string_t filter_type; 8132 cmdline_fixed_string_t mode; 8133 }; 8134 8135 static void 8136 cmd_set_vf_macvlan_parsed(void *parsed_result, 8137 __attribute__((unused)) struct cmdline *cl, 8138 __attribute__((unused)) void *data) 8139 { 8140 int is_on, ret = 0; 8141 struct cmd_set_vf_macvlan_filter *res = parsed_result; 8142 struct rte_eth_mac_filter filter; 8143 8144 memset(&filter, 0, sizeof(struct rte_eth_mac_filter)); 8145 8146 rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN); 8147 8148 /* set VF MAC filter */ 8149 filter.is_vf = 1; 8150 8151 /* set VF ID */ 8152 filter.dst_id = res->vf_id; 8153 8154 if (!strcmp(res->filter_type, "exact-mac")) 8155 filter.filter_type = RTE_MAC_PERFECT_MATCH; 8156 else if (!strcmp(res->filter_type, "exact-mac-vlan")) 8157 filter.filter_type = RTE_MACVLAN_PERFECT_MATCH; 8158 else if (!strcmp(res->filter_type, "hashmac")) 8159 filter.filter_type = RTE_MAC_HASH_MATCH; 8160 else if (!strcmp(res->filter_type, "hashmac-vlan")) 8161 filter.filter_type = RTE_MACVLAN_HASH_MATCH; 8162 8163 is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8164 8165 if (is_on) 8166 ret = rte_eth_dev_filter_ctrl(res->port_id, 8167 RTE_ETH_FILTER_MACVLAN, 8168 RTE_ETH_FILTER_ADD, 8169 &filter); 8170 else 8171 ret = rte_eth_dev_filter_ctrl(res->port_id, 8172 RTE_ETH_FILTER_MACVLAN, 8173 RTE_ETH_FILTER_DELETE, 8174 &filter); 8175 8176 if (ret < 0) 8177 printf("bad set MAC hash parameter, return code = %d\n", ret); 8178 8179 } 8180 8181 cmdline_parse_token_string_t cmd_set_vf_macvlan_set = 8182 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8183 set, "set"); 8184 cmdline_parse_token_string_t cmd_set_vf_macvlan_port = 8185 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8186 port, "port"); 8187 cmdline_parse_token_num_t cmd_set_vf_macvlan_portid = 8188 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8189 port_id, UINT16); 8190 cmdline_parse_token_string_t cmd_set_vf_macvlan_vf = 8191 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8192 vf, "vf"); 8193 cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id = 8194 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8195 vf_id, UINT8); 8196 cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac = 8197 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8198 address); 8199 cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type = 8200 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8201 filter_type, "exact-mac#exact-mac-vlan" 8202 "#hashmac#hashmac-vlan"); 8203 cmdline_parse_token_string_t cmd_set_vf_macvlan_mode = 8204 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, 8205 mode, "on#off"); 8206 8207 cmdline_parse_inst_t cmd_set_vf_macvlan_filter = { 8208 .f = cmd_set_vf_macvlan_parsed, 8209 .data = NULL, 8210 .help_str = "set port <port_id> vf <vf_id> <mac_addr> " 8211 "exact-mac|exact-mac-vlan|hashmac|hashmac-vlan on|off: " 8212 "Exact match rule: exact match of MAC or MAC and VLAN; " 8213 "hash match rule: hash match of MAC and exact match of VLAN", 8214 .tokens = { 8215 (void *)&cmd_set_vf_macvlan_set, 8216 (void *)&cmd_set_vf_macvlan_port, 8217 (void *)&cmd_set_vf_macvlan_portid, 8218 (void *)&cmd_set_vf_macvlan_vf, 8219 (void *)&cmd_set_vf_macvlan_vf_id, 8220 (void *)&cmd_set_vf_macvlan_mac, 8221 (void *)&cmd_set_vf_macvlan_filter_type, 8222 (void *)&cmd_set_vf_macvlan_mode, 8223 NULL, 8224 }, 8225 }; 8226 8227 /* *** CONFIGURE VF TRAFFIC CONTROL *** */ 8228 struct cmd_set_vf_traffic { 8229 cmdline_fixed_string_t set; 8230 cmdline_fixed_string_t port; 8231 portid_t port_id; 8232 cmdline_fixed_string_t vf; 8233 uint8_t vf_id; 8234 cmdline_fixed_string_t what; 8235 cmdline_fixed_string_t mode; 8236 }; 8237 8238 static void 8239 cmd_set_vf_traffic_parsed(void *parsed_result, 8240 __attribute__((unused)) struct cmdline *cl, 8241 __attribute__((unused)) void *data) 8242 { 8243 struct cmd_set_vf_traffic *res = parsed_result; 8244 int is_rx = (strcmp(res->what, "rx") == 0) ? 1 : 0; 8245 int is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; 8246 8247 set_vf_traffic(res->port_id, (uint8_t)is_rx, res->vf_id,(uint8_t) is_on); 8248 } 8249 8250 cmdline_parse_token_string_t cmd_setvf_traffic_set = 8251 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8252 set, "set"); 8253 cmdline_parse_token_string_t cmd_setvf_traffic_port = 8254 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8255 port, "port"); 8256 cmdline_parse_token_num_t cmd_setvf_traffic_portid = 8257 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8258 port_id, UINT16); 8259 cmdline_parse_token_string_t cmd_setvf_traffic_vf = 8260 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8261 vf, "vf"); 8262 cmdline_parse_token_num_t cmd_setvf_traffic_vfid = 8263 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_traffic, 8264 vf_id, UINT8); 8265 cmdline_parse_token_string_t cmd_setvf_traffic_what = 8266 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8267 what, "tx#rx"); 8268 cmdline_parse_token_string_t cmd_setvf_traffic_mode = 8269 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_traffic, 8270 mode, "on#off"); 8271 8272 cmdline_parse_inst_t cmd_set_vf_traffic = { 8273 .f = cmd_set_vf_traffic_parsed, 8274 .data = NULL, 8275 .help_str = "set port <port_id> vf <vf_id> rx|tx on|off", 8276 .tokens = { 8277 (void *)&cmd_setvf_traffic_set, 8278 (void *)&cmd_setvf_traffic_port, 8279 (void *)&cmd_setvf_traffic_portid, 8280 (void *)&cmd_setvf_traffic_vf, 8281 (void *)&cmd_setvf_traffic_vfid, 8282 (void *)&cmd_setvf_traffic_what, 8283 (void *)&cmd_setvf_traffic_mode, 8284 NULL, 8285 }, 8286 }; 8287 8288 /* *** CONFIGURE VF RECEIVE MODE *** */ 8289 struct cmd_set_vf_rxmode { 8290 cmdline_fixed_string_t set; 8291 cmdline_fixed_string_t port; 8292 portid_t port_id; 8293 cmdline_fixed_string_t vf; 8294 uint8_t vf_id; 8295 cmdline_fixed_string_t what; 8296 cmdline_fixed_string_t mode; 8297 cmdline_fixed_string_t on; 8298 }; 8299 8300 static void 8301 cmd_set_vf_rxmode_parsed(void *parsed_result, 8302 __attribute__((unused)) struct cmdline *cl, 8303 __attribute__((unused)) void *data) 8304 { 8305 int ret = -ENOTSUP; 8306 uint16_t rx_mode = 0; 8307 struct cmd_set_vf_rxmode *res = parsed_result; 8308 8309 int is_on = (strcmp(res->on, "on") == 0) ? 1 : 0; 8310 if (!strcmp(res->what,"rxmode")) { 8311 if (!strcmp(res->mode, "AUPE")) 8312 rx_mode |= ETH_VMDQ_ACCEPT_UNTAG; 8313 else if (!strcmp(res->mode, "ROPE")) 8314 rx_mode |= ETH_VMDQ_ACCEPT_HASH_UC; 8315 else if (!strcmp(res->mode, "BAM")) 8316 rx_mode |= ETH_VMDQ_ACCEPT_BROADCAST; 8317 else if (!strncmp(res->mode, "MPE",3)) 8318 rx_mode |= ETH_VMDQ_ACCEPT_MULTICAST; 8319 } 8320 8321 RTE_SET_USED(is_on); 8322 8323 #ifdef RTE_LIBRTE_IXGBE_PMD 8324 if (ret == -ENOTSUP) 8325 ret = rte_pmd_ixgbe_set_vf_rxmode(res->port_id, res->vf_id, 8326 rx_mode, (uint8_t)is_on); 8327 #endif 8328 #ifdef RTE_LIBRTE_BNXT_PMD 8329 if (ret == -ENOTSUP) 8330 ret = rte_pmd_bnxt_set_vf_rxmode(res->port_id, res->vf_id, 8331 rx_mode, (uint8_t)is_on); 8332 #endif 8333 if (ret < 0) 8334 printf("bad VF receive mode parameter, return code = %d \n", 8335 ret); 8336 } 8337 8338 cmdline_parse_token_string_t cmd_set_vf_rxmode_set = 8339 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8340 set, "set"); 8341 cmdline_parse_token_string_t cmd_set_vf_rxmode_port = 8342 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8343 port, "port"); 8344 cmdline_parse_token_num_t cmd_set_vf_rxmode_portid = 8345 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8346 port_id, UINT16); 8347 cmdline_parse_token_string_t cmd_set_vf_rxmode_vf = 8348 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8349 vf, "vf"); 8350 cmdline_parse_token_num_t cmd_set_vf_rxmode_vfid = 8351 TOKEN_NUM_INITIALIZER(struct cmd_set_vf_rxmode, 8352 vf_id, UINT8); 8353 cmdline_parse_token_string_t cmd_set_vf_rxmode_what = 8354 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8355 what, "rxmode"); 8356 cmdline_parse_token_string_t cmd_set_vf_rxmode_mode = 8357 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8358 mode, "AUPE#ROPE#BAM#MPE"); 8359 cmdline_parse_token_string_t cmd_set_vf_rxmode_on = 8360 TOKEN_STRING_INITIALIZER(struct cmd_set_vf_rxmode, 8361 on, "on#off"); 8362 8363 cmdline_parse_inst_t cmd_set_vf_rxmode = { 8364 .f = cmd_set_vf_rxmode_parsed, 8365 .data = NULL, 8366 .help_str = "set port <port_id> vf <vf_id> rxmode " 8367 "AUPE|ROPE|BAM|MPE on|off", 8368 .tokens = { 8369 (void *)&cmd_set_vf_rxmode_set, 8370 (void *)&cmd_set_vf_rxmode_port, 8371 (void *)&cmd_set_vf_rxmode_portid, 8372 (void *)&cmd_set_vf_rxmode_vf, 8373 (void *)&cmd_set_vf_rxmode_vfid, 8374 (void *)&cmd_set_vf_rxmode_what, 8375 (void *)&cmd_set_vf_rxmode_mode, 8376 (void *)&cmd_set_vf_rxmode_on, 8377 NULL, 8378 }, 8379 }; 8380 8381 /* *** ADD MAC ADDRESS FILTER FOR A VF OF A PORT *** */ 8382 struct cmd_vf_mac_addr_result { 8383 cmdline_fixed_string_t mac_addr_cmd; 8384 cmdline_fixed_string_t what; 8385 cmdline_fixed_string_t port; 8386 uint16_t port_num; 8387 cmdline_fixed_string_t vf; 8388 uint8_t vf_num; 8389 struct ether_addr address; 8390 }; 8391 8392 static void cmd_vf_mac_addr_parsed(void *parsed_result, 8393 __attribute__((unused)) struct cmdline *cl, 8394 __attribute__((unused)) void *data) 8395 { 8396 struct cmd_vf_mac_addr_result *res = parsed_result; 8397 int ret = -ENOTSUP; 8398 8399 if (strcmp(res->what, "add") != 0) 8400 return; 8401 8402 #ifdef RTE_LIBRTE_I40E_PMD 8403 if (ret == -ENOTSUP) 8404 ret = rte_pmd_i40e_add_vf_mac_addr(res->port_num, res->vf_num, 8405 &res->address); 8406 #endif 8407 #ifdef RTE_LIBRTE_BNXT_PMD 8408 if (ret == -ENOTSUP) 8409 ret = rte_pmd_bnxt_mac_addr_add(res->port_num, &res->address, 8410 res->vf_num); 8411 #endif 8412 8413 if(ret < 0) 8414 printf("vf_mac_addr_cmd error: (%s)\n", strerror(-ret)); 8415 8416 } 8417 8418 cmdline_parse_token_string_t cmd_vf_mac_addr_cmd = 8419 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8420 mac_addr_cmd,"mac_addr"); 8421 cmdline_parse_token_string_t cmd_vf_mac_addr_what = 8422 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8423 what,"add"); 8424 cmdline_parse_token_string_t cmd_vf_mac_addr_port = 8425 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8426 port,"port"); 8427 cmdline_parse_token_num_t cmd_vf_mac_addr_portnum = 8428 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8429 port_num, UINT16); 8430 cmdline_parse_token_string_t cmd_vf_mac_addr_vf = 8431 TOKEN_STRING_INITIALIZER(struct cmd_vf_mac_addr_result, 8432 vf,"vf"); 8433 cmdline_parse_token_num_t cmd_vf_mac_addr_vfnum = 8434 TOKEN_NUM_INITIALIZER(struct cmd_vf_mac_addr_result, 8435 vf_num, UINT8); 8436 cmdline_parse_token_etheraddr_t cmd_vf_mac_addr_addr = 8437 TOKEN_ETHERADDR_INITIALIZER(struct cmd_vf_mac_addr_result, 8438 address); 8439 8440 cmdline_parse_inst_t cmd_vf_mac_addr_filter = { 8441 .f = cmd_vf_mac_addr_parsed, 8442 .data = (void *)0, 8443 .help_str = "mac_addr add port <port_id> vf <vf_id> <mac_addr>: " 8444 "Add MAC address filtering for a VF on port_id", 8445 .tokens = { 8446 (void *)&cmd_vf_mac_addr_cmd, 8447 (void *)&cmd_vf_mac_addr_what, 8448 (void *)&cmd_vf_mac_addr_port, 8449 (void *)&cmd_vf_mac_addr_portnum, 8450 (void *)&cmd_vf_mac_addr_vf, 8451 (void *)&cmd_vf_mac_addr_vfnum, 8452 (void *)&cmd_vf_mac_addr_addr, 8453 NULL, 8454 }, 8455 }; 8456 8457 /* *** ADD/REMOVE A VLAN IDENTIFIER TO/FROM A PORT VLAN RX FILTER *** */ 8458 struct cmd_vf_rx_vlan_filter { 8459 cmdline_fixed_string_t rx_vlan; 8460 cmdline_fixed_string_t what; 8461 uint16_t vlan_id; 8462 cmdline_fixed_string_t port; 8463 portid_t port_id; 8464 cmdline_fixed_string_t vf; 8465 uint64_t vf_mask; 8466 }; 8467 8468 static void 8469 cmd_vf_rx_vlan_filter_parsed(void *parsed_result, 8470 __attribute__((unused)) struct cmdline *cl, 8471 __attribute__((unused)) void *data) 8472 { 8473 struct cmd_vf_rx_vlan_filter *res = parsed_result; 8474 int ret = -ENOTSUP; 8475 8476 __rte_unused int is_add = (strcmp(res->what, "add") == 0) ? 1 : 0; 8477 8478 #ifdef RTE_LIBRTE_IXGBE_PMD 8479 if (ret == -ENOTSUP) 8480 ret = rte_pmd_ixgbe_set_vf_vlan_filter(res->port_id, 8481 res->vlan_id, res->vf_mask, is_add); 8482 #endif 8483 #ifdef RTE_LIBRTE_I40E_PMD 8484 if (ret == -ENOTSUP) 8485 ret = rte_pmd_i40e_set_vf_vlan_filter(res->port_id, 8486 res->vlan_id, res->vf_mask, is_add); 8487 #endif 8488 #ifdef RTE_LIBRTE_BNXT_PMD 8489 if (ret == -ENOTSUP) 8490 ret = rte_pmd_bnxt_set_vf_vlan_filter(res->port_id, 8491 res->vlan_id, res->vf_mask, is_add); 8492 #endif 8493 8494 switch (ret) { 8495 case 0: 8496 break; 8497 case -EINVAL: 8498 printf("invalid vlan_id %d or vf_mask %"PRIu64"\n", 8499 res->vlan_id, res->vf_mask); 8500 break; 8501 case -ENODEV: 8502 printf("invalid port_id %d\n", res->port_id); 8503 break; 8504 case -ENOTSUP: 8505 printf("function not implemented or supported\n"); 8506 break; 8507 default: 8508 printf("programming error: (%s)\n", strerror(-ret)); 8509 } 8510 } 8511 8512 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_rx_vlan = 8513 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8514 rx_vlan, "rx_vlan"); 8515 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_what = 8516 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8517 what, "add#rm"); 8518 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vlanid = 8519 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8520 vlan_id, UINT16); 8521 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_port = 8522 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8523 port, "port"); 8524 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_portid = 8525 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8526 port_id, UINT16); 8527 cmdline_parse_token_string_t cmd_vf_rx_vlan_filter_vf = 8528 TOKEN_STRING_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8529 vf, "vf"); 8530 cmdline_parse_token_num_t cmd_vf_rx_vlan_filter_vf_mask = 8531 TOKEN_NUM_INITIALIZER(struct cmd_vf_rx_vlan_filter, 8532 vf_mask, UINT64); 8533 8534 cmdline_parse_inst_t cmd_vf_rxvlan_filter = { 8535 .f = cmd_vf_rx_vlan_filter_parsed, 8536 .data = NULL, 8537 .help_str = "rx_vlan add|rm <vlan_id> port <port_id> vf <vf_mask>: " 8538 "(vf_mask = hexadecimal VF mask)", 8539 .tokens = { 8540 (void *)&cmd_vf_rx_vlan_filter_rx_vlan, 8541 (void *)&cmd_vf_rx_vlan_filter_what, 8542 (void *)&cmd_vf_rx_vlan_filter_vlanid, 8543 (void *)&cmd_vf_rx_vlan_filter_port, 8544 (void *)&cmd_vf_rx_vlan_filter_portid, 8545 (void *)&cmd_vf_rx_vlan_filter_vf, 8546 (void *)&cmd_vf_rx_vlan_filter_vf_mask, 8547 NULL, 8548 }, 8549 }; 8550 8551 /* *** SET RATE LIMIT FOR A QUEUE OF A PORT *** */ 8552 struct cmd_queue_rate_limit_result { 8553 cmdline_fixed_string_t set; 8554 cmdline_fixed_string_t port; 8555 uint16_t port_num; 8556 cmdline_fixed_string_t queue; 8557 uint8_t queue_num; 8558 cmdline_fixed_string_t rate; 8559 uint16_t rate_num; 8560 }; 8561 8562 static void cmd_queue_rate_limit_parsed(void *parsed_result, 8563 __attribute__((unused)) struct cmdline *cl, 8564 __attribute__((unused)) void *data) 8565 { 8566 struct cmd_queue_rate_limit_result *res = parsed_result; 8567 int ret = 0; 8568 8569 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8570 && (strcmp(res->queue, "queue") == 0) 8571 && (strcmp(res->rate, "rate") == 0)) 8572 ret = set_queue_rate_limit(res->port_num, res->queue_num, 8573 res->rate_num); 8574 if (ret < 0) 8575 printf("queue_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8576 8577 } 8578 8579 cmdline_parse_token_string_t cmd_queue_rate_limit_set = 8580 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8581 set, "set"); 8582 cmdline_parse_token_string_t cmd_queue_rate_limit_port = 8583 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8584 port, "port"); 8585 cmdline_parse_token_num_t cmd_queue_rate_limit_portnum = 8586 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8587 port_num, UINT16); 8588 cmdline_parse_token_string_t cmd_queue_rate_limit_queue = 8589 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8590 queue, "queue"); 8591 cmdline_parse_token_num_t cmd_queue_rate_limit_queuenum = 8592 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8593 queue_num, UINT8); 8594 cmdline_parse_token_string_t cmd_queue_rate_limit_rate = 8595 TOKEN_STRING_INITIALIZER(struct cmd_queue_rate_limit_result, 8596 rate, "rate"); 8597 cmdline_parse_token_num_t cmd_queue_rate_limit_ratenum = 8598 TOKEN_NUM_INITIALIZER(struct cmd_queue_rate_limit_result, 8599 rate_num, UINT16); 8600 8601 cmdline_parse_inst_t cmd_queue_rate_limit = { 8602 .f = cmd_queue_rate_limit_parsed, 8603 .data = (void *)0, 8604 .help_str = "set port <port_id> queue <queue_id> rate <rate_value>: " 8605 "Set rate limit for a queue on port_id", 8606 .tokens = { 8607 (void *)&cmd_queue_rate_limit_set, 8608 (void *)&cmd_queue_rate_limit_port, 8609 (void *)&cmd_queue_rate_limit_portnum, 8610 (void *)&cmd_queue_rate_limit_queue, 8611 (void *)&cmd_queue_rate_limit_queuenum, 8612 (void *)&cmd_queue_rate_limit_rate, 8613 (void *)&cmd_queue_rate_limit_ratenum, 8614 NULL, 8615 }, 8616 }; 8617 8618 /* *** SET RATE LIMIT FOR A VF OF A PORT *** */ 8619 struct cmd_vf_rate_limit_result { 8620 cmdline_fixed_string_t set; 8621 cmdline_fixed_string_t port; 8622 uint16_t port_num; 8623 cmdline_fixed_string_t vf; 8624 uint8_t vf_num; 8625 cmdline_fixed_string_t rate; 8626 uint16_t rate_num; 8627 cmdline_fixed_string_t q_msk; 8628 uint64_t q_msk_val; 8629 }; 8630 8631 static void cmd_vf_rate_limit_parsed(void *parsed_result, 8632 __attribute__((unused)) struct cmdline *cl, 8633 __attribute__((unused)) void *data) 8634 { 8635 struct cmd_vf_rate_limit_result *res = parsed_result; 8636 int ret = 0; 8637 8638 if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) 8639 && (strcmp(res->vf, "vf") == 0) 8640 && (strcmp(res->rate, "rate") == 0) 8641 && (strcmp(res->q_msk, "queue_mask") == 0)) 8642 ret = set_vf_rate_limit(res->port_num, res->vf_num, 8643 res->rate_num, res->q_msk_val); 8644 if (ret < 0) 8645 printf("vf_rate_limit_cmd error: (%s)\n", strerror(-ret)); 8646 8647 } 8648 8649 cmdline_parse_token_string_t cmd_vf_rate_limit_set = 8650 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8651 set, "set"); 8652 cmdline_parse_token_string_t cmd_vf_rate_limit_port = 8653 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8654 port, "port"); 8655 cmdline_parse_token_num_t cmd_vf_rate_limit_portnum = 8656 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8657 port_num, UINT16); 8658 cmdline_parse_token_string_t cmd_vf_rate_limit_vf = 8659 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8660 vf, "vf"); 8661 cmdline_parse_token_num_t cmd_vf_rate_limit_vfnum = 8662 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8663 vf_num, UINT8); 8664 cmdline_parse_token_string_t cmd_vf_rate_limit_rate = 8665 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8666 rate, "rate"); 8667 cmdline_parse_token_num_t cmd_vf_rate_limit_ratenum = 8668 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8669 rate_num, UINT16); 8670 cmdline_parse_token_string_t cmd_vf_rate_limit_q_msk = 8671 TOKEN_STRING_INITIALIZER(struct cmd_vf_rate_limit_result, 8672 q_msk, "queue_mask"); 8673 cmdline_parse_token_num_t cmd_vf_rate_limit_q_msk_val = 8674 TOKEN_NUM_INITIALIZER(struct cmd_vf_rate_limit_result, 8675 q_msk_val, UINT64); 8676 8677 cmdline_parse_inst_t cmd_vf_rate_limit = { 8678 .f = cmd_vf_rate_limit_parsed, 8679 .data = (void *)0, 8680 .help_str = "set port <port_id> vf <vf_id> rate <rate_value> " 8681 "queue_mask <queue_mask_value>: " 8682 "Set rate limit for queues of VF on port_id", 8683 .tokens = { 8684 (void *)&cmd_vf_rate_limit_set, 8685 (void *)&cmd_vf_rate_limit_port, 8686 (void *)&cmd_vf_rate_limit_portnum, 8687 (void *)&cmd_vf_rate_limit_vf, 8688 (void *)&cmd_vf_rate_limit_vfnum, 8689 (void *)&cmd_vf_rate_limit_rate, 8690 (void *)&cmd_vf_rate_limit_ratenum, 8691 (void *)&cmd_vf_rate_limit_q_msk, 8692 (void *)&cmd_vf_rate_limit_q_msk_val, 8693 NULL, 8694 }, 8695 }; 8696 8697 /* *** ADD TUNNEL FILTER OF A PORT *** */ 8698 struct cmd_tunnel_filter_result { 8699 cmdline_fixed_string_t cmd; 8700 cmdline_fixed_string_t what; 8701 portid_t port_id; 8702 struct ether_addr outer_mac; 8703 struct ether_addr inner_mac; 8704 cmdline_ipaddr_t ip_value; 8705 uint16_t inner_vlan; 8706 cmdline_fixed_string_t tunnel_type; 8707 cmdline_fixed_string_t filter_type; 8708 uint32_t tenant_id; 8709 uint16_t queue_num; 8710 }; 8711 8712 static void 8713 cmd_tunnel_filter_parsed(void *parsed_result, 8714 __attribute__((unused)) struct cmdline *cl, 8715 __attribute__((unused)) void *data) 8716 { 8717 struct cmd_tunnel_filter_result *res = parsed_result; 8718 struct rte_eth_tunnel_filter_conf tunnel_filter_conf; 8719 int ret = 0; 8720 8721 memset(&tunnel_filter_conf, 0, sizeof(tunnel_filter_conf)); 8722 8723 ether_addr_copy(&res->outer_mac, &tunnel_filter_conf.outer_mac); 8724 ether_addr_copy(&res->inner_mac, &tunnel_filter_conf.inner_mac); 8725 tunnel_filter_conf.inner_vlan = res->inner_vlan; 8726 8727 if (res->ip_value.family == AF_INET) { 8728 tunnel_filter_conf.ip_addr.ipv4_addr = 8729 res->ip_value.addr.ipv4.s_addr; 8730 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV4; 8731 } else { 8732 memcpy(&(tunnel_filter_conf.ip_addr.ipv6_addr), 8733 &(res->ip_value.addr.ipv6), 8734 sizeof(struct in6_addr)); 8735 tunnel_filter_conf.ip_type = RTE_TUNNEL_IPTYPE_IPV6; 8736 } 8737 8738 if (!strcmp(res->filter_type, "imac-ivlan")) 8739 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_IVLAN; 8740 else if (!strcmp(res->filter_type, "imac-ivlan-tenid")) 8741 tunnel_filter_conf.filter_type = 8742 RTE_TUNNEL_FILTER_IMAC_IVLAN_TENID; 8743 else if (!strcmp(res->filter_type, "imac-tenid")) 8744 tunnel_filter_conf.filter_type = RTE_TUNNEL_FILTER_IMAC_TENID; 8745 else if (!strcmp(res->filter_type, "imac")) 8746 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IMAC; 8747 else if (!strcmp(res->filter_type, "omac-imac-tenid")) 8748 tunnel_filter_conf.filter_type = 8749 RTE_TUNNEL_FILTER_OMAC_TENID_IMAC; 8750 else if (!strcmp(res->filter_type, "oip")) 8751 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_OIP; 8752 else if (!strcmp(res->filter_type, "iip")) 8753 tunnel_filter_conf.filter_type = ETH_TUNNEL_FILTER_IIP; 8754 else { 8755 printf("The filter type is not supported"); 8756 return; 8757 } 8758 8759 if (!strcmp(res->tunnel_type, "vxlan")) 8760 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN; 8761 else if (!strcmp(res->tunnel_type, "nvgre")) 8762 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_NVGRE; 8763 else if (!strcmp(res->tunnel_type, "ipingre")) 8764 tunnel_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_IP_IN_GRE; 8765 else { 8766 printf("The tunnel type %s not supported.\n", res->tunnel_type); 8767 return; 8768 } 8769 8770 tunnel_filter_conf.tenant_id = res->tenant_id; 8771 tunnel_filter_conf.queue_id = res->queue_num; 8772 if (!strcmp(res->what, "add")) 8773 ret = rte_eth_dev_filter_ctrl(res->port_id, 8774 RTE_ETH_FILTER_TUNNEL, 8775 RTE_ETH_FILTER_ADD, 8776 &tunnel_filter_conf); 8777 else 8778 ret = rte_eth_dev_filter_ctrl(res->port_id, 8779 RTE_ETH_FILTER_TUNNEL, 8780 RTE_ETH_FILTER_DELETE, 8781 &tunnel_filter_conf); 8782 if (ret < 0) 8783 printf("cmd_tunnel_filter_parsed error: (%s)\n", 8784 strerror(-ret)); 8785 8786 } 8787 cmdline_parse_token_string_t cmd_tunnel_filter_cmd = 8788 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8789 cmd, "tunnel_filter"); 8790 cmdline_parse_token_string_t cmd_tunnel_filter_what = 8791 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8792 what, "add#rm"); 8793 cmdline_parse_token_num_t cmd_tunnel_filter_port_id = 8794 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8795 port_id, UINT16); 8796 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_outer_mac = 8797 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8798 outer_mac); 8799 cmdline_parse_token_etheraddr_t cmd_tunnel_filter_inner_mac = 8800 TOKEN_ETHERADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8801 inner_mac); 8802 cmdline_parse_token_num_t cmd_tunnel_filter_innner_vlan = 8803 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8804 inner_vlan, UINT16); 8805 cmdline_parse_token_ipaddr_t cmd_tunnel_filter_ip_value = 8806 TOKEN_IPADDR_INITIALIZER(struct cmd_tunnel_filter_result, 8807 ip_value); 8808 cmdline_parse_token_string_t cmd_tunnel_filter_tunnel_type = 8809 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8810 tunnel_type, "vxlan#nvgre#ipingre"); 8811 8812 cmdline_parse_token_string_t cmd_tunnel_filter_filter_type = 8813 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_filter_result, 8814 filter_type, "oip#iip#imac-ivlan#imac-ivlan-tenid#imac-tenid#" 8815 "imac#omac-imac-tenid"); 8816 cmdline_parse_token_num_t cmd_tunnel_filter_tenant_id = 8817 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8818 tenant_id, UINT32); 8819 cmdline_parse_token_num_t cmd_tunnel_filter_queue_num = 8820 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_filter_result, 8821 queue_num, UINT16); 8822 8823 cmdline_parse_inst_t cmd_tunnel_filter = { 8824 .f = cmd_tunnel_filter_parsed, 8825 .data = (void *)0, 8826 .help_str = "tunnel_filter add|rm <port_id> <outer_mac> <inner_mac> " 8827 "<ip> <inner_vlan> vxlan|nvgre|ipingre oip|iip|imac-ivlan|" 8828 "imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid <tenant_id> " 8829 "<queue_id>: Add/Rm tunnel filter of a port", 8830 .tokens = { 8831 (void *)&cmd_tunnel_filter_cmd, 8832 (void *)&cmd_tunnel_filter_what, 8833 (void *)&cmd_tunnel_filter_port_id, 8834 (void *)&cmd_tunnel_filter_outer_mac, 8835 (void *)&cmd_tunnel_filter_inner_mac, 8836 (void *)&cmd_tunnel_filter_ip_value, 8837 (void *)&cmd_tunnel_filter_innner_vlan, 8838 (void *)&cmd_tunnel_filter_tunnel_type, 8839 (void *)&cmd_tunnel_filter_filter_type, 8840 (void *)&cmd_tunnel_filter_tenant_id, 8841 (void *)&cmd_tunnel_filter_queue_num, 8842 NULL, 8843 }, 8844 }; 8845 8846 /* *** CONFIGURE TUNNEL UDP PORT *** */ 8847 struct cmd_tunnel_udp_config { 8848 cmdline_fixed_string_t cmd; 8849 cmdline_fixed_string_t what; 8850 uint16_t udp_port; 8851 portid_t port_id; 8852 }; 8853 8854 static void 8855 cmd_tunnel_udp_config_parsed(void *parsed_result, 8856 __attribute__((unused)) struct cmdline *cl, 8857 __attribute__((unused)) void *data) 8858 { 8859 struct cmd_tunnel_udp_config *res = parsed_result; 8860 struct rte_eth_udp_tunnel tunnel_udp; 8861 int ret; 8862 8863 tunnel_udp.udp_port = res->udp_port; 8864 8865 if (!strcmp(res->cmd, "rx_vxlan_port")) 8866 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 8867 8868 if (!strcmp(res->what, "add")) 8869 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 8870 &tunnel_udp); 8871 else 8872 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 8873 &tunnel_udp); 8874 8875 if (ret < 0) 8876 printf("udp tunneling add error: (%s)\n", strerror(-ret)); 8877 } 8878 8879 cmdline_parse_token_string_t cmd_tunnel_udp_config_cmd = 8880 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 8881 cmd, "rx_vxlan_port"); 8882 cmdline_parse_token_string_t cmd_tunnel_udp_config_what = 8883 TOKEN_STRING_INITIALIZER(struct cmd_tunnel_udp_config, 8884 what, "add#rm"); 8885 cmdline_parse_token_num_t cmd_tunnel_udp_config_udp_port = 8886 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 8887 udp_port, UINT16); 8888 cmdline_parse_token_num_t cmd_tunnel_udp_config_port_id = 8889 TOKEN_NUM_INITIALIZER(struct cmd_tunnel_udp_config, 8890 port_id, UINT16); 8891 8892 cmdline_parse_inst_t cmd_tunnel_udp_config = { 8893 .f = cmd_tunnel_udp_config_parsed, 8894 .data = (void *)0, 8895 .help_str = "rx_vxlan_port add|rm <udp_port> <port_id>: " 8896 "Add/Remove a tunneling UDP port filter", 8897 .tokens = { 8898 (void *)&cmd_tunnel_udp_config_cmd, 8899 (void *)&cmd_tunnel_udp_config_what, 8900 (void *)&cmd_tunnel_udp_config_udp_port, 8901 (void *)&cmd_tunnel_udp_config_port_id, 8902 NULL, 8903 }, 8904 }; 8905 8906 struct cmd_config_tunnel_udp_port { 8907 cmdline_fixed_string_t port; 8908 cmdline_fixed_string_t config; 8909 portid_t port_id; 8910 cmdline_fixed_string_t udp_tunnel_port; 8911 cmdline_fixed_string_t action; 8912 cmdline_fixed_string_t tunnel_type; 8913 uint16_t udp_port; 8914 }; 8915 8916 static void 8917 cmd_cfg_tunnel_udp_port_parsed(void *parsed_result, 8918 __attribute__((unused)) struct cmdline *cl, 8919 __attribute__((unused)) void *data) 8920 { 8921 struct cmd_config_tunnel_udp_port *res = parsed_result; 8922 struct rte_eth_udp_tunnel tunnel_udp; 8923 int ret = 0; 8924 8925 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 8926 return; 8927 8928 tunnel_udp.udp_port = res->udp_port; 8929 8930 if (!strcmp(res->tunnel_type, "vxlan")) { 8931 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_VXLAN; 8932 } else if (!strcmp(res->tunnel_type, "geneve")) { 8933 tunnel_udp.prot_type = RTE_TUNNEL_TYPE_GENEVE; 8934 } else { 8935 printf("Invalid tunnel type\n"); 8936 return; 8937 } 8938 8939 if (!strcmp(res->action, "add")) 8940 ret = rte_eth_dev_udp_tunnel_port_add(res->port_id, 8941 &tunnel_udp); 8942 else 8943 ret = rte_eth_dev_udp_tunnel_port_delete(res->port_id, 8944 &tunnel_udp); 8945 8946 if (ret < 0) 8947 printf("udp tunneling port add error: (%s)\n", strerror(-ret)); 8948 } 8949 8950 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_port = 8951 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, port, 8952 "port"); 8953 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_config = 8954 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, config, 8955 "config"); 8956 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_port_id = 8957 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, port_id, 8958 UINT16); 8959 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_port = 8960 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, 8961 udp_tunnel_port, 8962 "udp_tunnel_port"); 8963 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_action = 8964 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, action, 8965 "add#rm"); 8966 cmdline_parse_token_string_t cmd_config_tunnel_udp_port_tunnel_type = 8967 TOKEN_STRING_INITIALIZER(struct cmd_config_tunnel_udp_port, tunnel_type, 8968 "vxlan#geneve"); 8969 cmdline_parse_token_num_t cmd_config_tunnel_udp_port_value = 8970 TOKEN_NUM_INITIALIZER(struct cmd_config_tunnel_udp_port, udp_port, 8971 UINT16); 8972 8973 cmdline_parse_inst_t cmd_cfg_tunnel_udp_port = { 8974 .f = cmd_cfg_tunnel_udp_port_parsed, 8975 .data = NULL, 8976 .help_str = "port config <port_id> udp_tunnel_port add|rm vxlan|geneve <udp_port>", 8977 .tokens = { 8978 (void *)&cmd_config_tunnel_udp_port_port, 8979 (void *)&cmd_config_tunnel_udp_port_config, 8980 (void *)&cmd_config_tunnel_udp_port_port_id, 8981 (void *)&cmd_config_tunnel_udp_port_tunnel_port, 8982 (void *)&cmd_config_tunnel_udp_port_action, 8983 (void *)&cmd_config_tunnel_udp_port_tunnel_type, 8984 (void *)&cmd_config_tunnel_udp_port_value, 8985 NULL, 8986 }, 8987 }; 8988 8989 /* *** GLOBAL CONFIG *** */ 8990 struct cmd_global_config_result { 8991 cmdline_fixed_string_t cmd; 8992 portid_t port_id; 8993 cmdline_fixed_string_t cfg_type; 8994 uint8_t len; 8995 }; 8996 8997 static void 8998 cmd_global_config_parsed(void *parsed_result, 8999 __attribute__((unused)) struct cmdline *cl, 9000 __attribute__((unused)) void *data) 9001 { 9002 struct cmd_global_config_result *res = parsed_result; 9003 struct rte_eth_global_cfg conf; 9004 int ret; 9005 9006 memset(&conf, 0, sizeof(conf)); 9007 conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN; 9008 conf.cfg.gre_key_len = res->len; 9009 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE, 9010 RTE_ETH_FILTER_SET, &conf); 9011 if (ret != 0) 9012 printf("Global config error\n"); 9013 } 9014 9015 cmdline_parse_token_string_t cmd_global_config_cmd = 9016 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd, 9017 "global_config"); 9018 cmdline_parse_token_num_t cmd_global_config_port_id = 9019 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, 9020 UINT16); 9021 cmdline_parse_token_string_t cmd_global_config_type = 9022 TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, 9023 cfg_type, "gre-key-len"); 9024 cmdline_parse_token_num_t cmd_global_config_gre_key_len = 9025 TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, 9026 len, UINT8); 9027 9028 cmdline_parse_inst_t cmd_global_config = { 9029 .f = cmd_global_config_parsed, 9030 .data = (void *)NULL, 9031 .help_str = "global_config <port_id> gre-key-len <key_len>", 9032 .tokens = { 9033 (void *)&cmd_global_config_cmd, 9034 (void *)&cmd_global_config_port_id, 9035 (void *)&cmd_global_config_type, 9036 (void *)&cmd_global_config_gre_key_len, 9037 NULL, 9038 }, 9039 }; 9040 9041 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */ 9042 struct cmd_set_mirror_mask_result { 9043 cmdline_fixed_string_t set; 9044 cmdline_fixed_string_t port; 9045 portid_t port_id; 9046 cmdline_fixed_string_t mirror; 9047 uint8_t rule_id; 9048 cmdline_fixed_string_t what; 9049 cmdline_fixed_string_t value; 9050 cmdline_fixed_string_t dstpool; 9051 uint8_t dstpool_id; 9052 cmdline_fixed_string_t on; 9053 }; 9054 9055 cmdline_parse_token_string_t cmd_mirror_mask_set = 9056 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9057 set, "set"); 9058 cmdline_parse_token_string_t cmd_mirror_mask_port = 9059 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9060 port, "port"); 9061 cmdline_parse_token_num_t cmd_mirror_mask_portid = 9062 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9063 port_id, UINT16); 9064 cmdline_parse_token_string_t cmd_mirror_mask_mirror = 9065 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9066 mirror, "mirror-rule"); 9067 cmdline_parse_token_num_t cmd_mirror_mask_ruleid = 9068 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9069 rule_id, UINT8); 9070 cmdline_parse_token_string_t cmd_mirror_mask_what = 9071 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9072 what, "pool-mirror-up#pool-mirror-down" 9073 "#vlan-mirror"); 9074 cmdline_parse_token_string_t cmd_mirror_mask_value = 9075 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9076 value, NULL); 9077 cmdline_parse_token_string_t cmd_mirror_mask_dstpool = 9078 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9079 dstpool, "dst-pool"); 9080 cmdline_parse_token_num_t cmd_mirror_mask_poolid = 9081 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_mask_result, 9082 dstpool_id, UINT8); 9083 cmdline_parse_token_string_t cmd_mirror_mask_on = 9084 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_mask_result, 9085 on, "on#off"); 9086 9087 static void 9088 cmd_set_mirror_mask_parsed(void *parsed_result, 9089 __attribute__((unused)) struct cmdline *cl, 9090 __attribute__((unused)) void *data) 9091 { 9092 int ret,nb_item,i; 9093 struct cmd_set_mirror_mask_result *res = parsed_result; 9094 struct rte_eth_mirror_conf mr_conf; 9095 9096 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9097 9098 unsigned int vlan_list[ETH_MIRROR_MAX_VLANS]; 9099 9100 mr_conf.dst_pool = res->dstpool_id; 9101 9102 if (!strcmp(res->what, "pool-mirror-up")) { 9103 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9104 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_UP; 9105 } else if (!strcmp(res->what, "pool-mirror-down")) { 9106 mr_conf.pool_mask = strtoull(res->value, NULL, 16); 9107 mr_conf.rule_type = ETH_MIRROR_VIRTUAL_POOL_DOWN; 9108 } else if (!strcmp(res->what, "vlan-mirror")) { 9109 mr_conf.rule_type = ETH_MIRROR_VLAN; 9110 nb_item = parse_item_list(res->value, "vlan", 9111 ETH_MIRROR_MAX_VLANS, vlan_list, 1); 9112 if (nb_item <= 0) 9113 return; 9114 9115 for (i = 0; i < nb_item; i++) { 9116 if (vlan_list[i] > ETHER_MAX_VLAN_ID) { 9117 printf("Invalid vlan_id: must be < 4096\n"); 9118 return; 9119 } 9120 9121 mr_conf.vlan.vlan_id[i] = (uint16_t)vlan_list[i]; 9122 mr_conf.vlan.vlan_mask |= 1ULL << i; 9123 } 9124 } 9125 9126 if (!strcmp(res->on, "on")) 9127 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9128 res->rule_id, 1); 9129 else 9130 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9131 res->rule_id, 0); 9132 if (ret < 0) 9133 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9134 } 9135 9136 cmdline_parse_inst_t cmd_set_mirror_mask = { 9137 .f = cmd_set_mirror_mask_parsed, 9138 .data = NULL, 9139 .help_str = "set port <port_id> mirror-rule <rule_id> " 9140 "pool-mirror-up|pool-mirror-down|vlan-mirror " 9141 "<pool_mask|vlan_id[,vlan_id]*> dst-pool <pool_id> on|off", 9142 .tokens = { 9143 (void *)&cmd_mirror_mask_set, 9144 (void *)&cmd_mirror_mask_port, 9145 (void *)&cmd_mirror_mask_portid, 9146 (void *)&cmd_mirror_mask_mirror, 9147 (void *)&cmd_mirror_mask_ruleid, 9148 (void *)&cmd_mirror_mask_what, 9149 (void *)&cmd_mirror_mask_value, 9150 (void *)&cmd_mirror_mask_dstpool, 9151 (void *)&cmd_mirror_mask_poolid, 9152 (void *)&cmd_mirror_mask_on, 9153 NULL, 9154 }, 9155 }; 9156 9157 /* *** CONFIGURE VM MIRROR UPLINK/DOWNLINK RULE *** */ 9158 struct cmd_set_mirror_link_result { 9159 cmdline_fixed_string_t set; 9160 cmdline_fixed_string_t port; 9161 portid_t port_id; 9162 cmdline_fixed_string_t mirror; 9163 uint8_t rule_id; 9164 cmdline_fixed_string_t what; 9165 cmdline_fixed_string_t dstpool; 9166 uint8_t dstpool_id; 9167 cmdline_fixed_string_t on; 9168 }; 9169 9170 cmdline_parse_token_string_t cmd_mirror_link_set = 9171 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9172 set, "set"); 9173 cmdline_parse_token_string_t cmd_mirror_link_port = 9174 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9175 port, "port"); 9176 cmdline_parse_token_num_t cmd_mirror_link_portid = 9177 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9178 port_id, UINT16); 9179 cmdline_parse_token_string_t cmd_mirror_link_mirror = 9180 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9181 mirror, "mirror-rule"); 9182 cmdline_parse_token_num_t cmd_mirror_link_ruleid = 9183 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9184 rule_id, UINT8); 9185 cmdline_parse_token_string_t cmd_mirror_link_what = 9186 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9187 what, "uplink-mirror#downlink-mirror"); 9188 cmdline_parse_token_string_t cmd_mirror_link_dstpool = 9189 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9190 dstpool, "dst-pool"); 9191 cmdline_parse_token_num_t cmd_mirror_link_poolid = 9192 TOKEN_NUM_INITIALIZER(struct cmd_set_mirror_link_result, 9193 dstpool_id, UINT8); 9194 cmdline_parse_token_string_t cmd_mirror_link_on = 9195 TOKEN_STRING_INITIALIZER(struct cmd_set_mirror_link_result, 9196 on, "on#off"); 9197 9198 static void 9199 cmd_set_mirror_link_parsed(void *parsed_result, 9200 __attribute__((unused)) struct cmdline *cl, 9201 __attribute__((unused)) void *data) 9202 { 9203 int ret; 9204 struct cmd_set_mirror_link_result *res = parsed_result; 9205 struct rte_eth_mirror_conf mr_conf; 9206 9207 memset(&mr_conf, 0, sizeof(struct rte_eth_mirror_conf)); 9208 if (!strcmp(res->what, "uplink-mirror")) 9209 mr_conf.rule_type = ETH_MIRROR_UPLINK_PORT; 9210 else 9211 mr_conf.rule_type = ETH_MIRROR_DOWNLINK_PORT; 9212 9213 mr_conf.dst_pool = res->dstpool_id; 9214 9215 if (!strcmp(res->on, "on")) 9216 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9217 res->rule_id, 1); 9218 else 9219 ret = rte_eth_mirror_rule_set(res->port_id, &mr_conf, 9220 res->rule_id, 0); 9221 9222 /* check the return value and print it if is < 0 */ 9223 if (ret < 0) 9224 printf("mirror rule add error: (%s)\n", strerror(-ret)); 9225 9226 } 9227 9228 cmdline_parse_inst_t cmd_set_mirror_link = { 9229 .f = cmd_set_mirror_link_parsed, 9230 .data = NULL, 9231 .help_str = "set port <port_id> mirror-rule <rule_id> " 9232 "uplink-mirror|downlink-mirror dst-pool <pool_id> on|off", 9233 .tokens = { 9234 (void *)&cmd_mirror_link_set, 9235 (void *)&cmd_mirror_link_port, 9236 (void *)&cmd_mirror_link_portid, 9237 (void *)&cmd_mirror_link_mirror, 9238 (void *)&cmd_mirror_link_ruleid, 9239 (void *)&cmd_mirror_link_what, 9240 (void *)&cmd_mirror_link_dstpool, 9241 (void *)&cmd_mirror_link_poolid, 9242 (void *)&cmd_mirror_link_on, 9243 NULL, 9244 }, 9245 }; 9246 9247 /* *** RESET VM MIRROR RULE *** */ 9248 struct cmd_rm_mirror_rule_result { 9249 cmdline_fixed_string_t reset; 9250 cmdline_fixed_string_t port; 9251 portid_t port_id; 9252 cmdline_fixed_string_t mirror; 9253 uint8_t rule_id; 9254 }; 9255 9256 cmdline_parse_token_string_t cmd_rm_mirror_rule_reset = 9257 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9258 reset, "reset"); 9259 cmdline_parse_token_string_t cmd_rm_mirror_rule_port = 9260 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9261 port, "port"); 9262 cmdline_parse_token_num_t cmd_rm_mirror_rule_portid = 9263 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9264 port_id, UINT16); 9265 cmdline_parse_token_string_t cmd_rm_mirror_rule_mirror = 9266 TOKEN_STRING_INITIALIZER(struct cmd_rm_mirror_rule_result, 9267 mirror, "mirror-rule"); 9268 cmdline_parse_token_num_t cmd_rm_mirror_rule_ruleid = 9269 TOKEN_NUM_INITIALIZER(struct cmd_rm_mirror_rule_result, 9270 rule_id, UINT8); 9271 9272 static void 9273 cmd_reset_mirror_rule_parsed(void *parsed_result, 9274 __attribute__((unused)) struct cmdline *cl, 9275 __attribute__((unused)) void *data) 9276 { 9277 int ret; 9278 struct cmd_set_mirror_link_result *res = parsed_result; 9279 /* check rule_id */ 9280 ret = rte_eth_mirror_rule_reset(res->port_id,res->rule_id); 9281 if(ret < 0) 9282 printf("mirror rule remove error: (%s)\n", strerror(-ret)); 9283 } 9284 9285 cmdline_parse_inst_t cmd_reset_mirror_rule = { 9286 .f = cmd_reset_mirror_rule_parsed, 9287 .data = NULL, 9288 .help_str = "reset port <port_id> mirror-rule <rule_id>", 9289 .tokens = { 9290 (void *)&cmd_rm_mirror_rule_reset, 9291 (void *)&cmd_rm_mirror_rule_port, 9292 (void *)&cmd_rm_mirror_rule_portid, 9293 (void *)&cmd_rm_mirror_rule_mirror, 9294 (void *)&cmd_rm_mirror_rule_ruleid, 9295 NULL, 9296 }, 9297 }; 9298 9299 /* ******************************************************************************** */ 9300 9301 struct cmd_dump_result { 9302 cmdline_fixed_string_t dump; 9303 }; 9304 9305 static void 9306 dump_struct_sizes(void) 9307 { 9308 #define DUMP_SIZE(t) printf("sizeof(" #t ") = %u\n", (unsigned)sizeof(t)); 9309 DUMP_SIZE(struct rte_mbuf); 9310 DUMP_SIZE(struct rte_mempool); 9311 DUMP_SIZE(struct rte_ring); 9312 #undef DUMP_SIZE 9313 } 9314 9315 static void cmd_dump_parsed(void *parsed_result, 9316 __attribute__((unused)) struct cmdline *cl, 9317 __attribute__((unused)) void *data) 9318 { 9319 struct cmd_dump_result *res = parsed_result; 9320 9321 if (!strcmp(res->dump, "dump_physmem")) 9322 rte_dump_physmem_layout(stdout); 9323 else if (!strcmp(res->dump, "dump_memzone")) 9324 rte_memzone_dump(stdout); 9325 else if (!strcmp(res->dump, "dump_struct_sizes")) 9326 dump_struct_sizes(); 9327 else if (!strcmp(res->dump, "dump_ring")) 9328 rte_ring_list_dump(stdout); 9329 else if (!strcmp(res->dump, "dump_mempool")) 9330 rte_mempool_list_dump(stdout); 9331 else if (!strcmp(res->dump, "dump_devargs")) 9332 rte_devargs_dump(stdout); 9333 else if (!strcmp(res->dump, "dump_log_types")) 9334 rte_log_dump(stdout); 9335 } 9336 9337 cmdline_parse_token_string_t cmd_dump_dump = 9338 TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump, 9339 "dump_physmem#" 9340 "dump_memzone#" 9341 "dump_struct_sizes#" 9342 "dump_ring#" 9343 "dump_mempool#" 9344 "dump_devargs#" 9345 "dump_log_types"); 9346 9347 cmdline_parse_inst_t cmd_dump = { 9348 .f = cmd_dump_parsed, /* function to call */ 9349 .data = NULL, /* 2nd arg of func */ 9350 .help_str = "Dump status", 9351 .tokens = { /* token list, NULL terminated */ 9352 (void *)&cmd_dump_dump, 9353 NULL, 9354 }, 9355 }; 9356 9357 /* ******************************************************************************** */ 9358 9359 struct cmd_dump_one_result { 9360 cmdline_fixed_string_t dump; 9361 cmdline_fixed_string_t name; 9362 }; 9363 9364 static void cmd_dump_one_parsed(void *parsed_result, struct cmdline *cl, 9365 __attribute__((unused)) void *data) 9366 { 9367 struct cmd_dump_one_result *res = parsed_result; 9368 9369 if (!strcmp(res->dump, "dump_ring")) { 9370 struct rte_ring *r; 9371 r = rte_ring_lookup(res->name); 9372 if (r == NULL) { 9373 cmdline_printf(cl, "Cannot find ring\n"); 9374 return; 9375 } 9376 rte_ring_dump(stdout, r); 9377 } else if (!strcmp(res->dump, "dump_mempool")) { 9378 struct rte_mempool *mp; 9379 mp = rte_mempool_lookup(res->name); 9380 if (mp == NULL) { 9381 cmdline_printf(cl, "Cannot find mempool\n"); 9382 return; 9383 } 9384 rte_mempool_dump(stdout, mp); 9385 } 9386 } 9387 9388 cmdline_parse_token_string_t cmd_dump_one_dump = 9389 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, dump, 9390 "dump_ring#dump_mempool"); 9391 9392 cmdline_parse_token_string_t cmd_dump_one_name = 9393 TOKEN_STRING_INITIALIZER(struct cmd_dump_one_result, name, NULL); 9394 9395 cmdline_parse_inst_t cmd_dump_one = { 9396 .f = cmd_dump_one_parsed, /* function to call */ 9397 .data = NULL, /* 2nd arg of func */ 9398 .help_str = "dump_ring|dump_mempool <name>: Dump one ring/mempool", 9399 .tokens = { /* token list, NULL terminated */ 9400 (void *)&cmd_dump_one_dump, 9401 (void *)&cmd_dump_one_name, 9402 NULL, 9403 }, 9404 }; 9405 9406 /* *** Add/Del syn filter *** */ 9407 struct cmd_syn_filter_result { 9408 cmdline_fixed_string_t filter; 9409 portid_t port_id; 9410 cmdline_fixed_string_t ops; 9411 cmdline_fixed_string_t priority; 9412 cmdline_fixed_string_t high; 9413 cmdline_fixed_string_t queue; 9414 uint16_t queue_id; 9415 }; 9416 9417 static void 9418 cmd_syn_filter_parsed(void *parsed_result, 9419 __attribute__((unused)) struct cmdline *cl, 9420 __attribute__((unused)) void *data) 9421 { 9422 struct cmd_syn_filter_result *res = parsed_result; 9423 struct rte_eth_syn_filter syn_filter; 9424 int ret = 0; 9425 9426 ret = rte_eth_dev_filter_supported(res->port_id, 9427 RTE_ETH_FILTER_SYN); 9428 if (ret < 0) { 9429 printf("syn filter is not supported on port %u.\n", 9430 res->port_id); 9431 return; 9432 } 9433 9434 memset(&syn_filter, 0, sizeof(syn_filter)); 9435 9436 if (!strcmp(res->ops, "add")) { 9437 if (!strcmp(res->high, "high")) 9438 syn_filter.hig_pri = 1; 9439 else 9440 syn_filter.hig_pri = 0; 9441 9442 syn_filter.queue = res->queue_id; 9443 ret = rte_eth_dev_filter_ctrl(res->port_id, 9444 RTE_ETH_FILTER_SYN, 9445 RTE_ETH_FILTER_ADD, 9446 &syn_filter); 9447 } else 9448 ret = rte_eth_dev_filter_ctrl(res->port_id, 9449 RTE_ETH_FILTER_SYN, 9450 RTE_ETH_FILTER_DELETE, 9451 &syn_filter); 9452 9453 if (ret < 0) 9454 printf("syn filter programming error: (%s)\n", 9455 strerror(-ret)); 9456 } 9457 9458 cmdline_parse_token_string_t cmd_syn_filter_filter = 9459 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9460 filter, "syn_filter"); 9461 cmdline_parse_token_num_t cmd_syn_filter_port_id = 9462 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 9463 port_id, UINT16); 9464 cmdline_parse_token_string_t cmd_syn_filter_ops = 9465 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9466 ops, "add#del"); 9467 cmdline_parse_token_string_t cmd_syn_filter_priority = 9468 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9469 priority, "priority"); 9470 cmdline_parse_token_string_t cmd_syn_filter_high = 9471 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9472 high, "high#low"); 9473 cmdline_parse_token_string_t cmd_syn_filter_queue = 9474 TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, 9475 queue, "queue"); 9476 cmdline_parse_token_num_t cmd_syn_filter_queue_id = 9477 TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, 9478 queue_id, UINT16); 9479 9480 cmdline_parse_inst_t cmd_syn_filter = { 9481 .f = cmd_syn_filter_parsed, 9482 .data = NULL, 9483 .help_str = "syn_filter <port_id> add|del priority high|low queue " 9484 "<queue_id>: Add/Delete syn filter", 9485 .tokens = { 9486 (void *)&cmd_syn_filter_filter, 9487 (void *)&cmd_syn_filter_port_id, 9488 (void *)&cmd_syn_filter_ops, 9489 (void *)&cmd_syn_filter_priority, 9490 (void *)&cmd_syn_filter_high, 9491 (void *)&cmd_syn_filter_queue, 9492 (void *)&cmd_syn_filter_queue_id, 9493 NULL, 9494 }, 9495 }; 9496 9497 /* *** queue region set *** */ 9498 struct cmd_queue_region_result { 9499 cmdline_fixed_string_t set; 9500 cmdline_fixed_string_t port; 9501 portid_t port_id; 9502 cmdline_fixed_string_t cmd; 9503 cmdline_fixed_string_t region; 9504 uint8_t region_id; 9505 cmdline_fixed_string_t queue_start_index; 9506 uint8_t queue_id; 9507 cmdline_fixed_string_t queue_num; 9508 uint8_t queue_num_value; 9509 }; 9510 9511 static void 9512 cmd_queue_region_parsed(void *parsed_result, 9513 __attribute__((unused)) struct cmdline *cl, 9514 __attribute__((unused)) void *data) 9515 { 9516 struct cmd_queue_region_result *res = parsed_result; 9517 int ret = -ENOTSUP; 9518 #ifdef RTE_LIBRTE_I40E_PMD 9519 struct rte_pmd_i40e_queue_region_conf region_conf; 9520 enum rte_pmd_i40e_queue_region_op op_type; 9521 #endif 9522 9523 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9524 return; 9525 9526 #ifdef RTE_LIBRTE_I40E_PMD 9527 memset(®ion_conf, 0, sizeof(region_conf)); 9528 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_SET; 9529 region_conf.region_id = res->region_id; 9530 region_conf.queue_num = res->queue_num_value; 9531 region_conf.queue_start_index = res->queue_id; 9532 9533 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9534 op_type, ®ion_conf); 9535 #endif 9536 9537 switch (ret) { 9538 case 0: 9539 break; 9540 case -ENOTSUP: 9541 printf("function not implemented or supported\n"); 9542 break; 9543 default: 9544 printf("queue region config error: (%s)\n", strerror(-ret)); 9545 } 9546 } 9547 9548 cmdline_parse_token_string_t cmd_queue_region_set = 9549 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9550 set, "set"); 9551 cmdline_parse_token_string_t cmd_queue_region_port = 9552 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, port, "port"); 9553 cmdline_parse_token_num_t cmd_queue_region_port_id = 9554 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9555 port_id, UINT16); 9556 cmdline_parse_token_string_t cmd_queue_region_cmd = 9557 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9558 cmd, "queue-region"); 9559 cmdline_parse_token_string_t cmd_queue_region_id = 9560 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9561 region, "region_id"); 9562 cmdline_parse_token_num_t cmd_queue_region_index = 9563 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9564 region_id, UINT8); 9565 cmdline_parse_token_string_t cmd_queue_region_queue_start_index = 9566 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9567 queue_start_index, "queue_start_index"); 9568 cmdline_parse_token_num_t cmd_queue_region_queue_id = 9569 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9570 queue_id, UINT8); 9571 cmdline_parse_token_string_t cmd_queue_region_queue_num = 9572 TOKEN_STRING_INITIALIZER(struct cmd_queue_region_result, 9573 queue_num, "queue_num"); 9574 cmdline_parse_token_num_t cmd_queue_region_queue_num_value = 9575 TOKEN_NUM_INITIALIZER(struct cmd_queue_region_result, 9576 queue_num_value, UINT8); 9577 9578 cmdline_parse_inst_t cmd_queue_region = { 9579 .f = cmd_queue_region_parsed, 9580 .data = NULL, 9581 .help_str = "set port <port_id> queue-region region_id <value> " 9582 "queue_start_index <value> queue_num <value>: Set a queue region", 9583 .tokens = { 9584 (void *)&cmd_queue_region_set, 9585 (void *)&cmd_queue_region_port, 9586 (void *)&cmd_queue_region_port_id, 9587 (void *)&cmd_queue_region_cmd, 9588 (void *)&cmd_queue_region_id, 9589 (void *)&cmd_queue_region_index, 9590 (void *)&cmd_queue_region_queue_start_index, 9591 (void *)&cmd_queue_region_queue_id, 9592 (void *)&cmd_queue_region_queue_num, 9593 (void *)&cmd_queue_region_queue_num_value, 9594 NULL, 9595 }, 9596 }; 9597 9598 /* *** queue region and flowtype set *** */ 9599 struct cmd_region_flowtype_result { 9600 cmdline_fixed_string_t set; 9601 cmdline_fixed_string_t port; 9602 portid_t port_id; 9603 cmdline_fixed_string_t cmd; 9604 cmdline_fixed_string_t region; 9605 uint8_t region_id; 9606 cmdline_fixed_string_t flowtype; 9607 uint8_t flowtype_id; 9608 }; 9609 9610 static void 9611 cmd_region_flowtype_parsed(void *parsed_result, 9612 __attribute__((unused)) struct cmdline *cl, 9613 __attribute__((unused)) void *data) 9614 { 9615 struct cmd_region_flowtype_result *res = parsed_result; 9616 int ret = -ENOTSUP; 9617 #ifdef RTE_LIBRTE_I40E_PMD 9618 struct rte_pmd_i40e_queue_region_conf region_conf; 9619 enum rte_pmd_i40e_queue_region_op op_type; 9620 #endif 9621 9622 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9623 return; 9624 9625 #ifdef RTE_LIBRTE_I40E_PMD 9626 memset(®ion_conf, 0, sizeof(region_conf)); 9627 9628 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET; 9629 region_conf.region_id = res->region_id; 9630 region_conf.hw_flowtype = res->flowtype_id; 9631 9632 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9633 op_type, ®ion_conf); 9634 #endif 9635 9636 switch (ret) { 9637 case 0: 9638 break; 9639 case -ENOTSUP: 9640 printf("function not implemented or supported\n"); 9641 break; 9642 default: 9643 printf("region flowtype config error: (%s)\n", strerror(-ret)); 9644 } 9645 } 9646 9647 cmdline_parse_token_string_t cmd_region_flowtype_set = 9648 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9649 set, "set"); 9650 cmdline_parse_token_string_t cmd_region_flowtype_port = 9651 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9652 port, "port"); 9653 cmdline_parse_token_num_t cmd_region_flowtype_port_index = 9654 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9655 port_id, UINT16); 9656 cmdline_parse_token_string_t cmd_region_flowtype_cmd = 9657 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9658 cmd, "queue-region"); 9659 cmdline_parse_token_string_t cmd_region_flowtype_index = 9660 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9661 region, "region_id"); 9662 cmdline_parse_token_num_t cmd_region_flowtype_id = 9663 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9664 region_id, UINT8); 9665 cmdline_parse_token_string_t cmd_region_flowtype_flow_index = 9666 TOKEN_STRING_INITIALIZER(struct cmd_region_flowtype_result, 9667 flowtype, "flowtype"); 9668 cmdline_parse_token_num_t cmd_region_flowtype_flow_id = 9669 TOKEN_NUM_INITIALIZER(struct cmd_region_flowtype_result, 9670 flowtype_id, UINT8); 9671 cmdline_parse_inst_t cmd_region_flowtype = { 9672 .f = cmd_region_flowtype_parsed, 9673 .data = NULL, 9674 .help_str = "set port <port_id> queue-region region_id <value> " 9675 "flowtype <value>: Set a flowtype region index", 9676 .tokens = { 9677 (void *)&cmd_region_flowtype_set, 9678 (void *)&cmd_region_flowtype_port, 9679 (void *)&cmd_region_flowtype_port_index, 9680 (void *)&cmd_region_flowtype_cmd, 9681 (void *)&cmd_region_flowtype_index, 9682 (void *)&cmd_region_flowtype_id, 9683 (void *)&cmd_region_flowtype_flow_index, 9684 (void *)&cmd_region_flowtype_flow_id, 9685 NULL, 9686 }, 9687 }; 9688 9689 /* *** User Priority (UP) to queue region (region_id) set *** */ 9690 struct cmd_user_priority_region_result { 9691 cmdline_fixed_string_t set; 9692 cmdline_fixed_string_t port; 9693 portid_t port_id; 9694 cmdline_fixed_string_t cmd; 9695 cmdline_fixed_string_t user_priority; 9696 uint8_t user_priority_id; 9697 cmdline_fixed_string_t region; 9698 uint8_t region_id; 9699 }; 9700 9701 static void 9702 cmd_user_priority_region_parsed(void *parsed_result, 9703 __attribute__((unused)) struct cmdline *cl, 9704 __attribute__((unused)) void *data) 9705 { 9706 struct cmd_user_priority_region_result *res = parsed_result; 9707 int ret = -ENOTSUP; 9708 #ifdef RTE_LIBRTE_I40E_PMD 9709 struct rte_pmd_i40e_queue_region_conf region_conf; 9710 enum rte_pmd_i40e_queue_region_op op_type; 9711 #endif 9712 9713 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9714 return; 9715 9716 #ifdef RTE_LIBRTE_I40E_PMD 9717 memset(®ion_conf, 0, sizeof(region_conf)); 9718 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET; 9719 region_conf.user_priority = res->user_priority_id; 9720 region_conf.region_id = res->region_id; 9721 9722 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9723 op_type, ®ion_conf); 9724 #endif 9725 9726 switch (ret) { 9727 case 0: 9728 break; 9729 case -ENOTSUP: 9730 printf("function not implemented or supported\n"); 9731 break; 9732 default: 9733 printf("user_priority region config error: (%s)\n", 9734 strerror(-ret)); 9735 } 9736 } 9737 9738 cmdline_parse_token_string_t cmd_user_priority_region_set = 9739 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9740 set, "set"); 9741 cmdline_parse_token_string_t cmd_user_priority_region_port = 9742 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9743 port, "port"); 9744 cmdline_parse_token_num_t cmd_user_priority_region_port_index = 9745 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9746 port_id, UINT16); 9747 cmdline_parse_token_string_t cmd_user_priority_region_cmd = 9748 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9749 cmd, "queue-region"); 9750 cmdline_parse_token_string_t cmd_user_priority_region_UP = 9751 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9752 user_priority, "UP"); 9753 cmdline_parse_token_num_t cmd_user_priority_region_UP_id = 9754 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9755 user_priority_id, UINT8); 9756 cmdline_parse_token_string_t cmd_user_priority_region_region = 9757 TOKEN_STRING_INITIALIZER(struct cmd_user_priority_region_result, 9758 region, "region_id"); 9759 cmdline_parse_token_num_t cmd_user_priority_region_region_id = 9760 TOKEN_NUM_INITIALIZER(struct cmd_user_priority_region_result, 9761 region_id, UINT8); 9762 9763 cmdline_parse_inst_t cmd_user_priority_region = { 9764 .f = cmd_user_priority_region_parsed, 9765 .data = NULL, 9766 .help_str = "set port <port_id> queue-region UP <value> " 9767 "region_id <value>: Set the mapping of User Priority (UP) " 9768 "to queue region (region_id) ", 9769 .tokens = { 9770 (void *)&cmd_user_priority_region_set, 9771 (void *)&cmd_user_priority_region_port, 9772 (void *)&cmd_user_priority_region_port_index, 9773 (void *)&cmd_user_priority_region_cmd, 9774 (void *)&cmd_user_priority_region_UP, 9775 (void *)&cmd_user_priority_region_UP_id, 9776 (void *)&cmd_user_priority_region_region, 9777 (void *)&cmd_user_priority_region_region_id, 9778 NULL, 9779 }, 9780 }; 9781 9782 /* *** flush all queue region related configuration *** */ 9783 struct cmd_flush_queue_region_result { 9784 cmdline_fixed_string_t set; 9785 cmdline_fixed_string_t port; 9786 portid_t port_id; 9787 cmdline_fixed_string_t cmd; 9788 cmdline_fixed_string_t flush; 9789 cmdline_fixed_string_t what; 9790 }; 9791 9792 static void 9793 cmd_flush_queue_region_parsed(void *parsed_result, 9794 __attribute__((unused)) struct cmdline *cl, 9795 __attribute__((unused)) void *data) 9796 { 9797 struct cmd_flush_queue_region_result *res = parsed_result; 9798 int ret = -ENOTSUP; 9799 #ifdef RTE_LIBRTE_I40E_PMD 9800 struct rte_pmd_i40e_queue_region_conf region_conf; 9801 enum rte_pmd_i40e_queue_region_op op_type; 9802 #endif 9803 9804 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9805 return; 9806 9807 #ifdef RTE_LIBRTE_I40E_PMD 9808 memset(®ion_conf, 0, sizeof(region_conf)); 9809 9810 if (strcmp(res->what, "on") == 0) 9811 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON; 9812 else 9813 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF; 9814 9815 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9816 op_type, ®ion_conf); 9817 #endif 9818 9819 switch (ret) { 9820 case 0: 9821 break; 9822 case -ENOTSUP: 9823 printf("function not implemented or supported\n"); 9824 break; 9825 default: 9826 printf("queue region config flush error: (%s)\n", 9827 strerror(-ret)); 9828 } 9829 } 9830 9831 cmdline_parse_token_string_t cmd_flush_queue_region_set = 9832 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9833 set, "set"); 9834 cmdline_parse_token_string_t cmd_flush_queue_region_port = 9835 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9836 port, "port"); 9837 cmdline_parse_token_num_t cmd_flush_queue_region_port_index = 9838 TOKEN_NUM_INITIALIZER(struct cmd_flush_queue_region_result, 9839 port_id, UINT16); 9840 cmdline_parse_token_string_t cmd_flush_queue_region_cmd = 9841 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9842 cmd, "queue-region"); 9843 cmdline_parse_token_string_t cmd_flush_queue_region_flush = 9844 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9845 flush, "flush"); 9846 cmdline_parse_token_string_t cmd_flush_queue_region_what = 9847 TOKEN_STRING_INITIALIZER(struct cmd_flush_queue_region_result, 9848 what, "on#off"); 9849 9850 cmdline_parse_inst_t cmd_flush_queue_region = { 9851 .f = cmd_flush_queue_region_parsed, 9852 .data = NULL, 9853 .help_str = "set port <port_id> queue-region flush on|off" 9854 ": flush all queue region related configuration", 9855 .tokens = { 9856 (void *)&cmd_flush_queue_region_set, 9857 (void *)&cmd_flush_queue_region_port, 9858 (void *)&cmd_flush_queue_region_port_index, 9859 (void *)&cmd_flush_queue_region_cmd, 9860 (void *)&cmd_flush_queue_region_flush, 9861 (void *)&cmd_flush_queue_region_what, 9862 NULL, 9863 }, 9864 }; 9865 9866 /* *** get all queue region related configuration info *** */ 9867 struct cmd_show_queue_region_info { 9868 cmdline_fixed_string_t show; 9869 cmdline_fixed_string_t port; 9870 portid_t port_id; 9871 cmdline_fixed_string_t cmd; 9872 }; 9873 9874 static void 9875 cmd_show_queue_region_info_parsed(void *parsed_result, 9876 __attribute__((unused)) struct cmdline *cl, 9877 __attribute__((unused)) void *data) 9878 { 9879 struct cmd_show_queue_region_info *res = parsed_result; 9880 int ret = -ENOTSUP; 9881 #ifdef RTE_LIBRTE_I40E_PMD 9882 struct rte_pmd_i40e_queue_regions rte_pmd_regions; 9883 enum rte_pmd_i40e_queue_region_op op_type; 9884 #endif 9885 9886 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 9887 return; 9888 9889 #ifdef RTE_LIBRTE_I40E_PMD 9890 memset(&rte_pmd_regions, 0, sizeof(rte_pmd_regions)); 9891 9892 op_type = RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET; 9893 9894 ret = rte_pmd_i40e_rss_queue_region_conf(res->port_id, 9895 op_type, &rte_pmd_regions); 9896 9897 port_queue_region_info_display(res->port_id, &rte_pmd_regions); 9898 #endif 9899 9900 switch (ret) { 9901 case 0: 9902 break; 9903 case -ENOTSUP: 9904 printf("function not implemented or supported\n"); 9905 break; 9906 default: 9907 printf("queue region config info show error: (%s)\n", 9908 strerror(-ret)); 9909 } 9910 } 9911 9912 cmdline_parse_token_string_t cmd_show_queue_region_info_get = 9913 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9914 show, "show"); 9915 cmdline_parse_token_string_t cmd_show_queue_region_info_port = 9916 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9917 port, "port"); 9918 cmdline_parse_token_num_t cmd_show_queue_region_info_port_index = 9919 TOKEN_NUM_INITIALIZER(struct cmd_show_queue_region_info, 9920 port_id, UINT16); 9921 cmdline_parse_token_string_t cmd_show_queue_region_info_cmd = 9922 TOKEN_STRING_INITIALIZER(struct cmd_show_queue_region_info, 9923 cmd, "queue-region"); 9924 9925 cmdline_parse_inst_t cmd_show_queue_region_info_all = { 9926 .f = cmd_show_queue_region_info_parsed, 9927 .data = NULL, 9928 .help_str = "show port <port_id> queue-region" 9929 ": show all queue region related configuration info", 9930 .tokens = { 9931 (void *)&cmd_show_queue_region_info_get, 9932 (void *)&cmd_show_queue_region_info_port, 9933 (void *)&cmd_show_queue_region_info_port_index, 9934 (void *)&cmd_show_queue_region_info_cmd, 9935 NULL, 9936 }, 9937 }; 9938 9939 /* *** ADD/REMOVE A 2tuple FILTER *** */ 9940 struct cmd_2tuple_filter_result { 9941 cmdline_fixed_string_t filter; 9942 portid_t port_id; 9943 cmdline_fixed_string_t ops; 9944 cmdline_fixed_string_t dst_port; 9945 uint16_t dst_port_value; 9946 cmdline_fixed_string_t protocol; 9947 uint8_t protocol_value; 9948 cmdline_fixed_string_t mask; 9949 uint8_t mask_value; 9950 cmdline_fixed_string_t tcp_flags; 9951 uint8_t tcp_flags_value; 9952 cmdline_fixed_string_t priority; 9953 uint8_t priority_value; 9954 cmdline_fixed_string_t queue; 9955 uint16_t queue_id; 9956 }; 9957 9958 static void 9959 cmd_2tuple_filter_parsed(void *parsed_result, 9960 __attribute__((unused)) struct cmdline *cl, 9961 __attribute__((unused)) void *data) 9962 { 9963 struct rte_eth_ntuple_filter filter; 9964 struct cmd_2tuple_filter_result *res = parsed_result; 9965 int ret = 0; 9966 9967 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 9968 if (ret < 0) { 9969 printf("ntuple filter is not supported on port %u.\n", 9970 res->port_id); 9971 return; 9972 } 9973 9974 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 9975 9976 filter.flags = RTE_2TUPLE_FLAGS; 9977 filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 9978 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 9979 filter.proto = res->protocol_value; 9980 filter.priority = res->priority_value; 9981 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 9982 printf("nonzero tcp_flags is only meaningful" 9983 " when protocol is TCP.\n"); 9984 return; 9985 } 9986 if (res->tcp_flags_value > TCP_FLAG_ALL) { 9987 printf("invalid TCP flags.\n"); 9988 return; 9989 } 9990 9991 if (res->tcp_flags_value != 0) { 9992 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 9993 filter.tcp_flags = res->tcp_flags_value; 9994 } 9995 9996 /* need convert to big endian. */ 9997 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 9998 filter.queue = res->queue_id; 9999 10000 if (!strcmp(res->ops, "add")) 10001 ret = rte_eth_dev_filter_ctrl(res->port_id, 10002 RTE_ETH_FILTER_NTUPLE, 10003 RTE_ETH_FILTER_ADD, 10004 &filter); 10005 else 10006 ret = rte_eth_dev_filter_ctrl(res->port_id, 10007 RTE_ETH_FILTER_NTUPLE, 10008 RTE_ETH_FILTER_DELETE, 10009 &filter); 10010 if (ret < 0) 10011 printf("2tuple filter programming error: (%s)\n", 10012 strerror(-ret)); 10013 10014 } 10015 10016 cmdline_parse_token_string_t cmd_2tuple_filter_filter = 10017 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10018 filter, "2tuple_filter"); 10019 cmdline_parse_token_num_t cmd_2tuple_filter_port_id = 10020 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10021 port_id, UINT16); 10022 cmdline_parse_token_string_t cmd_2tuple_filter_ops = 10023 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10024 ops, "add#del"); 10025 cmdline_parse_token_string_t cmd_2tuple_filter_dst_port = 10026 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10027 dst_port, "dst_port"); 10028 cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value = 10029 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10030 dst_port_value, UINT16); 10031 cmdline_parse_token_string_t cmd_2tuple_filter_protocol = 10032 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10033 protocol, "protocol"); 10034 cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value = 10035 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10036 protocol_value, UINT8); 10037 cmdline_parse_token_string_t cmd_2tuple_filter_mask = 10038 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10039 mask, "mask"); 10040 cmdline_parse_token_num_t cmd_2tuple_filter_mask_value = 10041 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10042 mask_value, INT8); 10043 cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags = 10044 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10045 tcp_flags, "tcp_flags"); 10046 cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value = 10047 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10048 tcp_flags_value, UINT8); 10049 cmdline_parse_token_string_t cmd_2tuple_filter_priority = 10050 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10051 priority, "priority"); 10052 cmdline_parse_token_num_t cmd_2tuple_filter_priority_value = 10053 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10054 priority_value, UINT8); 10055 cmdline_parse_token_string_t cmd_2tuple_filter_queue = 10056 TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, 10057 queue, "queue"); 10058 cmdline_parse_token_num_t cmd_2tuple_filter_queue_id = 10059 TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, 10060 queue_id, UINT16); 10061 10062 cmdline_parse_inst_t cmd_2tuple_filter = { 10063 .f = cmd_2tuple_filter_parsed, 10064 .data = NULL, 10065 .help_str = "2tuple_filter <port_id> add|del dst_port <value> protocol " 10066 "<value> mask <value> tcp_flags <value> priority <value> queue " 10067 "<queue_id>: Add a 2tuple filter", 10068 .tokens = { 10069 (void *)&cmd_2tuple_filter_filter, 10070 (void *)&cmd_2tuple_filter_port_id, 10071 (void *)&cmd_2tuple_filter_ops, 10072 (void *)&cmd_2tuple_filter_dst_port, 10073 (void *)&cmd_2tuple_filter_dst_port_value, 10074 (void *)&cmd_2tuple_filter_protocol, 10075 (void *)&cmd_2tuple_filter_protocol_value, 10076 (void *)&cmd_2tuple_filter_mask, 10077 (void *)&cmd_2tuple_filter_mask_value, 10078 (void *)&cmd_2tuple_filter_tcp_flags, 10079 (void *)&cmd_2tuple_filter_tcp_flags_value, 10080 (void *)&cmd_2tuple_filter_priority, 10081 (void *)&cmd_2tuple_filter_priority_value, 10082 (void *)&cmd_2tuple_filter_queue, 10083 (void *)&cmd_2tuple_filter_queue_id, 10084 NULL, 10085 }, 10086 }; 10087 10088 /* *** ADD/REMOVE A 5tuple FILTER *** */ 10089 struct cmd_5tuple_filter_result { 10090 cmdline_fixed_string_t filter; 10091 portid_t port_id; 10092 cmdline_fixed_string_t ops; 10093 cmdline_fixed_string_t dst_ip; 10094 cmdline_ipaddr_t dst_ip_value; 10095 cmdline_fixed_string_t src_ip; 10096 cmdline_ipaddr_t src_ip_value; 10097 cmdline_fixed_string_t dst_port; 10098 uint16_t dst_port_value; 10099 cmdline_fixed_string_t src_port; 10100 uint16_t src_port_value; 10101 cmdline_fixed_string_t protocol; 10102 uint8_t protocol_value; 10103 cmdline_fixed_string_t mask; 10104 uint8_t mask_value; 10105 cmdline_fixed_string_t tcp_flags; 10106 uint8_t tcp_flags_value; 10107 cmdline_fixed_string_t priority; 10108 uint8_t priority_value; 10109 cmdline_fixed_string_t queue; 10110 uint16_t queue_id; 10111 }; 10112 10113 static void 10114 cmd_5tuple_filter_parsed(void *parsed_result, 10115 __attribute__((unused)) struct cmdline *cl, 10116 __attribute__((unused)) void *data) 10117 { 10118 struct rte_eth_ntuple_filter filter; 10119 struct cmd_5tuple_filter_result *res = parsed_result; 10120 int ret = 0; 10121 10122 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); 10123 if (ret < 0) { 10124 printf("ntuple filter is not supported on port %u.\n", 10125 res->port_id); 10126 return; 10127 } 10128 10129 memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); 10130 10131 filter.flags = RTE_5TUPLE_FLAGS; 10132 filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0; 10133 filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0; 10134 filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0; 10135 filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; 10136 filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; 10137 filter.proto = res->protocol_value; 10138 filter.priority = res->priority_value; 10139 if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { 10140 printf("nonzero tcp_flags is only meaningful" 10141 " when protocol is TCP.\n"); 10142 return; 10143 } 10144 if (res->tcp_flags_value > TCP_FLAG_ALL) { 10145 printf("invalid TCP flags.\n"); 10146 return; 10147 } 10148 10149 if (res->tcp_flags_value != 0) { 10150 filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; 10151 filter.tcp_flags = res->tcp_flags_value; 10152 } 10153 10154 if (res->dst_ip_value.family == AF_INET) 10155 /* no need to convert, already big endian. */ 10156 filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr; 10157 else { 10158 if (filter.dst_ip_mask == 0) { 10159 printf("can not support ipv6 involved compare.\n"); 10160 return; 10161 } 10162 filter.dst_ip = 0; 10163 } 10164 10165 if (res->src_ip_value.family == AF_INET) 10166 /* no need to convert, already big endian. */ 10167 filter.src_ip = res->src_ip_value.addr.ipv4.s_addr; 10168 else { 10169 if (filter.src_ip_mask == 0) { 10170 printf("can not support ipv6 involved compare.\n"); 10171 return; 10172 } 10173 filter.src_ip = 0; 10174 } 10175 /* need convert to big endian. */ 10176 filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); 10177 filter.src_port = rte_cpu_to_be_16(res->src_port_value); 10178 filter.queue = res->queue_id; 10179 10180 if (!strcmp(res->ops, "add")) 10181 ret = rte_eth_dev_filter_ctrl(res->port_id, 10182 RTE_ETH_FILTER_NTUPLE, 10183 RTE_ETH_FILTER_ADD, 10184 &filter); 10185 else 10186 ret = rte_eth_dev_filter_ctrl(res->port_id, 10187 RTE_ETH_FILTER_NTUPLE, 10188 RTE_ETH_FILTER_DELETE, 10189 &filter); 10190 if (ret < 0) 10191 printf("5tuple filter programming error: (%s)\n", 10192 strerror(-ret)); 10193 } 10194 10195 cmdline_parse_token_string_t cmd_5tuple_filter_filter = 10196 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10197 filter, "5tuple_filter"); 10198 cmdline_parse_token_num_t cmd_5tuple_filter_port_id = 10199 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10200 port_id, UINT16); 10201 cmdline_parse_token_string_t cmd_5tuple_filter_ops = 10202 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10203 ops, "add#del"); 10204 cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip = 10205 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10206 dst_ip, "dst_ip"); 10207 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_dst_ip_value = 10208 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 10209 dst_ip_value); 10210 cmdline_parse_token_string_t cmd_5tuple_filter_src_ip = 10211 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10212 src_ip, "src_ip"); 10213 cmdline_parse_token_ipaddr_t cmd_5tuple_filter_src_ip_value = 10214 TOKEN_IPADDR_INITIALIZER(struct cmd_5tuple_filter_result, 10215 src_ip_value); 10216 cmdline_parse_token_string_t cmd_5tuple_filter_dst_port = 10217 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10218 dst_port, "dst_port"); 10219 cmdline_parse_token_num_t cmd_5tuple_filter_dst_port_value = 10220 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10221 dst_port_value, UINT16); 10222 cmdline_parse_token_string_t cmd_5tuple_filter_src_port = 10223 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10224 src_port, "src_port"); 10225 cmdline_parse_token_num_t cmd_5tuple_filter_src_port_value = 10226 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10227 src_port_value, UINT16); 10228 cmdline_parse_token_string_t cmd_5tuple_filter_protocol = 10229 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10230 protocol, "protocol"); 10231 cmdline_parse_token_num_t cmd_5tuple_filter_protocol_value = 10232 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10233 protocol_value, UINT8); 10234 cmdline_parse_token_string_t cmd_5tuple_filter_mask = 10235 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10236 mask, "mask"); 10237 cmdline_parse_token_num_t cmd_5tuple_filter_mask_value = 10238 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10239 mask_value, INT8); 10240 cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags = 10241 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10242 tcp_flags, "tcp_flags"); 10243 cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value = 10244 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10245 tcp_flags_value, UINT8); 10246 cmdline_parse_token_string_t cmd_5tuple_filter_priority = 10247 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10248 priority, "priority"); 10249 cmdline_parse_token_num_t cmd_5tuple_filter_priority_value = 10250 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10251 priority_value, UINT8); 10252 cmdline_parse_token_string_t cmd_5tuple_filter_queue = 10253 TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, 10254 queue, "queue"); 10255 cmdline_parse_token_num_t cmd_5tuple_filter_queue_id = 10256 TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, 10257 queue_id, UINT16); 10258 10259 cmdline_parse_inst_t cmd_5tuple_filter = { 10260 .f = cmd_5tuple_filter_parsed, 10261 .data = NULL, 10262 .help_str = "5tuple_filter <port_id> add|del dst_ip <value> " 10263 "src_ip <value> dst_port <value> src_port <value> " 10264 "protocol <value> mask <value> tcp_flags <value> " 10265 "priority <value> queue <queue_id>: Add/Del a 5tuple filter", 10266 .tokens = { 10267 (void *)&cmd_5tuple_filter_filter, 10268 (void *)&cmd_5tuple_filter_port_id, 10269 (void *)&cmd_5tuple_filter_ops, 10270 (void *)&cmd_5tuple_filter_dst_ip, 10271 (void *)&cmd_5tuple_filter_dst_ip_value, 10272 (void *)&cmd_5tuple_filter_src_ip, 10273 (void *)&cmd_5tuple_filter_src_ip_value, 10274 (void *)&cmd_5tuple_filter_dst_port, 10275 (void *)&cmd_5tuple_filter_dst_port_value, 10276 (void *)&cmd_5tuple_filter_src_port, 10277 (void *)&cmd_5tuple_filter_src_port_value, 10278 (void *)&cmd_5tuple_filter_protocol, 10279 (void *)&cmd_5tuple_filter_protocol_value, 10280 (void *)&cmd_5tuple_filter_mask, 10281 (void *)&cmd_5tuple_filter_mask_value, 10282 (void *)&cmd_5tuple_filter_tcp_flags, 10283 (void *)&cmd_5tuple_filter_tcp_flags_value, 10284 (void *)&cmd_5tuple_filter_priority, 10285 (void *)&cmd_5tuple_filter_priority_value, 10286 (void *)&cmd_5tuple_filter_queue, 10287 (void *)&cmd_5tuple_filter_queue_id, 10288 NULL, 10289 }, 10290 }; 10291 10292 /* *** ADD/REMOVE A flex FILTER *** */ 10293 struct cmd_flex_filter_result { 10294 cmdline_fixed_string_t filter; 10295 cmdline_fixed_string_t ops; 10296 portid_t port_id; 10297 cmdline_fixed_string_t len; 10298 uint8_t len_value; 10299 cmdline_fixed_string_t bytes; 10300 cmdline_fixed_string_t bytes_value; 10301 cmdline_fixed_string_t mask; 10302 cmdline_fixed_string_t mask_value; 10303 cmdline_fixed_string_t priority; 10304 uint8_t priority_value; 10305 cmdline_fixed_string_t queue; 10306 uint16_t queue_id; 10307 }; 10308 10309 static int xdigit2val(unsigned char c) 10310 { 10311 int val; 10312 if (isdigit(c)) 10313 val = c - '0'; 10314 else if (isupper(c)) 10315 val = c - 'A' + 10; 10316 else 10317 val = c - 'a' + 10; 10318 return val; 10319 } 10320 10321 static void 10322 cmd_flex_filter_parsed(void *parsed_result, 10323 __attribute__((unused)) struct cmdline *cl, 10324 __attribute__((unused)) void *data) 10325 { 10326 int ret = 0; 10327 struct rte_eth_flex_filter filter; 10328 struct cmd_flex_filter_result *res = parsed_result; 10329 char *bytes_ptr, *mask_ptr; 10330 uint16_t len, i, j = 0; 10331 char c; 10332 int val; 10333 uint8_t byte = 0; 10334 10335 if (res->len_value > RTE_FLEX_FILTER_MAXLEN) { 10336 printf("the len exceed the max length 128\n"); 10337 return; 10338 } 10339 memset(&filter, 0, sizeof(struct rte_eth_flex_filter)); 10340 filter.len = res->len_value; 10341 filter.priority = res->priority_value; 10342 filter.queue = res->queue_id; 10343 bytes_ptr = res->bytes_value; 10344 mask_ptr = res->mask_value; 10345 10346 /* translate bytes string to array. */ 10347 if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') || 10348 (bytes_ptr[1] == 'X'))) 10349 bytes_ptr += 2; 10350 len = strnlen(bytes_ptr, res->len_value * 2); 10351 if (len == 0 || (len % 8 != 0)) { 10352 printf("please check len and bytes input\n"); 10353 return; 10354 } 10355 for (i = 0; i < len; i++) { 10356 c = bytes_ptr[i]; 10357 if (isxdigit(c) == 0) { 10358 /* invalid characters. */ 10359 printf("invalid input\n"); 10360 return; 10361 } 10362 val = xdigit2val(c); 10363 if (i % 2) { 10364 byte |= val; 10365 filter.bytes[j] = byte; 10366 printf("bytes[%d]:%02x ", j, filter.bytes[j]); 10367 j++; 10368 byte = 0; 10369 } else 10370 byte |= val << 4; 10371 } 10372 printf("\n"); 10373 /* translate mask string to uint8_t array. */ 10374 if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') || 10375 (mask_ptr[1] == 'X'))) 10376 mask_ptr += 2; 10377 len = strnlen(mask_ptr, (res->len_value + 3) / 4); 10378 if (len == 0) { 10379 printf("invalid input\n"); 10380 return; 10381 } 10382 j = 0; 10383 byte = 0; 10384 for (i = 0; i < len; i++) { 10385 c = mask_ptr[i]; 10386 if (isxdigit(c) == 0) { 10387 /* invalid characters. */ 10388 printf("invalid input\n"); 10389 return; 10390 } 10391 val = xdigit2val(c); 10392 if (i % 2) { 10393 byte |= val; 10394 filter.mask[j] = byte; 10395 printf("mask[%d]:%02x ", j, filter.mask[j]); 10396 j++; 10397 byte = 0; 10398 } else 10399 byte |= val << 4; 10400 } 10401 printf("\n"); 10402 10403 if (!strcmp(res->ops, "add")) 10404 ret = rte_eth_dev_filter_ctrl(res->port_id, 10405 RTE_ETH_FILTER_FLEXIBLE, 10406 RTE_ETH_FILTER_ADD, 10407 &filter); 10408 else 10409 ret = rte_eth_dev_filter_ctrl(res->port_id, 10410 RTE_ETH_FILTER_FLEXIBLE, 10411 RTE_ETH_FILTER_DELETE, 10412 &filter); 10413 10414 if (ret < 0) 10415 printf("flex filter setting error: (%s)\n", strerror(-ret)); 10416 } 10417 10418 cmdline_parse_token_string_t cmd_flex_filter_filter = 10419 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10420 filter, "flex_filter"); 10421 cmdline_parse_token_num_t cmd_flex_filter_port_id = 10422 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10423 port_id, UINT16); 10424 cmdline_parse_token_string_t cmd_flex_filter_ops = 10425 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10426 ops, "add#del"); 10427 cmdline_parse_token_string_t cmd_flex_filter_len = 10428 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10429 len, "len"); 10430 cmdline_parse_token_num_t cmd_flex_filter_len_value = 10431 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10432 len_value, UINT8); 10433 cmdline_parse_token_string_t cmd_flex_filter_bytes = 10434 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10435 bytes, "bytes"); 10436 cmdline_parse_token_string_t cmd_flex_filter_bytes_value = 10437 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10438 bytes_value, NULL); 10439 cmdline_parse_token_string_t cmd_flex_filter_mask = 10440 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10441 mask, "mask"); 10442 cmdline_parse_token_string_t cmd_flex_filter_mask_value = 10443 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10444 mask_value, NULL); 10445 cmdline_parse_token_string_t cmd_flex_filter_priority = 10446 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10447 priority, "priority"); 10448 cmdline_parse_token_num_t cmd_flex_filter_priority_value = 10449 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10450 priority_value, UINT8); 10451 cmdline_parse_token_string_t cmd_flex_filter_queue = 10452 TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, 10453 queue, "queue"); 10454 cmdline_parse_token_num_t cmd_flex_filter_queue_id = 10455 TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, 10456 queue_id, UINT16); 10457 cmdline_parse_inst_t cmd_flex_filter = { 10458 .f = cmd_flex_filter_parsed, 10459 .data = NULL, 10460 .help_str = "flex_filter <port_id> add|del len <value> bytes " 10461 "<value> mask <value> priority <value> queue <queue_id>: " 10462 "Add/Del a flex filter", 10463 .tokens = { 10464 (void *)&cmd_flex_filter_filter, 10465 (void *)&cmd_flex_filter_port_id, 10466 (void *)&cmd_flex_filter_ops, 10467 (void *)&cmd_flex_filter_len, 10468 (void *)&cmd_flex_filter_len_value, 10469 (void *)&cmd_flex_filter_bytes, 10470 (void *)&cmd_flex_filter_bytes_value, 10471 (void *)&cmd_flex_filter_mask, 10472 (void *)&cmd_flex_filter_mask_value, 10473 (void *)&cmd_flex_filter_priority, 10474 (void *)&cmd_flex_filter_priority_value, 10475 (void *)&cmd_flex_filter_queue, 10476 (void *)&cmd_flex_filter_queue_id, 10477 NULL, 10478 }, 10479 }; 10480 10481 /* *** Filters Control *** */ 10482 10483 /* *** deal with ethertype filter *** */ 10484 struct cmd_ethertype_filter_result { 10485 cmdline_fixed_string_t filter; 10486 portid_t port_id; 10487 cmdline_fixed_string_t ops; 10488 cmdline_fixed_string_t mac; 10489 struct ether_addr mac_addr; 10490 cmdline_fixed_string_t ethertype; 10491 uint16_t ethertype_value; 10492 cmdline_fixed_string_t drop; 10493 cmdline_fixed_string_t queue; 10494 uint16_t queue_id; 10495 }; 10496 10497 cmdline_parse_token_string_t cmd_ethertype_filter_filter = 10498 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10499 filter, "ethertype_filter"); 10500 cmdline_parse_token_num_t cmd_ethertype_filter_port_id = 10501 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10502 port_id, UINT16); 10503 cmdline_parse_token_string_t cmd_ethertype_filter_ops = 10504 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10505 ops, "add#del"); 10506 cmdline_parse_token_string_t cmd_ethertype_filter_mac = 10507 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10508 mac, "mac_addr#mac_ignr"); 10509 cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr = 10510 TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result, 10511 mac_addr); 10512 cmdline_parse_token_string_t cmd_ethertype_filter_ethertype = 10513 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10514 ethertype, "ethertype"); 10515 cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value = 10516 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10517 ethertype_value, UINT16); 10518 cmdline_parse_token_string_t cmd_ethertype_filter_drop = 10519 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10520 drop, "drop#fwd"); 10521 cmdline_parse_token_string_t cmd_ethertype_filter_queue = 10522 TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result, 10523 queue, "queue"); 10524 cmdline_parse_token_num_t cmd_ethertype_filter_queue_id = 10525 TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result, 10526 queue_id, UINT16); 10527 10528 static void 10529 cmd_ethertype_filter_parsed(void *parsed_result, 10530 __attribute__((unused)) struct cmdline *cl, 10531 __attribute__((unused)) void *data) 10532 { 10533 struct cmd_ethertype_filter_result *res = parsed_result; 10534 struct rte_eth_ethertype_filter filter; 10535 int ret = 0; 10536 10537 ret = rte_eth_dev_filter_supported(res->port_id, 10538 RTE_ETH_FILTER_ETHERTYPE); 10539 if (ret < 0) { 10540 printf("ethertype filter is not supported on port %u.\n", 10541 res->port_id); 10542 return; 10543 } 10544 10545 memset(&filter, 0, sizeof(filter)); 10546 if (!strcmp(res->mac, "mac_addr")) { 10547 filter.flags |= RTE_ETHTYPE_FLAGS_MAC; 10548 rte_memcpy(&filter.mac_addr, &res->mac_addr, 10549 sizeof(struct ether_addr)); 10550 } 10551 if (!strcmp(res->drop, "drop")) 10552 filter.flags |= RTE_ETHTYPE_FLAGS_DROP; 10553 filter.ether_type = res->ethertype_value; 10554 filter.queue = res->queue_id; 10555 10556 if (!strcmp(res->ops, "add")) 10557 ret = rte_eth_dev_filter_ctrl(res->port_id, 10558 RTE_ETH_FILTER_ETHERTYPE, 10559 RTE_ETH_FILTER_ADD, 10560 &filter); 10561 else 10562 ret = rte_eth_dev_filter_ctrl(res->port_id, 10563 RTE_ETH_FILTER_ETHERTYPE, 10564 RTE_ETH_FILTER_DELETE, 10565 &filter); 10566 if (ret < 0) 10567 printf("ethertype filter programming error: (%s)\n", 10568 strerror(-ret)); 10569 } 10570 10571 cmdline_parse_inst_t cmd_ethertype_filter = { 10572 .f = cmd_ethertype_filter_parsed, 10573 .data = NULL, 10574 .help_str = "ethertype_filter <port_id> add|del mac_addr|mac_ignr " 10575 "<mac_addr> ethertype <value> drop|fw queue <queue_id>: " 10576 "Add or delete an ethertype filter entry", 10577 .tokens = { 10578 (void *)&cmd_ethertype_filter_filter, 10579 (void *)&cmd_ethertype_filter_port_id, 10580 (void *)&cmd_ethertype_filter_ops, 10581 (void *)&cmd_ethertype_filter_mac, 10582 (void *)&cmd_ethertype_filter_mac_addr, 10583 (void *)&cmd_ethertype_filter_ethertype, 10584 (void *)&cmd_ethertype_filter_ethertype_value, 10585 (void *)&cmd_ethertype_filter_drop, 10586 (void *)&cmd_ethertype_filter_queue, 10587 (void *)&cmd_ethertype_filter_queue_id, 10588 NULL, 10589 }, 10590 }; 10591 10592 /* *** deal with flow director filter *** */ 10593 struct cmd_flow_director_result { 10594 cmdline_fixed_string_t flow_director_filter; 10595 portid_t port_id; 10596 cmdline_fixed_string_t mode; 10597 cmdline_fixed_string_t mode_value; 10598 cmdline_fixed_string_t ops; 10599 cmdline_fixed_string_t flow; 10600 cmdline_fixed_string_t flow_type; 10601 cmdline_fixed_string_t ether; 10602 uint16_t ether_type; 10603 cmdline_fixed_string_t src; 10604 cmdline_ipaddr_t ip_src; 10605 uint16_t port_src; 10606 cmdline_fixed_string_t dst; 10607 cmdline_ipaddr_t ip_dst; 10608 uint16_t port_dst; 10609 cmdline_fixed_string_t verify_tag; 10610 uint32_t verify_tag_value; 10611 cmdline_fixed_string_t tos; 10612 uint8_t tos_value; 10613 cmdline_fixed_string_t proto; 10614 uint8_t proto_value; 10615 cmdline_fixed_string_t ttl; 10616 uint8_t ttl_value; 10617 cmdline_fixed_string_t vlan; 10618 uint16_t vlan_value; 10619 cmdline_fixed_string_t flexbytes; 10620 cmdline_fixed_string_t flexbytes_value; 10621 cmdline_fixed_string_t pf_vf; 10622 cmdline_fixed_string_t drop; 10623 cmdline_fixed_string_t queue; 10624 uint16_t queue_id; 10625 cmdline_fixed_string_t fd_id; 10626 uint32_t fd_id_value; 10627 cmdline_fixed_string_t mac; 10628 struct ether_addr mac_addr; 10629 cmdline_fixed_string_t tunnel; 10630 cmdline_fixed_string_t tunnel_type; 10631 cmdline_fixed_string_t tunnel_id; 10632 uint32_t tunnel_id_value; 10633 cmdline_fixed_string_t packet; 10634 char filepath[]; 10635 }; 10636 10637 static inline int 10638 parse_flexbytes(const char *q_arg, uint8_t *flexbytes, uint16_t max_num) 10639 { 10640 char s[256]; 10641 const char *p, *p0 = q_arg; 10642 char *end; 10643 unsigned long int_fld; 10644 char *str_fld[max_num]; 10645 int i; 10646 unsigned size; 10647 int ret = -1; 10648 10649 p = strchr(p0, '('); 10650 if (p == NULL) 10651 return -1; 10652 ++p; 10653 p0 = strchr(p, ')'); 10654 if (p0 == NULL) 10655 return -1; 10656 10657 size = p0 - p; 10658 if (size >= sizeof(s)) 10659 return -1; 10660 10661 snprintf(s, sizeof(s), "%.*s", size, p); 10662 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 10663 if (ret < 0 || ret > max_num) 10664 return -1; 10665 for (i = 0; i < ret; i++) { 10666 errno = 0; 10667 int_fld = strtoul(str_fld[i], &end, 0); 10668 if (errno != 0 || *end != '\0' || int_fld > UINT8_MAX) 10669 return -1; 10670 flexbytes[i] = (uint8_t)int_fld; 10671 } 10672 return ret; 10673 } 10674 10675 static uint16_t 10676 str2flowtype(char *string) 10677 { 10678 uint8_t i = 0; 10679 static const struct { 10680 char str[32]; 10681 uint16_t type; 10682 } flowtype_str[] = { 10683 {"raw", RTE_ETH_FLOW_RAW}, 10684 {"ipv4", RTE_ETH_FLOW_IPV4}, 10685 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 10686 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 10687 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 10688 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 10689 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 10690 {"ipv6", RTE_ETH_FLOW_IPV6}, 10691 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 10692 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 10693 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 10694 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 10695 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 10696 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 10697 }; 10698 10699 for (i = 0; i < RTE_DIM(flowtype_str); i++) { 10700 if (!strcmp(flowtype_str[i].str, string)) 10701 return flowtype_str[i].type; 10702 } 10703 10704 if (isdigit(string[0]) && atoi(string) > 0 && atoi(string) < 64) 10705 return (uint16_t)atoi(string); 10706 10707 return RTE_ETH_FLOW_UNKNOWN; 10708 } 10709 10710 static enum rte_eth_fdir_tunnel_type 10711 str2fdir_tunneltype(char *string) 10712 { 10713 uint8_t i = 0; 10714 10715 static const struct { 10716 char str[32]; 10717 enum rte_eth_fdir_tunnel_type type; 10718 } tunneltype_str[] = { 10719 {"NVGRE", RTE_FDIR_TUNNEL_TYPE_NVGRE}, 10720 {"VxLAN", RTE_FDIR_TUNNEL_TYPE_VXLAN}, 10721 }; 10722 10723 for (i = 0; i < RTE_DIM(tunneltype_str); i++) { 10724 if (!strcmp(tunneltype_str[i].str, string)) 10725 return tunneltype_str[i].type; 10726 } 10727 return RTE_FDIR_TUNNEL_TYPE_UNKNOWN; 10728 } 10729 10730 #define IPV4_ADDR_TO_UINT(ip_addr, ip) \ 10731 do { \ 10732 if ((ip_addr).family == AF_INET) \ 10733 (ip) = (ip_addr).addr.ipv4.s_addr; \ 10734 else { \ 10735 printf("invalid parameter.\n"); \ 10736 return; \ 10737 } \ 10738 } while (0) 10739 10740 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \ 10741 do { \ 10742 if ((ip_addr).family == AF_INET6) \ 10743 rte_memcpy(&(ip), \ 10744 &((ip_addr).addr.ipv6), \ 10745 sizeof(struct in6_addr)); \ 10746 else { \ 10747 printf("invalid parameter.\n"); \ 10748 return; \ 10749 } \ 10750 } while (0) 10751 10752 static void 10753 cmd_flow_director_filter_parsed(void *parsed_result, 10754 __attribute__((unused)) struct cmdline *cl, 10755 __attribute__((unused)) void *data) 10756 { 10757 struct cmd_flow_director_result *res = parsed_result; 10758 struct rte_eth_fdir_filter entry; 10759 uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN]; 10760 char *end; 10761 unsigned long vf_id; 10762 int ret = 0; 10763 10764 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 10765 if (ret < 0) { 10766 printf("flow director is not supported on port %u.\n", 10767 res->port_id); 10768 return; 10769 } 10770 memset(flexbytes, 0, sizeof(flexbytes)); 10771 memset(&entry, 0, sizeof(struct rte_eth_fdir_filter)); 10772 10773 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 10774 if (strcmp(res->mode_value, "MAC-VLAN")) { 10775 printf("Please set mode to MAC-VLAN.\n"); 10776 return; 10777 } 10778 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10779 if (strcmp(res->mode_value, "Tunnel")) { 10780 printf("Please set mode to Tunnel.\n"); 10781 return; 10782 } 10783 } else { 10784 if (!strcmp(res->mode_value, "raw")) { 10785 #ifdef RTE_LIBRTE_I40E_PMD 10786 struct rte_pmd_i40e_flow_type_mapping 10787 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 10788 struct rte_pmd_i40e_pkt_template_conf conf; 10789 uint16_t flow_type = str2flowtype(res->flow_type); 10790 uint16_t i, port = res->port_id; 10791 uint8_t add; 10792 10793 memset(&conf, 0, sizeof(conf)); 10794 10795 if (flow_type == RTE_ETH_FLOW_UNKNOWN) { 10796 printf("Invalid flow type specified.\n"); 10797 return; 10798 } 10799 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, 10800 mapping); 10801 if (ret) 10802 return; 10803 if (mapping[flow_type].pctype == 0ULL) { 10804 printf("Invalid flow type specified.\n"); 10805 return; 10806 } 10807 for (i = 0; i < RTE_PMD_I40E_PCTYPE_MAX; i++) { 10808 if (mapping[flow_type].pctype & (1ULL << i)) { 10809 conf.input.pctype = i; 10810 break; 10811 } 10812 } 10813 10814 conf.input.packet = open_file(res->filepath, 10815 &conf.input.length); 10816 if (!conf.input.packet) 10817 return; 10818 if (!strcmp(res->drop, "drop")) 10819 conf.action.behavior = 10820 RTE_PMD_I40E_PKT_TEMPLATE_REJECT; 10821 else 10822 conf.action.behavior = 10823 RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT; 10824 conf.action.report_status = 10825 RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID; 10826 conf.action.rx_queue = res->queue_id; 10827 conf.soft_id = res->fd_id_value; 10828 add = strcmp(res->ops, "del") ? 1 : 0; 10829 ret = rte_pmd_i40e_flow_add_del_packet_template(port, 10830 &conf, 10831 add); 10832 if (ret < 0) 10833 printf("flow director config error: (%s)\n", 10834 strerror(-ret)); 10835 close_file(conf.input.packet); 10836 #endif 10837 return; 10838 } else if (strcmp(res->mode_value, "IP")) { 10839 printf("Please set mode to IP or raw.\n"); 10840 return; 10841 } 10842 entry.input.flow_type = str2flowtype(res->flow_type); 10843 } 10844 10845 ret = parse_flexbytes(res->flexbytes_value, 10846 flexbytes, 10847 RTE_ETH_FDIR_MAX_FLEXLEN); 10848 if (ret < 0) { 10849 printf("error: Cannot parse flexbytes input.\n"); 10850 return; 10851 } 10852 10853 switch (entry.input.flow_type) { 10854 case RTE_ETH_FLOW_FRAG_IPV4: 10855 case RTE_ETH_FLOW_NONFRAG_IPV4_OTHER: 10856 entry.input.flow.ip4_flow.proto = res->proto_value; 10857 /* fall-through */ 10858 case RTE_ETH_FLOW_NONFRAG_IPV4_UDP: 10859 case RTE_ETH_FLOW_NONFRAG_IPV4_TCP: 10860 IPV4_ADDR_TO_UINT(res->ip_dst, 10861 entry.input.flow.ip4_flow.dst_ip); 10862 IPV4_ADDR_TO_UINT(res->ip_src, 10863 entry.input.flow.ip4_flow.src_ip); 10864 entry.input.flow.ip4_flow.tos = res->tos_value; 10865 entry.input.flow.ip4_flow.ttl = res->ttl_value; 10866 /* need convert to big endian. */ 10867 entry.input.flow.udp4_flow.dst_port = 10868 rte_cpu_to_be_16(res->port_dst); 10869 entry.input.flow.udp4_flow.src_port = 10870 rte_cpu_to_be_16(res->port_src); 10871 break; 10872 case RTE_ETH_FLOW_NONFRAG_IPV4_SCTP: 10873 IPV4_ADDR_TO_UINT(res->ip_dst, 10874 entry.input.flow.sctp4_flow.ip.dst_ip); 10875 IPV4_ADDR_TO_UINT(res->ip_src, 10876 entry.input.flow.sctp4_flow.ip.src_ip); 10877 entry.input.flow.ip4_flow.tos = res->tos_value; 10878 entry.input.flow.ip4_flow.ttl = res->ttl_value; 10879 /* need convert to big endian. */ 10880 entry.input.flow.sctp4_flow.dst_port = 10881 rte_cpu_to_be_16(res->port_dst); 10882 entry.input.flow.sctp4_flow.src_port = 10883 rte_cpu_to_be_16(res->port_src); 10884 entry.input.flow.sctp4_flow.verify_tag = 10885 rte_cpu_to_be_32(res->verify_tag_value); 10886 break; 10887 case RTE_ETH_FLOW_FRAG_IPV6: 10888 case RTE_ETH_FLOW_NONFRAG_IPV6_OTHER: 10889 entry.input.flow.ipv6_flow.proto = res->proto_value; 10890 /* fall-through */ 10891 case RTE_ETH_FLOW_NONFRAG_IPV6_UDP: 10892 case RTE_ETH_FLOW_NONFRAG_IPV6_TCP: 10893 IPV6_ADDR_TO_ARRAY(res->ip_dst, 10894 entry.input.flow.ipv6_flow.dst_ip); 10895 IPV6_ADDR_TO_ARRAY(res->ip_src, 10896 entry.input.flow.ipv6_flow.src_ip); 10897 entry.input.flow.ipv6_flow.tc = res->tos_value; 10898 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 10899 /* need convert to big endian. */ 10900 entry.input.flow.udp6_flow.dst_port = 10901 rte_cpu_to_be_16(res->port_dst); 10902 entry.input.flow.udp6_flow.src_port = 10903 rte_cpu_to_be_16(res->port_src); 10904 break; 10905 case RTE_ETH_FLOW_NONFRAG_IPV6_SCTP: 10906 IPV6_ADDR_TO_ARRAY(res->ip_dst, 10907 entry.input.flow.sctp6_flow.ip.dst_ip); 10908 IPV6_ADDR_TO_ARRAY(res->ip_src, 10909 entry.input.flow.sctp6_flow.ip.src_ip); 10910 entry.input.flow.ipv6_flow.tc = res->tos_value; 10911 entry.input.flow.ipv6_flow.hop_limits = res->ttl_value; 10912 /* need convert to big endian. */ 10913 entry.input.flow.sctp6_flow.dst_port = 10914 rte_cpu_to_be_16(res->port_dst); 10915 entry.input.flow.sctp6_flow.src_port = 10916 rte_cpu_to_be_16(res->port_src); 10917 entry.input.flow.sctp6_flow.verify_tag = 10918 rte_cpu_to_be_32(res->verify_tag_value); 10919 break; 10920 case RTE_ETH_FLOW_L2_PAYLOAD: 10921 entry.input.flow.l2_flow.ether_type = 10922 rte_cpu_to_be_16(res->ether_type); 10923 break; 10924 default: 10925 break; 10926 } 10927 10928 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) 10929 rte_memcpy(&entry.input.flow.mac_vlan_flow.mac_addr, 10930 &res->mac_addr, 10931 sizeof(struct ether_addr)); 10932 10933 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 10934 rte_memcpy(&entry.input.flow.tunnel_flow.mac_addr, 10935 &res->mac_addr, 10936 sizeof(struct ether_addr)); 10937 entry.input.flow.tunnel_flow.tunnel_type = 10938 str2fdir_tunneltype(res->tunnel_type); 10939 entry.input.flow.tunnel_flow.tunnel_id = 10940 rte_cpu_to_be_32(res->tunnel_id_value); 10941 } 10942 10943 rte_memcpy(entry.input.flow_ext.flexbytes, 10944 flexbytes, 10945 RTE_ETH_FDIR_MAX_FLEXLEN); 10946 10947 entry.input.flow_ext.vlan_tci = rte_cpu_to_be_16(res->vlan_value); 10948 10949 entry.action.flex_off = 0; /*use 0 by default */ 10950 if (!strcmp(res->drop, "drop")) 10951 entry.action.behavior = RTE_ETH_FDIR_REJECT; 10952 else 10953 entry.action.behavior = RTE_ETH_FDIR_ACCEPT; 10954 10955 if (fdir_conf.mode != RTE_FDIR_MODE_PERFECT_MAC_VLAN && 10956 fdir_conf.mode != RTE_FDIR_MODE_PERFECT_TUNNEL) { 10957 if (!strcmp(res->pf_vf, "pf")) 10958 entry.input.flow_ext.is_vf = 0; 10959 else if (!strncmp(res->pf_vf, "vf", 2)) { 10960 struct rte_eth_dev_info dev_info; 10961 10962 memset(&dev_info, 0, sizeof(dev_info)); 10963 rte_eth_dev_info_get(res->port_id, &dev_info); 10964 errno = 0; 10965 vf_id = strtoul(res->pf_vf + 2, &end, 10); 10966 if (errno != 0 || *end != '\0' || 10967 vf_id >= dev_info.max_vfs) { 10968 printf("invalid parameter %s.\n", res->pf_vf); 10969 return; 10970 } 10971 entry.input.flow_ext.is_vf = 1; 10972 entry.input.flow_ext.dst_id = (uint16_t)vf_id; 10973 } else { 10974 printf("invalid parameter %s.\n", res->pf_vf); 10975 return; 10976 } 10977 } 10978 10979 /* set to report FD ID by default */ 10980 entry.action.report_status = RTE_ETH_FDIR_REPORT_ID; 10981 entry.action.rx_queue = res->queue_id; 10982 entry.soft_id = res->fd_id_value; 10983 if (!strcmp(res->ops, "add")) 10984 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10985 RTE_ETH_FILTER_ADD, &entry); 10986 else if (!strcmp(res->ops, "del")) 10987 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10988 RTE_ETH_FILTER_DELETE, &entry); 10989 else 10990 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 10991 RTE_ETH_FILTER_UPDATE, &entry); 10992 if (ret < 0) 10993 printf("flow director programming error: (%s)\n", 10994 strerror(-ret)); 10995 } 10996 10997 cmdline_parse_token_string_t cmd_flow_director_filter = 10998 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 10999 flow_director_filter, "flow_director_filter"); 11000 cmdline_parse_token_num_t cmd_flow_director_port_id = 11001 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11002 port_id, UINT16); 11003 cmdline_parse_token_string_t cmd_flow_director_ops = 11004 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11005 ops, "add#del#update"); 11006 cmdline_parse_token_string_t cmd_flow_director_flow = 11007 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11008 flow, "flow"); 11009 cmdline_parse_token_string_t cmd_flow_director_flow_type = 11010 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11011 flow_type, NULL); 11012 cmdline_parse_token_string_t cmd_flow_director_ether = 11013 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11014 ether, "ether"); 11015 cmdline_parse_token_num_t cmd_flow_director_ether_type = 11016 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11017 ether_type, UINT16); 11018 cmdline_parse_token_string_t cmd_flow_director_src = 11019 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11020 src, "src"); 11021 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_src = 11022 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 11023 ip_src); 11024 cmdline_parse_token_num_t cmd_flow_director_port_src = 11025 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11026 port_src, UINT16); 11027 cmdline_parse_token_string_t cmd_flow_director_dst = 11028 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11029 dst, "dst"); 11030 cmdline_parse_token_ipaddr_t cmd_flow_director_ip_dst = 11031 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_result, 11032 ip_dst); 11033 cmdline_parse_token_num_t cmd_flow_director_port_dst = 11034 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11035 port_dst, UINT16); 11036 cmdline_parse_token_string_t cmd_flow_director_verify_tag = 11037 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11038 verify_tag, "verify_tag"); 11039 cmdline_parse_token_num_t cmd_flow_director_verify_tag_value = 11040 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11041 verify_tag_value, UINT32); 11042 cmdline_parse_token_string_t cmd_flow_director_tos = 11043 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11044 tos, "tos"); 11045 cmdline_parse_token_num_t cmd_flow_director_tos_value = 11046 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11047 tos_value, UINT8); 11048 cmdline_parse_token_string_t cmd_flow_director_proto = 11049 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11050 proto, "proto"); 11051 cmdline_parse_token_num_t cmd_flow_director_proto_value = 11052 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11053 proto_value, UINT8); 11054 cmdline_parse_token_string_t cmd_flow_director_ttl = 11055 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11056 ttl, "ttl"); 11057 cmdline_parse_token_num_t cmd_flow_director_ttl_value = 11058 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11059 ttl_value, UINT8); 11060 cmdline_parse_token_string_t cmd_flow_director_vlan = 11061 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11062 vlan, "vlan"); 11063 cmdline_parse_token_num_t cmd_flow_director_vlan_value = 11064 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11065 vlan_value, UINT16); 11066 cmdline_parse_token_string_t cmd_flow_director_flexbytes = 11067 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11068 flexbytes, "flexbytes"); 11069 cmdline_parse_token_string_t cmd_flow_director_flexbytes_value = 11070 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11071 flexbytes_value, NULL); 11072 cmdline_parse_token_string_t cmd_flow_director_drop = 11073 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11074 drop, "drop#fwd"); 11075 cmdline_parse_token_string_t cmd_flow_director_pf_vf = 11076 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11077 pf_vf, NULL); 11078 cmdline_parse_token_string_t cmd_flow_director_queue = 11079 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11080 queue, "queue"); 11081 cmdline_parse_token_num_t cmd_flow_director_queue_id = 11082 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11083 queue_id, UINT16); 11084 cmdline_parse_token_string_t cmd_flow_director_fd_id = 11085 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11086 fd_id, "fd_id"); 11087 cmdline_parse_token_num_t cmd_flow_director_fd_id_value = 11088 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11089 fd_id_value, UINT32); 11090 11091 cmdline_parse_token_string_t cmd_flow_director_mode = 11092 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11093 mode, "mode"); 11094 cmdline_parse_token_string_t cmd_flow_director_mode_ip = 11095 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11096 mode_value, "IP"); 11097 cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan = 11098 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11099 mode_value, "MAC-VLAN"); 11100 cmdline_parse_token_string_t cmd_flow_director_mode_tunnel = 11101 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11102 mode_value, "Tunnel"); 11103 cmdline_parse_token_string_t cmd_flow_director_mode_raw = 11104 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11105 mode_value, "raw"); 11106 cmdline_parse_token_string_t cmd_flow_director_mac = 11107 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11108 mac, "mac"); 11109 cmdline_parse_token_etheraddr_t cmd_flow_director_mac_addr = 11110 TOKEN_ETHERADDR_INITIALIZER(struct cmd_flow_director_result, 11111 mac_addr); 11112 cmdline_parse_token_string_t cmd_flow_director_tunnel = 11113 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11114 tunnel, "tunnel"); 11115 cmdline_parse_token_string_t cmd_flow_director_tunnel_type = 11116 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11117 tunnel_type, "NVGRE#VxLAN"); 11118 cmdline_parse_token_string_t cmd_flow_director_tunnel_id = 11119 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11120 tunnel_id, "tunnel-id"); 11121 cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value = 11122 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, 11123 tunnel_id_value, UINT32); 11124 cmdline_parse_token_string_t cmd_flow_director_packet = 11125 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11126 packet, "packet"); 11127 cmdline_parse_token_string_t cmd_flow_director_filepath = 11128 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, 11129 filepath, NULL); 11130 11131 cmdline_parse_inst_t cmd_add_del_ip_flow_director = { 11132 .f = cmd_flow_director_filter_parsed, 11133 .data = NULL, 11134 .help_str = "flow_director_filter <port_id> mode IP add|del|update flow" 11135 " ipv4-other|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|" 11136 "ipv6-other|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|" 11137 "l2_payload src <src_ip> dst <dst_ip> tos <tos_value> " 11138 "proto <proto_value> ttl <ttl_value> vlan <vlan_value> " 11139 "flexbytes <flexbyte_values> drop|fw <pf_vf> queue <queue_id> " 11140 "fd_id <fd_id_value>: " 11141 "Add or delete an ip flow director entry on NIC", 11142 .tokens = { 11143 (void *)&cmd_flow_director_filter, 11144 (void *)&cmd_flow_director_port_id, 11145 (void *)&cmd_flow_director_mode, 11146 (void *)&cmd_flow_director_mode_ip, 11147 (void *)&cmd_flow_director_ops, 11148 (void *)&cmd_flow_director_flow, 11149 (void *)&cmd_flow_director_flow_type, 11150 (void *)&cmd_flow_director_src, 11151 (void *)&cmd_flow_director_ip_src, 11152 (void *)&cmd_flow_director_dst, 11153 (void *)&cmd_flow_director_ip_dst, 11154 (void *)&cmd_flow_director_tos, 11155 (void *)&cmd_flow_director_tos_value, 11156 (void *)&cmd_flow_director_proto, 11157 (void *)&cmd_flow_director_proto_value, 11158 (void *)&cmd_flow_director_ttl, 11159 (void *)&cmd_flow_director_ttl_value, 11160 (void *)&cmd_flow_director_vlan, 11161 (void *)&cmd_flow_director_vlan_value, 11162 (void *)&cmd_flow_director_flexbytes, 11163 (void *)&cmd_flow_director_flexbytes_value, 11164 (void *)&cmd_flow_director_drop, 11165 (void *)&cmd_flow_director_pf_vf, 11166 (void *)&cmd_flow_director_queue, 11167 (void *)&cmd_flow_director_queue_id, 11168 (void *)&cmd_flow_director_fd_id, 11169 (void *)&cmd_flow_director_fd_id_value, 11170 NULL, 11171 }, 11172 }; 11173 11174 cmdline_parse_inst_t cmd_add_del_udp_flow_director = { 11175 .f = cmd_flow_director_filter_parsed, 11176 .data = NULL, 11177 .help_str = "flow_director_filter ... : Add or delete an udp/tcp flow " 11178 "director entry on NIC", 11179 .tokens = { 11180 (void *)&cmd_flow_director_filter, 11181 (void *)&cmd_flow_director_port_id, 11182 (void *)&cmd_flow_director_mode, 11183 (void *)&cmd_flow_director_mode_ip, 11184 (void *)&cmd_flow_director_ops, 11185 (void *)&cmd_flow_director_flow, 11186 (void *)&cmd_flow_director_flow_type, 11187 (void *)&cmd_flow_director_src, 11188 (void *)&cmd_flow_director_ip_src, 11189 (void *)&cmd_flow_director_port_src, 11190 (void *)&cmd_flow_director_dst, 11191 (void *)&cmd_flow_director_ip_dst, 11192 (void *)&cmd_flow_director_port_dst, 11193 (void *)&cmd_flow_director_tos, 11194 (void *)&cmd_flow_director_tos_value, 11195 (void *)&cmd_flow_director_ttl, 11196 (void *)&cmd_flow_director_ttl_value, 11197 (void *)&cmd_flow_director_vlan, 11198 (void *)&cmd_flow_director_vlan_value, 11199 (void *)&cmd_flow_director_flexbytes, 11200 (void *)&cmd_flow_director_flexbytes_value, 11201 (void *)&cmd_flow_director_drop, 11202 (void *)&cmd_flow_director_pf_vf, 11203 (void *)&cmd_flow_director_queue, 11204 (void *)&cmd_flow_director_queue_id, 11205 (void *)&cmd_flow_director_fd_id, 11206 (void *)&cmd_flow_director_fd_id_value, 11207 NULL, 11208 }, 11209 }; 11210 11211 cmdline_parse_inst_t cmd_add_del_sctp_flow_director = { 11212 .f = cmd_flow_director_filter_parsed, 11213 .data = NULL, 11214 .help_str = "flow_director_filter ... : Add or delete a sctp flow " 11215 "director entry on NIC", 11216 .tokens = { 11217 (void *)&cmd_flow_director_filter, 11218 (void *)&cmd_flow_director_port_id, 11219 (void *)&cmd_flow_director_mode, 11220 (void *)&cmd_flow_director_mode_ip, 11221 (void *)&cmd_flow_director_ops, 11222 (void *)&cmd_flow_director_flow, 11223 (void *)&cmd_flow_director_flow_type, 11224 (void *)&cmd_flow_director_src, 11225 (void *)&cmd_flow_director_ip_src, 11226 (void *)&cmd_flow_director_port_src, 11227 (void *)&cmd_flow_director_dst, 11228 (void *)&cmd_flow_director_ip_dst, 11229 (void *)&cmd_flow_director_port_dst, 11230 (void *)&cmd_flow_director_verify_tag, 11231 (void *)&cmd_flow_director_verify_tag_value, 11232 (void *)&cmd_flow_director_tos, 11233 (void *)&cmd_flow_director_tos_value, 11234 (void *)&cmd_flow_director_ttl, 11235 (void *)&cmd_flow_director_ttl_value, 11236 (void *)&cmd_flow_director_vlan, 11237 (void *)&cmd_flow_director_vlan_value, 11238 (void *)&cmd_flow_director_flexbytes, 11239 (void *)&cmd_flow_director_flexbytes_value, 11240 (void *)&cmd_flow_director_drop, 11241 (void *)&cmd_flow_director_pf_vf, 11242 (void *)&cmd_flow_director_queue, 11243 (void *)&cmd_flow_director_queue_id, 11244 (void *)&cmd_flow_director_fd_id, 11245 (void *)&cmd_flow_director_fd_id_value, 11246 NULL, 11247 }, 11248 }; 11249 11250 cmdline_parse_inst_t cmd_add_del_l2_flow_director = { 11251 .f = cmd_flow_director_filter_parsed, 11252 .data = NULL, 11253 .help_str = "flow_director_filter ... : Add or delete a L2 flow " 11254 "director entry on NIC", 11255 .tokens = { 11256 (void *)&cmd_flow_director_filter, 11257 (void *)&cmd_flow_director_port_id, 11258 (void *)&cmd_flow_director_mode, 11259 (void *)&cmd_flow_director_mode_ip, 11260 (void *)&cmd_flow_director_ops, 11261 (void *)&cmd_flow_director_flow, 11262 (void *)&cmd_flow_director_flow_type, 11263 (void *)&cmd_flow_director_ether, 11264 (void *)&cmd_flow_director_ether_type, 11265 (void *)&cmd_flow_director_flexbytes, 11266 (void *)&cmd_flow_director_flexbytes_value, 11267 (void *)&cmd_flow_director_drop, 11268 (void *)&cmd_flow_director_pf_vf, 11269 (void *)&cmd_flow_director_queue, 11270 (void *)&cmd_flow_director_queue_id, 11271 (void *)&cmd_flow_director_fd_id, 11272 (void *)&cmd_flow_director_fd_id_value, 11273 NULL, 11274 }, 11275 }; 11276 11277 cmdline_parse_inst_t cmd_add_del_mac_vlan_flow_director = { 11278 .f = cmd_flow_director_filter_parsed, 11279 .data = NULL, 11280 .help_str = "flow_director_filter ... : Add or delete a MAC VLAN flow " 11281 "director entry on NIC", 11282 .tokens = { 11283 (void *)&cmd_flow_director_filter, 11284 (void *)&cmd_flow_director_port_id, 11285 (void *)&cmd_flow_director_mode, 11286 (void *)&cmd_flow_director_mode_mac_vlan, 11287 (void *)&cmd_flow_director_ops, 11288 (void *)&cmd_flow_director_mac, 11289 (void *)&cmd_flow_director_mac_addr, 11290 (void *)&cmd_flow_director_vlan, 11291 (void *)&cmd_flow_director_vlan_value, 11292 (void *)&cmd_flow_director_flexbytes, 11293 (void *)&cmd_flow_director_flexbytes_value, 11294 (void *)&cmd_flow_director_drop, 11295 (void *)&cmd_flow_director_queue, 11296 (void *)&cmd_flow_director_queue_id, 11297 (void *)&cmd_flow_director_fd_id, 11298 (void *)&cmd_flow_director_fd_id_value, 11299 NULL, 11300 }, 11301 }; 11302 11303 cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = { 11304 .f = cmd_flow_director_filter_parsed, 11305 .data = NULL, 11306 .help_str = "flow_director_filter ... : Add or delete a tunnel flow " 11307 "director entry on NIC", 11308 .tokens = { 11309 (void *)&cmd_flow_director_filter, 11310 (void *)&cmd_flow_director_port_id, 11311 (void *)&cmd_flow_director_mode, 11312 (void *)&cmd_flow_director_mode_tunnel, 11313 (void *)&cmd_flow_director_ops, 11314 (void *)&cmd_flow_director_mac, 11315 (void *)&cmd_flow_director_mac_addr, 11316 (void *)&cmd_flow_director_vlan, 11317 (void *)&cmd_flow_director_vlan_value, 11318 (void *)&cmd_flow_director_tunnel, 11319 (void *)&cmd_flow_director_tunnel_type, 11320 (void *)&cmd_flow_director_tunnel_id, 11321 (void *)&cmd_flow_director_tunnel_id_value, 11322 (void *)&cmd_flow_director_flexbytes, 11323 (void *)&cmd_flow_director_flexbytes_value, 11324 (void *)&cmd_flow_director_drop, 11325 (void *)&cmd_flow_director_queue, 11326 (void *)&cmd_flow_director_queue_id, 11327 (void *)&cmd_flow_director_fd_id, 11328 (void *)&cmd_flow_director_fd_id_value, 11329 NULL, 11330 }, 11331 }; 11332 11333 cmdline_parse_inst_t cmd_add_del_raw_flow_director = { 11334 .f = cmd_flow_director_filter_parsed, 11335 .data = NULL, 11336 .help_str = "flow_director_filter ... : Add or delete a raw flow " 11337 "director entry on NIC", 11338 .tokens = { 11339 (void *)&cmd_flow_director_filter, 11340 (void *)&cmd_flow_director_port_id, 11341 (void *)&cmd_flow_director_mode, 11342 (void *)&cmd_flow_director_mode_raw, 11343 (void *)&cmd_flow_director_ops, 11344 (void *)&cmd_flow_director_flow, 11345 (void *)&cmd_flow_director_flow_type, 11346 (void *)&cmd_flow_director_drop, 11347 (void *)&cmd_flow_director_queue, 11348 (void *)&cmd_flow_director_queue_id, 11349 (void *)&cmd_flow_director_fd_id, 11350 (void *)&cmd_flow_director_fd_id_value, 11351 (void *)&cmd_flow_director_packet, 11352 (void *)&cmd_flow_director_filepath, 11353 NULL, 11354 }, 11355 }; 11356 11357 struct cmd_flush_flow_director_result { 11358 cmdline_fixed_string_t flush_flow_director; 11359 portid_t port_id; 11360 }; 11361 11362 cmdline_parse_token_string_t cmd_flush_flow_director_flush = 11363 TOKEN_STRING_INITIALIZER(struct cmd_flush_flow_director_result, 11364 flush_flow_director, "flush_flow_director"); 11365 cmdline_parse_token_num_t cmd_flush_flow_director_port_id = 11366 TOKEN_NUM_INITIALIZER(struct cmd_flush_flow_director_result, 11367 port_id, UINT16); 11368 11369 static void 11370 cmd_flush_flow_director_parsed(void *parsed_result, 11371 __attribute__((unused)) struct cmdline *cl, 11372 __attribute__((unused)) void *data) 11373 { 11374 struct cmd_flow_director_result *res = parsed_result; 11375 int ret = 0; 11376 11377 ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_FDIR); 11378 if (ret < 0) { 11379 printf("flow director is not supported on port %u.\n", 11380 res->port_id); 11381 return; 11382 } 11383 11384 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11385 RTE_ETH_FILTER_FLUSH, NULL); 11386 if (ret < 0) 11387 printf("flow director table flushing error: (%s)\n", 11388 strerror(-ret)); 11389 } 11390 11391 cmdline_parse_inst_t cmd_flush_flow_director = { 11392 .f = cmd_flush_flow_director_parsed, 11393 .data = NULL, 11394 .help_str = "flush_flow_director <port_id>: " 11395 "Flush all flow director entries of a device on NIC", 11396 .tokens = { 11397 (void *)&cmd_flush_flow_director_flush, 11398 (void *)&cmd_flush_flow_director_port_id, 11399 NULL, 11400 }, 11401 }; 11402 11403 /* *** deal with flow director mask *** */ 11404 struct cmd_flow_director_mask_result { 11405 cmdline_fixed_string_t flow_director_mask; 11406 portid_t port_id; 11407 cmdline_fixed_string_t mode; 11408 cmdline_fixed_string_t mode_value; 11409 cmdline_fixed_string_t vlan; 11410 uint16_t vlan_mask; 11411 cmdline_fixed_string_t src_mask; 11412 cmdline_ipaddr_t ipv4_src; 11413 cmdline_ipaddr_t ipv6_src; 11414 uint16_t port_src; 11415 cmdline_fixed_string_t dst_mask; 11416 cmdline_ipaddr_t ipv4_dst; 11417 cmdline_ipaddr_t ipv6_dst; 11418 uint16_t port_dst; 11419 cmdline_fixed_string_t mac; 11420 uint8_t mac_addr_byte_mask; 11421 cmdline_fixed_string_t tunnel_id; 11422 uint32_t tunnel_id_mask; 11423 cmdline_fixed_string_t tunnel_type; 11424 uint8_t tunnel_type_mask; 11425 }; 11426 11427 static void 11428 cmd_flow_director_mask_parsed(void *parsed_result, 11429 __attribute__((unused)) struct cmdline *cl, 11430 __attribute__((unused)) void *data) 11431 { 11432 struct cmd_flow_director_mask_result *res = parsed_result; 11433 struct rte_eth_fdir_masks *mask; 11434 struct rte_port *port; 11435 11436 port = &ports[res->port_id]; 11437 /** Check if the port is not started **/ 11438 if (port->port_status != RTE_PORT_STOPPED) { 11439 printf("Please stop port %d first\n", res->port_id); 11440 return; 11441 } 11442 11443 mask = &port->dev_conf.fdir_conf.mask; 11444 11445 if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) { 11446 if (strcmp(res->mode_value, "MAC-VLAN")) { 11447 printf("Please set mode to MAC-VLAN.\n"); 11448 return; 11449 } 11450 11451 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11452 } else if (fdir_conf.mode == RTE_FDIR_MODE_PERFECT_TUNNEL) { 11453 if (strcmp(res->mode_value, "Tunnel")) { 11454 printf("Please set mode to Tunnel.\n"); 11455 return; 11456 } 11457 11458 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11459 mask->mac_addr_byte_mask = res->mac_addr_byte_mask; 11460 mask->tunnel_id_mask = rte_cpu_to_be_32(res->tunnel_id_mask); 11461 mask->tunnel_type_mask = res->tunnel_type_mask; 11462 } else { 11463 if (strcmp(res->mode_value, "IP")) { 11464 printf("Please set mode to IP.\n"); 11465 return; 11466 } 11467 11468 mask->vlan_tci_mask = rte_cpu_to_be_16(res->vlan_mask); 11469 IPV4_ADDR_TO_UINT(res->ipv4_src, mask->ipv4_mask.src_ip); 11470 IPV4_ADDR_TO_UINT(res->ipv4_dst, mask->ipv4_mask.dst_ip); 11471 IPV6_ADDR_TO_ARRAY(res->ipv6_src, mask->ipv6_mask.src_ip); 11472 IPV6_ADDR_TO_ARRAY(res->ipv6_dst, mask->ipv6_mask.dst_ip); 11473 mask->src_port_mask = rte_cpu_to_be_16(res->port_src); 11474 mask->dst_port_mask = rte_cpu_to_be_16(res->port_dst); 11475 } 11476 11477 cmd_reconfig_device_queue(res->port_id, 1, 1); 11478 } 11479 11480 cmdline_parse_token_string_t cmd_flow_director_mask = 11481 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11482 flow_director_mask, "flow_director_mask"); 11483 cmdline_parse_token_num_t cmd_flow_director_mask_port_id = 11484 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11485 port_id, UINT16); 11486 cmdline_parse_token_string_t cmd_flow_director_mask_vlan = 11487 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11488 vlan, "vlan"); 11489 cmdline_parse_token_num_t cmd_flow_director_mask_vlan_value = 11490 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11491 vlan_mask, UINT16); 11492 cmdline_parse_token_string_t cmd_flow_director_mask_src = 11493 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11494 src_mask, "src_mask"); 11495 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_src = 11496 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11497 ipv4_src); 11498 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_src = 11499 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11500 ipv6_src); 11501 cmdline_parse_token_num_t cmd_flow_director_mask_port_src = 11502 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11503 port_src, UINT16); 11504 cmdline_parse_token_string_t cmd_flow_director_mask_dst = 11505 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11506 dst_mask, "dst_mask"); 11507 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv4_dst = 11508 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11509 ipv4_dst); 11510 cmdline_parse_token_ipaddr_t cmd_flow_director_mask_ipv6_dst = 11511 TOKEN_IPADDR_INITIALIZER(struct cmd_flow_director_mask_result, 11512 ipv6_dst); 11513 cmdline_parse_token_num_t cmd_flow_director_mask_port_dst = 11514 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11515 port_dst, UINT16); 11516 11517 cmdline_parse_token_string_t cmd_flow_director_mask_mode = 11518 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11519 mode, "mode"); 11520 cmdline_parse_token_string_t cmd_flow_director_mask_mode_ip = 11521 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11522 mode_value, "IP"); 11523 cmdline_parse_token_string_t cmd_flow_director_mask_mode_mac_vlan = 11524 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11525 mode_value, "MAC-VLAN"); 11526 cmdline_parse_token_string_t cmd_flow_director_mask_mode_tunnel = 11527 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11528 mode_value, "Tunnel"); 11529 cmdline_parse_token_string_t cmd_flow_director_mask_mac = 11530 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11531 mac, "mac"); 11532 cmdline_parse_token_num_t cmd_flow_director_mask_mac_value = 11533 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11534 mac_addr_byte_mask, UINT8); 11535 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_type = 11536 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11537 tunnel_type, "tunnel-type"); 11538 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_type_value = 11539 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11540 tunnel_type_mask, UINT8); 11541 cmdline_parse_token_string_t cmd_flow_director_mask_tunnel_id = 11542 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_mask_result, 11543 tunnel_id, "tunnel-id"); 11544 cmdline_parse_token_num_t cmd_flow_director_mask_tunnel_id_value = 11545 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_mask_result, 11546 tunnel_id_mask, UINT32); 11547 11548 cmdline_parse_inst_t cmd_set_flow_director_ip_mask = { 11549 .f = cmd_flow_director_mask_parsed, 11550 .data = NULL, 11551 .help_str = "flow_director_mask ... : " 11552 "Set IP mode flow director's mask on NIC", 11553 .tokens = { 11554 (void *)&cmd_flow_director_mask, 11555 (void *)&cmd_flow_director_mask_port_id, 11556 (void *)&cmd_flow_director_mask_mode, 11557 (void *)&cmd_flow_director_mask_mode_ip, 11558 (void *)&cmd_flow_director_mask_vlan, 11559 (void *)&cmd_flow_director_mask_vlan_value, 11560 (void *)&cmd_flow_director_mask_src, 11561 (void *)&cmd_flow_director_mask_ipv4_src, 11562 (void *)&cmd_flow_director_mask_ipv6_src, 11563 (void *)&cmd_flow_director_mask_port_src, 11564 (void *)&cmd_flow_director_mask_dst, 11565 (void *)&cmd_flow_director_mask_ipv4_dst, 11566 (void *)&cmd_flow_director_mask_ipv6_dst, 11567 (void *)&cmd_flow_director_mask_port_dst, 11568 NULL, 11569 }, 11570 }; 11571 11572 cmdline_parse_inst_t cmd_set_flow_director_mac_vlan_mask = { 11573 .f = cmd_flow_director_mask_parsed, 11574 .data = NULL, 11575 .help_str = "flow_director_mask ... : Set MAC VLAN mode " 11576 "flow director's mask on NIC", 11577 .tokens = { 11578 (void *)&cmd_flow_director_mask, 11579 (void *)&cmd_flow_director_mask_port_id, 11580 (void *)&cmd_flow_director_mask_mode, 11581 (void *)&cmd_flow_director_mask_mode_mac_vlan, 11582 (void *)&cmd_flow_director_mask_vlan, 11583 (void *)&cmd_flow_director_mask_vlan_value, 11584 NULL, 11585 }, 11586 }; 11587 11588 cmdline_parse_inst_t cmd_set_flow_director_tunnel_mask = { 11589 .f = cmd_flow_director_mask_parsed, 11590 .data = NULL, 11591 .help_str = "flow_director_mask ... : Set tunnel mode " 11592 "flow director's mask on NIC", 11593 .tokens = { 11594 (void *)&cmd_flow_director_mask, 11595 (void *)&cmd_flow_director_mask_port_id, 11596 (void *)&cmd_flow_director_mask_mode, 11597 (void *)&cmd_flow_director_mask_mode_tunnel, 11598 (void *)&cmd_flow_director_mask_vlan, 11599 (void *)&cmd_flow_director_mask_vlan_value, 11600 (void *)&cmd_flow_director_mask_mac, 11601 (void *)&cmd_flow_director_mask_mac_value, 11602 (void *)&cmd_flow_director_mask_tunnel_type, 11603 (void *)&cmd_flow_director_mask_tunnel_type_value, 11604 (void *)&cmd_flow_director_mask_tunnel_id, 11605 (void *)&cmd_flow_director_mask_tunnel_id_value, 11606 NULL, 11607 }, 11608 }; 11609 11610 /* *** deal with flow director mask on flexible payload *** */ 11611 struct cmd_flow_director_flex_mask_result { 11612 cmdline_fixed_string_t flow_director_flexmask; 11613 portid_t port_id; 11614 cmdline_fixed_string_t flow; 11615 cmdline_fixed_string_t flow_type; 11616 cmdline_fixed_string_t mask; 11617 }; 11618 11619 static void 11620 cmd_flow_director_flex_mask_parsed(void *parsed_result, 11621 __attribute__((unused)) struct cmdline *cl, 11622 __attribute__((unused)) void *data) 11623 { 11624 struct cmd_flow_director_flex_mask_result *res = parsed_result; 11625 struct rte_eth_fdir_info fdir_info; 11626 struct rte_eth_fdir_flex_mask flex_mask; 11627 struct rte_port *port; 11628 uint64_t flow_type_mask; 11629 uint16_t i; 11630 int ret; 11631 11632 port = &ports[res->port_id]; 11633 /** Check if the port is not started **/ 11634 if (port->port_status != RTE_PORT_STOPPED) { 11635 printf("Please stop port %d first\n", res->port_id); 11636 return; 11637 } 11638 11639 memset(&flex_mask, 0, sizeof(struct rte_eth_fdir_flex_mask)); 11640 ret = parse_flexbytes(res->mask, 11641 flex_mask.mask, 11642 RTE_ETH_FDIR_MAX_FLEXLEN); 11643 if (ret < 0) { 11644 printf("error: Cannot parse mask input.\n"); 11645 return; 11646 } 11647 11648 memset(&fdir_info, 0, sizeof(fdir_info)); 11649 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 11650 RTE_ETH_FILTER_INFO, &fdir_info); 11651 if (ret < 0) { 11652 printf("Cannot get FDir filter info\n"); 11653 return; 11654 } 11655 11656 if (!strcmp(res->flow_type, "none")) { 11657 /* means don't specify the flow type */ 11658 flex_mask.flow_type = RTE_ETH_FLOW_UNKNOWN; 11659 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) 11660 memset(&port->dev_conf.fdir_conf.flex_conf.flex_mask[i], 11661 0, sizeof(struct rte_eth_fdir_flex_mask)); 11662 port->dev_conf.fdir_conf.flex_conf.nb_flexmasks = 1; 11663 rte_memcpy(&port->dev_conf.fdir_conf.flex_conf.flex_mask[0], 11664 &flex_mask, 11665 sizeof(struct rte_eth_fdir_flex_mask)); 11666 cmd_reconfig_device_queue(res->port_id, 1, 1); 11667 return; 11668 } 11669 flow_type_mask = fdir_info.flow_types_mask[0]; 11670 if (!strcmp(res->flow_type, "all")) { 11671 if (!flow_type_mask) { 11672 printf("No flow type supported\n"); 11673 return; 11674 } 11675 for (i = RTE_ETH_FLOW_UNKNOWN; i < RTE_ETH_FLOW_MAX; i++) { 11676 if (flow_type_mask & (1ULL << i)) { 11677 flex_mask.flow_type = i; 11678 fdir_set_flex_mask(res->port_id, &flex_mask); 11679 } 11680 } 11681 cmd_reconfig_device_queue(res->port_id, 1, 1); 11682 return; 11683 } 11684 flex_mask.flow_type = str2flowtype(res->flow_type); 11685 if (!(flow_type_mask & (1ULL << flex_mask.flow_type))) { 11686 printf("Flow type %s not supported on port %d\n", 11687 res->flow_type, res->port_id); 11688 return; 11689 } 11690 fdir_set_flex_mask(res->port_id, &flex_mask); 11691 cmd_reconfig_device_queue(res->port_id, 1, 1); 11692 } 11693 11694 cmdline_parse_token_string_t cmd_flow_director_flexmask = 11695 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11696 flow_director_flexmask, 11697 "flow_director_flex_mask"); 11698 cmdline_parse_token_num_t cmd_flow_director_flexmask_port_id = 11699 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11700 port_id, UINT16); 11701 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow = 11702 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11703 flow, "flow"); 11704 cmdline_parse_token_string_t cmd_flow_director_flexmask_flow_type = 11705 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11706 flow_type, "none#ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" 11707 "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload#all"); 11708 cmdline_parse_token_string_t cmd_flow_director_flexmask_mask = 11709 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flex_mask_result, 11710 mask, NULL); 11711 11712 cmdline_parse_inst_t cmd_set_flow_director_flex_mask = { 11713 .f = cmd_flow_director_flex_mask_parsed, 11714 .data = NULL, 11715 .help_str = "flow_director_flex_mask ... : " 11716 "Set flow director's flex mask on NIC", 11717 .tokens = { 11718 (void *)&cmd_flow_director_flexmask, 11719 (void *)&cmd_flow_director_flexmask_port_id, 11720 (void *)&cmd_flow_director_flexmask_flow, 11721 (void *)&cmd_flow_director_flexmask_flow_type, 11722 (void *)&cmd_flow_director_flexmask_mask, 11723 NULL, 11724 }, 11725 }; 11726 11727 /* *** deal with flow director flexible payload configuration *** */ 11728 struct cmd_flow_director_flexpayload_result { 11729 cmdline_fixed_string_t flow_director_flexpayload; 11730 portid_t port_id; 11731 cmdline_fixed_string_t payload_layer; 11732 cmdline_fixed_string_t payload_cfg; 11733 }; 11734 11735 static inline int 11736 parse_offsets(const char *q_arg, uint16_t *offsets, uint16_t max_num) 11737 { 11738 char s[256]; 11739 const char *p, *p0 = q_arg; 11740 char *end; 11741 unsigned long int_fld; 11742 char *str_fld[max_num]; 11743 int i; 11744 unsigned size; 11745 int ret = -1; 11746 11747 p = strchr(p0, '('); 11748 if (p == NULL) 11749 return -1; 11750 ++p; 11751 p0 = strchr(p, ')'); 11752 if (p0 == NULL) 11753 return -1; 11754 11755 size = p0 - p; 11756 if (size >= sizeof(s)) 11757 return -1; 11758 11759 snprintf(s, sizeof(s), "%.*s", size, p); 11760 ret = rte_strsplit(s, sizeof(s), str_fld, max_num, ','); 11761 if (ret < 0 || ret > max_num) 11762 return -1; 11763 for (i = 0; i < ret; i++) { 11764 errno = 0; 11765 int_fld = strtoul(str_fld[i], &end, 0); 11766 if (errno != 0 || *end != '\0' || int_fld > UINT16_MAX) 11767 return -1; 11768 offsets[i] = (uint16_t)int_fld; 11769 } 11770 return ret; 11771 } 11772 11773 static void 11774 cmd_flow_director_flxpld_parsed(void *parsed_result, 11775 __attribute__((unused)) struct cmdline *cl, 11776 __attribute__((unused)) void *data) 11777 { 11778 struct cmd_flow_director_flexpayload_result *res = parsed_result; 11779 struct rte_eth_flex_payload_cfg flex_cfg; 11780 struct rte_port *port; 11781 int ret = 0; 11782 11783 port = &ports[res->port_id]; 11784 /** Check if the port is not started **/ 11785 if (port->port_status != RTE_PORT_STOPPED) { 11786 printf("Please stop port %d first\n", res->port_id); 11787 return; 11788 } 11789 11790 memset(&flex_cfg, 0, sizeof(struct rte_eth_flex_payload_cfg)); 11791 11792 if (!strcmp(res->payload_layer, "raw")) 11793 flex_cfg.type = RTE_ETH_RAW_PAYLOAD; 11794 else if (!strcmp(res->payload_layer, "l2")) 11795 flex_cfg.type = RTE_ETH_L2_PAYLOAD; 11796 else if (!strcmp(res->payload_layer, "l3")) 11797 flex_cfg.type = RTE_ETH_L3_PAYLOAD; 11798 else if (!strcmp(res->payload_layer, "l4")) 11799 flex_cfg.type = RTE_ETH_L4_PAYLOAD; 11800 11801 ret = parse_offsets(res->payload_cfg, flex_cfg.src_offset, 11802 RTE_ETH_FDIR_MAX_FLEXLEN); 11803 if (ret < 0) { 11804 printf("error: Cannot parse flex payload input.\n"); 11805 return; 11806 } 11807 11808 fdir_set_flex_payload(res->port_id, &flex_cfg); 11809 cmd_reconfig_device_queue(res->port_id, 1, 1); 11810 } 11811 11812 cmdline_parse_token_string_t cmd_flow_director_flexpayload = 11813 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11814 flow_director_flexpayload, 11815 "flow_director_flex_payload"); 11816 cmdline_parse_token_num_t cmd_flow_director_flexpayload_port_id = 11817 TOKEN_NUM_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11818 port_id, UINT16); 11819 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_layer = 11820 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11821 payload_layer, "raw#l2#l3#l4"); 11822 cmdline_parse_token_string_t cmd_flow_director_flexpayload_payload_cfg = 11823 TOKEN_STRING_INITIALIZER(struct cmd_flow_director_flexpayload_result, 11824 payload_cfg, NULL); 11825 11826 cmdline_parse_inst_t cmd_set_flow_director_flex_payload = { 11827 .f = cmd_flow_director_flxpld_parsed, 11828 .data = NULL, 11829 .help_str = "flow_director_flexpayload ... : " 11830 "Set flow director's flex payload on NIC", 11831 .tokens = { 11832 (void *)&cmd_flow_director_flexpayload, 11833 (void *)&cmd_flow_director_flexpayload_port_id, 11834 (void *)&cmd_flow_director_flexpayload_payload_layer, 11835 (void *)&cmd_flow_director_flexpayload_payload_cfg, 11836 NULL, 11837 }, 11838 }; 11839 11840 /* Generic flow interface command. */ 11841 extern cmdline_parse_inst_t cmd_flow; 11842 11843 /* *** Classification Filters Control *** */ 11844 /* *** Get symmetric hash enable per port *** */ 11845 struct cmd_get_sym_hash_ena_per_port_result { 11846 cmdline_fixed_string_t get_sym_hash_ena_per_port; 11847 portid_t port_id; 11848 }; 11849 11850 static void 11851 cmd_get_sym_hash_per_port_parsed(void *parsed_result, 11852 __rte_unused struct cmdline *cl, 11853 __rte_unused void *data) 11854 { 11855 struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result; 11856 struct rte_eth_hash_filter_info info; 11857 int ret; 11858 11859 if (rte_eth_dev_filter_supported(res->port_id, 11860 RTE_ETH_FILTER_HASH) < 0) { 11861 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 11862 res->port_id); 11863 return; 11864 } 11865 11866 memset(&info, 0, sizeof(info)); 11867 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 11868 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11869 RTE_ETH_FILTER_GET, &info); 11870 11871 if (ret < 0) { 11872 printf("Cannot get symmetric hash enable per port " 11873 "on port %u\n", res->port_id); 11874 return; 11875 } 11876 11877 printf("Symmetric hash is %s on port %u\n", info.info.enable ? 11878 "enabled" : "disabled", res->port_id); 11879 } 11880 11881 cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all = 11882 TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 11883 get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port"); 11884 cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id = 11885 TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result, 11886 port_id, UINT16); 11887 11888 cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = { 11889 .f = cmd_get_sym_hash_per_port_parsed, 11890 .data = NULL, 11891 .help_str = "get_sym_hash_ena_per_port <port_id>", 11892 .tokens = { 11893 (void *)&cmd_get_sym_hash_ena_per_port_all, 11894 (void *)&cmd_get_sym_hash_ena_per_port_port_id, 11895 NULL, 11896 }, 11897 }; 11898 11899 /* *** Set symmetric hash enable per port *** */ 11900 struct cmd_set_sym_hash_ena_per_port_result { 11901 cmdline_fixed_string_t set_sym_hash_ena_per_port; 11902 cmdline_fixed_string_t enable; 11903 portid_t port_id; 11904 }; 11905 11906 static void 11907 cmd_set_sym_hash_per_port_parsed(void *parsed_result, 11908 __rte_unused struct cmdline *cl, 11909 __rte_unused void *data) 11910 { 11911 struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result; 11912 struct rte_eth_hash_filter_info info; 11913 int ret; 11914 11915 if (rte_eth_dev_filter_supported(res->port_id, 11916 RTE_ETH_FILTER_HASH) < 0) { 11917 printf("RTE_ETH_FILTER_HASH not supported on port: %d\n", 11918 res->port_id); 11919 return; 11920 } 11921 11922 memset(&info, 0, sizeof(info)); 11923 info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT; 11924 if (!strcmp(res->enable, "enable")) 11925 info.info.enable = 1; 11926 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 11927 RTE_ETH_FILTER_SET, &info); 11928 if (ret < 0) { 11929 printf("Cannot set symmetric hash enable per port on " 11930 "port %u\n", res->port_id); 11931 return; 11932 } 11933 printf("Symmetric hash has been set to %s on port %u\n", 11934 res->enable, res->port_id); 11935 } 11936 11937 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all = 11938 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11939 set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port"); 11940 cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id = 11941 TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11942 port_id, UINT16); 11943 cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable = 11944 TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result, 11945 enable, "enable#disable"); 11946 11947 cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = { 11948 .f = cmd_set_sym_hash_per_port_parsed, 11949 .data = NULL, 11950 .help_str = "set_sym_hash_ena_per_port <port_id> enable|disable", 11951 .tokens = { 11952 (void *)&cmd_set_sym_hash_ena_per_port_all, 11953 (void *)&cmd_set_sym_hash_ena_per_port_port_id, 11954 (void *)&cmd_set_sym_hash_ena_per_port_enable, 11955 NULL, 11956 }, 11957 }; 11958 11959 /* Get global config of hash function */ 11960 struct cmd_get_hash_global_config_result { 11961 cmdline_fixed_string_t get_hash_global_config; 11962 portid_t port_id; 11963 }; 11964 11965 static char * 11966 flowtype_to_str(uint16_t ftype) 11967 { 11968 uint16_t i; 11969 static struct { 11970 char str[16]; 11971 uint16_t ftype; 11972 } ftype_table[] = { 11973 {"ipv4", RTE_ETH_FLOW_IPV4}, 11974 {"ipv4-frag", RTE_ETH_FLOW_FRAG_IPV4}, 11975 {"ipv4-tcp", RTE_ETH_FLOW_NONFRAG_IPV4_TCP}, 11976 {"ipv4-udp", RTE_ETH_FLOW_NONFRAG_IPV4_UDP}, 11977 {"ipv4-sctp", RTE_ETH_FLOW_NONFRAG_IPV4_SCTP}, 11978 {"ipv4-other", RTE_ETH_FLOW_NONFRAG_IPV4_OTHER}, 11979 {"ipv6", RTE_ETH_FLOW_IPV6}, 11980 {"ipv6-frag", RTE_ETH_FLOW_FRAG_IPV6}, 11981 {"ipv6-tcp", RTE_ETH_FLOW_NONFRAG_IPV6_TCP}, 11982 {"ipv6-udp", RTE_ETH_FLOW_NONFRAG_IPV6_UDP}, 11983 {"ipv6-sctp", RTE_ETH_FLOW_NONFRAG_IPV6_SCTP}, 11984 {"ipv6-other", RTE_ETH_FLOW_NONFRAG_IPV6_OTHER}, 11985 {"l2_payload", RTE_ETH_FLOW_L2_PAYLOAD}, 11986 {"port", RTE_ETH_FLOW_PORT}, 11987 {"vxlan", RTE_ETH_FLOW_VXLAN}, 11988 {"geneve", RTE_ETH_FLOW_GENEVE}, 11989 {"nvgre", RTE_ETH_FLOW_NVGRE}, 11990 }; 11991 11992 for (i = 0; i < RTE_DIM(ftype_table); i++) { 11993 if (ftype_table[i].ftype == ftype) 11994 return ftype_table[i].str; 11995 } 11996 11997 return NULL; 11998 } 11999 12000 static void 12001 cmd_get_hash_global_config_parsed(void *parsed_result, 12002 __rte_unused struct cmdline *cl, 12003 __rte_unused void *data) 12004 { 12005 struct cmd_get_hash_global_config_result *res = parsed_result; 12006 struct rte_eth_hash_filter_info info; 12007 uint32_t idx, offset; 12008 uint16_t i; 12009 char *str; 12010 int ret; 12011 12012 if (rte_eth_dev_filter_supported(res->port_id, 12013 RTE_ETH_FILTER_HASH) < 0) { 12014 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 12015 res->port_id); 12016 return; 12017 } 12018 12019 memset(&info, 0, sizeof(info)); 12020 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 12021 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12022 RTE_ETH_FILTER_GET, &info); 12023 if (ret < 0) { 12024 printf("Cannot get hash global configurations by port %d\n", 12025 res->port_id); 12026 return; 12027 } 12028 12029 switch (info.info.global_conf.hash_func) { 12030 case RTE_ETH_HASH_FUNCTION_TOEPLITZ: 12031 printf("Hash function is Toeplitz\n"); 12032 break; 12033 case RTE_ETH_HASH_FUNCTION_SIMPLE_XOR: 12034 printf("Hash function is Simple XOR\n"); 12035 break; 12036 default: 12037 printf("Unknown hash function\n"); 12038 break; 12039 } 12040 12041 for (i = 0; i < RTE_ETH_FLOW_MAX; i++) { 12042 idx = i / UINT64_BIT; 12043 offset = i % UINT64_BIT; 12044 if (!(info.info.global_conf.valid_bit_mask[idx] & 12045 (1ULL << offset))) 12046 continue; 12047 str = flowtype_to_str(i); 12048 if (!str) 12049 continue; 12050 printf("Symmetric hash is %s globally for flow type %s " 12051 "by port %d\n", 12052 ((info.info.global_conf.sym_hash_enable_mask[idx] & 12053 (1ULL << offset)) ? "enabled" : "disabled"), str, 12054 res->port_id); 12055 } 12056 } 12057 12058 cmdline_parse_token_string_t cmd_get_hash_global_config_all = 12059 TOKEN_STRING_INITIALIZER(struct cmd_get_hash_global_config_result, 12060 get_hash_global_config, "get_hash_global_config"); 12061 cmdline_parse_token_num_t cmd_get_hash_global_config_port_id = 12062 TOKEN_NUM_INITIALIZER(struct cmd_get_hash_global_config_result, 12063 port_id, UINT16); 12064 12065 cmdline_parse_inst_t cmd_get_hash_global_config = { 12066 .f = cmd_get_hash_global_config_parsed, 12067 .data = NULL, 12068 .help_str = "get_hash_global_config <port_id>", 12069 .tokens = { 12070 (void *)&cmd_get_hash_global_config_all, 12071 (void *)&cmd_get_hash_global_config_port_id, 12072 NULL, 12073 }, 12074 }; 12075 12076 /* Set global config of hash function */ 12077 struct cmd_set_hash_global_config_result { 12078 cmdline_fixed_string_t set_hash_global_config; 12079 portid_t port_id; 12080 cmdline_fixed_string_t hash_func; 12081 cmdline_fixed_string_t flow_type; 12082 cmdline_fixed_string_t enable; 12083 }; 12084 12085 static void 12086 cmd_set_hash_global_config_parsed(void *parsed_result, 12087 __rte_unused struct cmdline *cl, 12088 __rte_unused void *data) 12089 { 12090 struct cmd_set_hash_global_config_result *res = parsed_result; 12091 struct rte_eth_hash_filter_info info; 12092 uint32_t ftype, idx, offset; 12093 int ret; 12094 12095 if (rte_eth_dev_filter_supported(res->port_id, 12096 RTE_ETH_FILTER_HASH) < 0) { 12097 printf("RTE_ETH_FILTER_HASH not supported on port %d\n", 12098 res->port_id); 12099 return; 12100 } 12101 memset(&info, 0, sizeof(info)); 12102 info.info_type = RTE_ETH_HASH_FILTER_GLOBAL_CONFIG; 12103 if (!strcmp(res->hash_func, "toeplitz")) 12104 info.info.global_conf.hash_func = 12105 RTE_ETH_HASH_FUNCTION_TOEPLITZ; 12106 else if (!strcmp(res->hash_func, "simple_xor")) 12107 info.info.global_conf.hash_func = 12108 RTE_ETH_HASH_FUNCTION_SIMPLE_XOR; 12109 else if (!strcmp(res->hash_func, "default")) 12110 info.info.global_conf.hash_func = 12111 RTE_ETH_HASH_FUNCTION_DEFAULT; 12112 12113 ftype = str2flowtype(res->flow_type); 12114 idx = ftype / UINT64_BIT; 12115 offset = ftype % UINT64_BIT; 12116 info.info.global_conf.valid_bit_mask[idx] |= (1ULL << offset); 12117 if (!strcmp(res->enable, "enable")) 12118 info.info.global_conf.sym_hash_enable_mask[idx] |= 12119 (1ULL << offset); 12120 ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12121 RTE_ETH_FILTER_SET, &info); 12122 if (ret < 0) 12123 printf("Cannot set global hash configurations by port %d\n", 12124 res->port_id); 12125 else 12126 printf("Global hash configurations have been set " 12127 "successfully by port %d\n", res->port_id); 12128 } 12129 12130 cmdline_parse_token_string_t cmd_set_hash_global_config_all = 12131 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12132 set_hash_global_config, "set_hash_global_config"); 12133 cmdline_parse_token_num_t cmd_set_hash_global_config_port_id = 12134 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_global_config_result, 12135 port_id, UINT16); 12136 cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func = 12137 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12138 hash_func, "toeplitz#simple_xor#default"); 12139 cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type = 12140 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12141 flow_type, 12142 "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#" 12143 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 12144 cmdline_parse_token_string_t cmd_set_hash_global_config_enable = 12145 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, 12146 enable, "enable#disable"); 12147 12148 cmdline_parse_inst_t cmd_set_hash_global_config = { 12149 .f = cmd_set_hash_global_config_parsed, 12150 .data = NULL, 12151 .help_str = "set_hash_global_config <port_id> " 12152 "toeplitz|simple_xor|default " 12153 "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12154 "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" 12155 "l2_payload enable|disable", 12156 .tokens = { 12157 (void *)&cmd_set_hash_global_config_all, 12158 (void *)&cmd_set_hash_global_config_port_id, 12159 (void *)&cmd_set_hash_global_config_hash_func, 12160 (void *)&cmd_set_hash_global_config_flow_type, 12161 (void *)&cmd_set_hash_global_config_enable, 12162 NULL, 12163 }, 12164 }; 12165 12166 /* Set hash input set */ 12167 struct cmd_set_hash_input_set_result { 12168 cmdline_fixed_string_t set_hash_input_set; 12169 portid_t port_id; 12170 cmdline_fixed_string_t flow_type; 12171 cmdline_fixed_string_t inset_field; 12172 cmdline_fixed_string_t select; 12173 }; 12174 12175 static enum rte_eth_input_set_field 12176 str2inset(char *string) 12177 { 12178 uint16_t i; 12179 12180 static const struct { 12181 char str[32]; 12182 enum rte_eth_input_set_field inset; 12183 } inset_table[] = { 12184 {"ethertype", RTE_ETH_INPUT_SET_L2_ETHERTYPE}, 12185 {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN}, 12186 {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN}, 12187 {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4}, 12188 {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4}, 12189 {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS}, 12190 {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO}, 12191 {"ipv4-ttl", RTE_ETH_INPUT_SET_L3_IP4_TTL}, 12192 {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6}, 12193 {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6}, 12194 {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC}, 12195 {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER}, 12196 {"ipv6-hop-limits", RTE_ETH_INPUT_SET_L3_IP6_HOP_LIMITS}, 12197 {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT}, 12198 {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT}, 12199 {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT}, 12200 {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT}, 12201 {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT}, 12202 {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT}, 12203 {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG}, 12204 {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY}, 12205 {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY}, 12206 {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD}, 12207 {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD}, 12208 {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD}, 12209 {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD}, 12210 {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD}, 12211 {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD}, 12212 {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD}, 12213 {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD}, 12214 {"none", RTE_ETH_INPUT_SET_NONE}, 12215 }; 12216 12217 for (i = 0; i < RTE_DIM(inset_table); i++) { 12218 if (!strcmp(string, inset_table[i].str)) 12219 return inset_table[i].inset; 12220 } 12221 12222 return RTE_ETH_INPUT_SET_UNKNOWN; 12223 } 12224 12225 static void 12226 cmd_set_hash_input_set_parsed(void *parsed_result, 12227 __rte_unused struct cmdline *cl, 12228 __rte_unused void *data) 12229 { 12230 struct cmd_set_hash_input_set_result *res = parsed_result; 12231 struct rte_eth_hash_filter_info info; 12232 12233 memset(&info, 0, sizeof(info)); 12234 info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT; 12235 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 12236 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 12237 info.info.input_set_conf.inset_size = 1; 12238 if (!strcmp(res->select, "select")) 12239 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 12240 else if (!strcmp(res->select, "add")) 12241 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 12242 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, 12243 RTE_ETH_FILTER_SET, &info); 12244 } 12245 12246 cmdline_parse_token_string_t cmd_set_hash_input_set_cmd = 12247 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12248 set_hash_input_set, "set_hash_input_set"); 12249 cmdline_parse_token_num_t cmd_set_hash_input_set_port_id = 12250 TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result, 12251 port_id, UINT16); 12252 cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type = 12253 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12254 flow_type, NULL); 12255 cmdline_parse_token_string_t cmd_set_hash_input_set_field = 12256 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12257 inset_field, 12258 "ovlan#ivlan#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12259 "ipv4-tos#ipv4-proto#ipv6-tc#ipv6-next-header#udp-src-port#" 12260 "udp-dst-port#tcp-src-port#tcp-dst-port#sctp-src-port#" 12261 "sctp-dst-port#sctp-veri-tag#udp-key#gre-key#fld-1st#" 12262 "fld-2nd#fld-3rd#fld-4th#fld-5th#fld-6th#fld-7th#" 12263 "fld-8th#none"); 12264 cmdline_parse_token_string_t cmd_set_hash_input_set_select = 12265 TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result, 12266 select, "select#add"); 12267 12268 cmdline_parse_inst_t cmd_set_hash_input_set = { 12269 .f = cmd_set_hash_input_set_parsed, 12270 .data = NULL, 12271 .help_str = "set_hash_input_set <port_id> " 12272 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12273 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|<flowtype_id> " 12274 "ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos|ipv4-proto|" 12275 "ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port|tcp-src-port|" 12276 "tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag|udp-key|" 12277 "gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|" 12278 "fld-7th|fld-8th|none select|add", 12279 .tokens = { 12280 (void *)&cmd_set_hash_input_set_cmd, 12281 (void *)&cmd_set_hash_input_set_port_id, 12282 (void *)&cmd_set_hash_input_set_flow_type, 12283 (void *)&cmd_set_hash_input_set_field, 12284 (void *)&cmd_set_hash_input_set_select, 12285 NULL, 12286 }, 12287 }; 12288 12289 /* Set flow director input set */ 12290 struct cmd_set_fdir_input_set_result { 12291 cmdline_fixed_string_t set_fdir_input_set; 12292 portid_t port_id; 12293 cmdline_fixed_string_t flow_type; 12294 cmdline_fixed_string_t inset_field; 12295 cmdline_fixed_string_t select; 12296 }; 12297 12298 static void 12299 cmd_set_fdir_input_set_parsed(void *parsed_result, 12300 __rte_unused struct cmdline *cl, 12301 __rte_unused void *data) 12302 { 12303 struct cmd_set_fdir_input_set_result *res = parsed_result; 12304 struct rte_eth_fdir_filter_info info; 12305 12306 memset(&info, 0, sizeof(info)); 12307 info.info_type = RTE_ETH_FDIR_FILTER_INPUT_SET_SELECT; 12308 info.info.input_set_conf.flow_type = str2flowtype(res->flow_type); 12309 info.info.input_set_conf.field[0] = str2inset(res->inset_field); 12310 info.info.input_set_conf.inset_size = 1; 12311 if (!strcmp(res->select, "select")) 12312 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT; 12313 else if (!strcmp(res->select, "add")) 12314 info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD; 12315 rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_FDIR, 12316 RTE_ETH_FILTER_SET, &info); 12317 } 12318 12319 cmdline_parse_token_string_t cmd_set_fdir_input_set_cmd = 12320 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12321 set_fdir_input_set, "set_fdir_input_set"); 12322 cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id = 12323 TOKEN_NUM_INITIALIZER(struct cmd_set_fdir_input_set_result, 12324 port_id, UINT16); 12325 cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type = 12326 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12327 flow_type, 12328 "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#" 12329 "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); 12330 cmdline_parse_token_string_t cmd_set_fdir_input_set_field = 12331 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12332 inset_field, 12333 "ivlan#ethertype#src-ipv4#dst-ipv4#src-ipv6#dst-ipv6#" 12334 "ipv4-tos#ipv4-proto#ipv4-ttl#ipv6-tc#ipv6-next-header#" 12335 "ipv6-hop-limits#udp-src-port#udp-dst-port#" 12336 "tcp-src-port#tcp-dst-port#sctp-src-port#sctp-dst-port#" 12337 "sctp-veri-tag#none"); 12338 cmdline_parse_token_string_t cmd_set_fdir_input_set_select = 12339 TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, 12340 select, "select#add"); 12341 12342 cmdline_parse_inst_t cmd_set_fdir_input_set = { 12343 .f = cmd_set_fdir_input_set_parsed, 12344 .data = NULL, 12345 .help_str = "set_fdir_input_set <port_id> " 12346 "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" 12347 "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload " 12348 "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|" 12349 "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|" 12350 "ipv6-hop-limits|udp-src-port|udp-dst-port|" 12351 "tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|" 12352 "sctp-veri-tag|none select|add", 12353 .tokens = { 12354 (void *)&cmd_set_fdir_input_set_cmd, 12355 (void *)&cmd_set_fdir_input_set_port_id, 12356 (void *)&cmd_set_fdir_input_set_flow_type, 12357 (void *)&cmd_set_fdir_input_set_field, 12358 (void *)&cmd_set_fdir_input_set_select, 12359 NULL, 12360 }, 12361 }; 12362 12363 /* *** ADD/REMOVE A MULTICAST MAC ADDRESS TO/FROM A PORT *** */ 12364 struct cmd_mcast_addr_result { 12365 cmdline_fixed_string_t mcast_addr_cmd; 12366 cmdline_fixed_string_t what; 12367 uint16_t port_num; 12368 struct ether_addr mc_addr; 12369 }; 12370 12371 static void cmd_mcast_addr_parsed(void *parsed_result, 12372 __attribute__((unused)) struct cmdline *cl, 12373 __attribute__((unused)) void *data) 12374 { 12375 struct cmd_mcast_addr_result *res = parsed_result; 12376 12377 if (!is_multicast_ether_addr(&res->mc_addr)) { 12378 printf("Invalid multicast addr %02X:%02X:%02X:%02X:%02X:%02X\n", 12379 res->mc_addr.addr_bytes[0], res->mc_addr.addr_bytes[1], 12380 res->mc_addr.addr_bytes[2], res->mc_addr.addr_bytes[3], 12381 res->mc_addr.addr_bytes[4], res->mc_addr.addr_bytes[5]); 12382 return; 12383 } 12384 if (strcmp(res->what, "add") == 0) 12385 mcast_addr_add(res->port_num, &res->mc_addr); 12386 else 12387 mcast_addr_remove(res->port_num, &res->mc_addr); 12388 } 12389 12390 cmdline_parse_token_string_t cmd_mcast_addr_cmd = 12391 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, 12392 mcast_addr_cmd, "mcast_addr"); 12393 cmdline_parse_token_string_t cmd_mcast_addr_what = 12394 TOKEN_STRING_INITIALIZER(struct cmd_mcast_addr_result, what, 12395 "add#remove"); 12396 cmdline_parse_token_num_t cmd_mcast_addr_portnum = 12397 TOKEN_NUM_INITIALIZER(struct cmd_mcast_addr_result, port_num, UINT16); 12398 cmdline_parse_token_etheraddr_t cmd_mcast_addr_addr = 12399 TOKEN_ETHERADDR_INITIALIZER(struct cmd_mac_addr_result, address); 12400 12401 cmdline_parse_inst_t cmd_mcast_addr = { 12402 .f = cmd_mcast_addr_parsed, 12403 .data = (void *)0, 12404 .help_str = "mcast_addr add|remove <port_id> <mcast_addr>: " 12405 "Add/Remove multicast MAC address on port_id", 12406 .tokens = { 12407 (void *)&cmd_mcast_addr_cmd, 12408 (void *)&cmd_mcast_addr_what, 12409 (void *)&cmd_mcast_addr_portnum, 12410 (void *)&cmd_mcast_addr_addr, 12411 NULL, 12412 }, 12413 }; 12414 12415 /* l2 tunnel config 12416 * only support E-tag now. 12417 */ 12418 12419 /* Ether type config */ 12420 struct cmd_config_l2_tunnel_eth_type_result { 12421 cmdline_fixed_string_t port; 12422 cmdline_fixed_string_t config; 12423 cmdline_fixed_string_t all; 12424 portid_t id; 12425 cmdline_fixed_string_t l2_tunnel; 12426 cmdline_fixed_string_t l2_tunnel_type; 12427 cmdline_fixed_string_t eth_type; 12428 uint16_t eth_type_val; 12429 }; 12430 12431 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port = 12432 TOKEN_STRING_INITIALIZER 12433 (struct cmd_config_l2_tunnel_eth_type_result, 12434 port, "port"); 12435 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config = 12436 TOKEN_STRING_INITIALIZER 12437 (struct cmd_config_l2_tunnel_eth_type_result, 12438 config, "config"); 12439 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str = 12440 TOKEN_STRING_INITIALIZER 12441 (struct cmd_config_l2_tunnel_eth_type_result, 12442 all, "all"); 12443 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id = 12444 TOKEN_NUM_INITIALIZER 12445 (struct cmd_config_l2_tunnel_eth_type_result, 12446 id, UINT16); 12447 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel = 12448 TOKEN_STRING_INITIALIZER 12449 (struct cmd_config_l2_tunnel_eth_type_result, 12450 l2_tunnel, "l2-tunnel"); 12451 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type = 12452 TOKEN_STRING_INITIALIZER 12453 (struct cmd_config_l2_tunnel_eth_type_result, 12454 l2_tunnel_type, "E-tag"); 12455 cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type = 12456 TOKEN_STRING_INITIALIZER 12457 (struct cmd_config_l2_tunnel_eth_type_result, 12458 eth_type, "ether-type"); 12459 cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val = 12460 TOKEN_NUM_INITIALIZER 12461 (struct cmd_config_l2_tunnel_eth_type_result, 12462 eth_type_val, UINT16); 12463 12464 static enum rte_eth_tunnel_type 12465 str2fdir_l2_tunnel_type(char *string) 12466 { 12467 uint32_t i = 0; 12468 12469 static const struct { 12470 char str[32]; 12471 enum rte_eth_tunnel_type type; 12472 } l2_tunnel_type_str[] = { 12473 {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG}, 12474 }; 12475 12476 for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) { 12477 if (!strcmp(l2_tunnel_type_str[i].str, string)) 12478 return l2_tunnel_type_str[i].type; 12479 } 12480 return RTE_TUNNEL_TYPE_NONE; 12481 } 12482 12483 /* ether type config for all ports */ 12484 static void 12485 cmd_config_l2_tunnel_eth_type_all_parsed 12486 (void *parsed_result, 12487 __attribute__((unused)) struct cmdline *cl, 12488 __attribute__((unused)) void *data) 12489 { 12490 struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result; 12491 struct rte_eth_l2_tunnel_conf entry; 12492 portid_t pid; 12493 12494 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12495 entry.ether_type = res->eth_type_val; 12496 12497 RTE_ETH_FOREACH_DEV(pid) { 12498 rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry); 12499 } 12500 } 12501 12502 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = { 12503 .f = cmd_config_l2_tunnel_eth_type_all_parsed, 12504 .data = NULL, 12505 .help_str = "port config all l2-tunnel E-tag ether-type <value>", 12506 .tokens = { 12507 (void *)&cmd_config_l2_tunnel_eth_type_port, 12508 (void *)&cmd_config_l2_tunnel_eth_type_config, 12509 (void *)&cmd_config_l2_tunnel_eth_type_all_str, 12510 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 12511 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 12512 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 12513 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 12514 NULL, 12515 }, 12516 }; 12517 12518 /* ether type config for a specific port */ 12519 static void 12520 cmd_config_l2_tunnel_eth_type_specific_parsed( 12521 void *parsed_result, 12522 __attribute__((unused)) struct cmdline *cl, 12523 __attribute__((unused)) void *data) 12524 { 12525 struct cmd_config_l2_tunnel_eth_type_result *res = 12526 parsed_result; 12527 struct rte_eth_l2_tunnel_conf entry; 12528 12529 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12530 return; 12531 12532 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12533 entry.ether_type = res->eth_type_val; 12534 12535 rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry); 12536 } 12537 12538 cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = { 12539 .f = cmd_config_l2_tunnel_eth_type_specific_parsed, 12540 .data = NULL, 12541 .help_str = "port config <port_id> l2-tunnel E-tag ether-type <value>", 12542 .tokens = { 12543 (void *)&cmd_config_l2_tunnel_eth_type_port, 12544 (void *)&cmd_config_l2_tunnel_eth_type_config, 12545 (void *)&cmd_config_l2_tunnel_eth_type_id, 12546 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, 12547 (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, 12548 (void *)&cmd_config_l2_tunnel_eth_type_eth_type, 12549 (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, 12550 NULL, 12551 }, 12552 }; 12553 12554 /* Enable/disable l2 tunnel */ 12555 struct cmd_config_l2_tunnel_en_dis_result { 12556 cmdline_fixed_string_t port; 12557 cmdline_fixed_string_t config; 12558 cmdline_fixed_string_t all; 12559 portid_t id; 12560 cmdline_fixed_string_t l2_tunnel; 12561 cmdline_fixed_string_t l2_tunnel_type; 12562 cmdline_fixed_string_t en_dis; 12563 }; 12564 12565 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port = 12566 TOKEN_STRING_INITIALIZER 12567 (struct cmd_config_l2_tunnel_en_dis_result, 12568 port, "port"); 12569 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config = 12570 TOKEN_STRING_INITIALIZER 12571 (struct cmd_config_l2_tunnel_en_dis_result, 12572 config, "config"); 12573 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str = 12574 TOKEN_STRING_INITIALIZER 12575 (struct cmd_config_l2_tunnel_en_dis_result, 12576 all, "all"); 12577 cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id = 12578 TOKEN_NUM_INITIALIZER 12579 (struct cmd_config_l2_tunnel_en_dis_result, 12580 id, UINT16); 12581 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel = 12582 TOKEN_STRING_INITIALIZER 12583 (struct cmd_config_l2_tunnel_en_dis_result, 12584 l2_tunnel, "l2-tunnel"); 12585 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type = 12586 TOKEN_STRING_INITIALIZER 12587 (struct cmd_config_l2_tunnel_en_dis_result, 12588 l2_tunnel_type, "E-tag"); 12589 cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis = 12590 TOKEN_STRING_INITIALIZER 12591 (struct cmd_config_l2_tunnel_en_dis_result, 12592 en_dis, "enable#disable"); 12593 12594 /* enable/disable l2 tunnel for all ports */ 12595 static void 12596 cmd_config_l2_tunnel_en_dis_all_parsed( 12597 void *parsed_result, 12598 __attribute__((unused)) struct cmdline *cl, 12599 __attribute__((unused)) void *data) 12600 { 12601 struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result; 12602 struct rte_eth_l2_tunnel_conf entry; 12603 portid_t pid; 12604 uint8_t en; 12605 12606 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12607 12608 if (!strcmp("enable", res->en_dis)) 12609 en = 1; 12610 else 12611 en = 0; 12612 12613 RTE_ETH_FOREACH_DEV(pid) { 12614 rte_eth_dev_l2_tunnel_offload_set(pid, 12615 &entry, 12616 ETH_L2_TUNNEL_ENABLE_MASK, 12617 en); 12618 } 12619 } 12620 12621 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = { 12622 .f = cmd_config_l2_tunnel_en_dis_all_parsed, 12623 .data = NULL, 12624 .help_str = "port config all l2-tunnel E-tag enable|disable", 12625 .tokens = { 12626 (void *)&cmd_config_l2_tunnel_en_dis_port, 12627 (void *)&cmd_config_l2_tunnel_en_dis_config, 12628 (void *)&cmd_config_l2_tunnel_en_dis_all_str, 12629 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12630 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12631 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12632 NULL, 12633 }, 12634 }; 12635 12636 /* enable/disable l2 tunnel for a port */ 12637 static void 12638 cmd_config_l2_tunnel_en_dis_specific_parsed( 12639 void *parsed_result, 12640 __attribute__((unused)) struct cmdline *cl, 12641 __attribute__((unused)) void *data) 12642 { 12643 struct cmd_config_l2_tunnel_en_dis_result *res = 12644 parsed_result; 12645 struct rte_eth_l2_tunnel_conf entry; 12646 12647 if (port_id_is_invalid(res->id, ENABLED_WARN)) 12648 return; 12649 12650 entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); 12651 12652 if (!strcmp("enable", res->en_dis)) 12653 rte_eth_dev_l2_tunnel_offload_set(res->id, 12654 &entry, 12655 ETH_L2_TUNNEL_ENABLE_MASK, 12656 1); 12657 else 12658 rte_eth_dev_l2_tunnel_offload_set(res->id, 12659 &entry, 12660 ETH_L2_TUNNEL_ENABLE_MASK, 12661 0); 12662 } 12663 12664 cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = { 12665 .f = cmd_config_l2_tunnel_en_dis_specific_parsed, 12666 .data = NULL, 12667 .help_str = "port config <port_id> l2-tunnel E-tag enable|disable", 12668 .tokens = { 12669 (void *)&cmd_config_l2_tunnel_en_dis_port, 12670 (void *)&cmd_config_l2_tunnel_en_dis_config, 12671 (void *)&cmd_config_l2_tunnel_en_dis_id, 12672 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, 12673 (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, 12674 (void *)&cmd_config_l2_tunnel_en_dis_en_dis, 12675 NULL, 12676 }, 12677 }; 12678 12679 /* E-tag configuration */ 12680 12681 /* Common result structure for all E-tag configuration */ 12682 struct cmd_config_e_tag_result { 12683 cmdline_fixed_string_t e_tag; 12684 cmdline_fixed_string_t set; 12685 cmdline_fixed_string_t insertion; 12686 cmdline_fixed_string_t stripping; 12687 cmdline_fixed_string_t forwarding; 12688 cmdline_fixed_string_t filter; 12689 cmdline_fixed_string_t add; 12690 cmdline_fixed_string_t del; 12691 cmdline_fixed_string_t on; 12692 cmdline_fixed_string_t off; 12693 cmdline_fixed_string_t on_off; 12694 cmdline_fixed_string_t port_tag_id; 12695 uint32_t port_tag_id_val; 12696 cmdline_fixed_string_t e_tag_id; 12697 uint16_t e_tag_id_val; 12698 cmdline_fixed_string_t dst_pool; 12699 uint8_t dst_pool_val; 12700 cmdline_fixed_string_t port; 12701 portid_t port_id; 12702 cmdline_fixed_string_t vf; 12703 uint8_t vf_id; 12704 }; 12705 12706 /* Common CLI fields for all E-tag configuration */ 12707 cmdline_parse_token_string_t cmd_config_e_tag_e_tag = 12708 TOKEN_STRING_INITIALIZER 12709 (struct cmd_config_e_tag_result, 12710 e_tag, "E-tag"); 12711 cmdline_parse_token_string_t cmd_config_e_tag_set = 12712 TOKEN_STRING_INITIALIZER 12713 (struct cmd_config_e_tag_result, 12714 set, "set"); 12715 cmdline_parse_token_string_t cmd_config_e_tag_insertion = 12716 TOKEN_STRING_INITIALIZER 12717 (struct cmd_config_e_tag_result, 12718 insertion, "insertion"); 12719 cmdline_parse_token_string_t cmd_config_e_tag_stripping = 12720 TOKEN_STRING_INITIALIZER 12721 (struct cmd_config_e_tag_result, 12722 stripping, "stripping"); 12723 cmdline_parse_token_string_t cmd_config_e_tag_forwarding = 12724 TOKEN_STRING_INITIALIZER 12725 (struct cmd_config_e_tag_result, 12726 forwarding, "forwarding"); 12727 cmdline_parse_token_string_t cmd_config_e_tag_filter = 12728 TOKEN_STRING_INITIALIZER 12729 (struct cmd_config_e_tag_result, 12730 filter, "filter"); 12731 cmdline_parse_token_string_t cmd_config_e_tag_add = 12732 TOKEN_STRING_INITIALIZER 12733 (struct cmd_config_e_tag_result, 12734 add, "add"); 12735 cmdline_parse_token_string_t cmd_config_e_tag_del = 12736 TOKEN_STRING_INITIALIZER 12737 (struct cmd_config_e_tag_result, 12738 del, "del"); 12739 cmdline_parse_token_string_t cmd_config_e_tag_on = 12740 TOKEN_STRING_INITIALIZER 12741 (struct cmd_config_e_tag_result, 12742 on, "on"); 12743 cmdline_parse_token_string_t cmd_config_e_tag_off = 12744 TOKEN_STRING_INITIALIZER 12745 (struct cmd_config_e_tag_result, 12746 off, "off"); 12747 cmdline_parse_token_string_t cmd_config_e_tag_on_off = 12748 TOKEN_STRING_INITIALIZER 12749 (struct cmd_config_e_tag_result, 12750 on_off, "on#off"); 12751 cmdline_parse_token_string_t cmd_config_e_tag_port_tag_id = 12752 TOKEN_STRING_INITIALIZER 12753 (struct cmd_config_e_tag_result, 12754 port_tag_id, "port-tag-id"); 12755 cmdline_parse_token_num_t cmd_config_e_tag_port_tag_id_val = 12756 TOKEN_NUM_INITIALIZER 12757 (struct cmd_config_e_tag_result, 12758 port_tag_id_val, UINT32); 12759 cmdline_parse_token_string_t cmd_config_e_tag_e_tag_id = 12760 TOKEN_STRING_INITIALIZER 12761 (struct cmd_config_e_tag_result, 12762 e_tag_id, "e-tag-id"); 12763 cmdline_parse_token_num_t cmd_config_e_tag_e_tag_id_val = 12764 TOKEN_NUM_INITIALIZER 12765 (struct cmd_config_e_tag_result, 12766 e_tag_id_val, UINT16); 12767 cmdline_parse_token_string_t cmd_config_e_tag_dst_pool = 12768 TOKEN_STRING_INITIALIZER 12769 (struct cmd_config_e_tag_result, 12770 dst_pool, "dst-pool"); 12771 cmdline_parse_token_num_t cmd_config_e_tag_dst_pool_val = 12772 TOKEN_NUM_INITIALIZER 12773 (struct cmd_config_e_tag_result, 12774 dst_pool_val, UINT8); 12775 cmdline_parse_token_string_t cmd_config_e_tag_port = 12776 TOKEN_STRING_INITIALIZER 12777 (struct cmd_config_e_tag_result, 12778 port, "port"); 12779 cmdline_parse_token_num_t cmd_config_e_tag_port_id = 12780 TOKEN_NUM_INITIALIZER 12781 (struct cmd_config_e_tag_result, 12782 port_id, UINT16); 12783 cmdline_parse_token_string_t cmd_config_e_tag_vf = 12784 TOKEN_STRING_INITIALIZER 12785 (struct cmd_config_e_tag_result, 12786 vf, "vf"); 12787 cmdline_parse_token_num_t cmd_config_e_tag_vf_id = 12788 TOKEN_NUM_INITIALIZER 12789 (struct cmd_config_e_tag_result, 12790 vf_id, UINT8); 12791 12792 /* E-tag insertion configuration */ 12793 static void 12794 cmd_config_e_tag_insertion_en_parsed( 12795 void *parsed_result, 12796 __attribute__((unused)) struct cmdline *cl, 12797 __attribute__((unused)) void *data) 12798 { 12799 struct cmd_config_e_tag_result *res = 12800 parsed_result; 12801 struct rte_eth_l2_tunnel_conf entry; 12802 12803 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12804 return; 12805 12806 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12807 entry.tunnel_id = res->port_tag_id_val; 12808 entry.vf_id = res->vf_id; 12809 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 12810 &entry, 12811 ETH_L2_TUNNEL_INSERTION_MASK, 12812 1); 12813 } 12814 12815 static void 12816 cmd_config_e_tag_insertion_dis_parsed( 12817 void *parsed_result, 12818 __attribute__((unused)) struct cmdline *cl, 12819 __attribute__((unused)) void *data) 12820 { 12821 struct cmd_config_e_tag_result *res = 12822 parsed_result; 12823 struct rte_eth_l2_tunnel_conf entry; 12824 12825 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12826 return; 12827 12828 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12829 entry.vf_id = res->vf_id; 12830 12831 rte_eth_dev_l2_tunnel_offload_set(res->port_id, 12832 &entry, 12833 ETH_L2_TUNNEL_INSERTION_MASK, 12834 0); 12835 } 12836 12837 cmdline_parse_inst_t cmd_config_e_tag_insertion_en = { 12838 .f = cmd_config_e_tag_insertion_en_parsed, 12839 .data = NULL, 12840 .help_str = "E-tag ... : E-tag insertion enable", 12841 .tokens = { 12842 (void *)&cmd_config_e_tag_e_tag, 12843 (void *)&cmd_config_e_tag_set, 12844 (void *)&cmd_config_e_tag_insertion, 12845 (void *)&cmd_config_e_tag_on, 12846 (void *)&cmd_config_e_tag_port_tag_id, 12847 (void *)&cmd_config_e_tag_port_tag_id_val, 12848 (void *)&cmd_config_e_tag_port, 12849 (void *)&cmd_config_e_tag_port_id, 12850 (void *)&cmd_config_e_tag_vf, 12851 (void *)&cmd_config_e_tag_vf_id, 12852 NULL, 12853 }, 12854 }; 12855 12856 cmdline_parse_inst_t cmd_config_e_tag_insertion_dis = { 12857 .f = cmd_config_e_tag_insertion_dis_parsed, 12858 .data = NULL, 12859 .help_str = "E-tag ... : E-tag insertion disable", 12860 .tokens = { 12861 (void *)&cmd_config_e_tag_e_tag, 12862 (void *)&cmd_config_e_tag_set, 12863 (void *)&cmd_config_e_tag_insertion, 12864 (void *)&cmd_config_e_tag_off, 12865 (void *)&cmd_config_e_tag_port, 12866 (void *)&cmd_config_e_tag_port_id, 12867 (void *)&cmd_config_e_tag_vf, 12868 (void *)&cmd_config_e_tag_vf_id, 12869 NULL, 12870 }, 12871 }; 12872 12873 /* E-tag stripping configuration */ 12874 static void 12875 cmd_config_e_tag_stripping_parsed( 12876 void *parsed_result, 12877 __attribute__((unused)) struct cmdline *cl, 12878 __attribute__((unused)) void *data) 12879 { 12880 struct cmd_config_e_tag_result *res = 12881 parsed_result; 12882 struct rte_eth_l2_tunnel_conf entry; 12883 12884 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12885 return; 12886 12887 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12888 12889 if (!strcmp(res->on_off, "on")) 12890 rte_eth_dev_l2_tunnel_offload_set 12891 (res->port_id, 12892 &entry, 12893 ETH_L2_TUNNEL_STRIPPING_MASK, 12894 1); 12895 else 12896 rte_eth_dev_l2_tunnel_offload_set 12897 (res->port_id, 12898 &entry, 12899 ETH_L2_TUNNEL_STRIPPING_MASK, 12900 0); 12901 } 12902 12903 cmdline_parse_inst_t cmd_config_e_tag_stripping_en_dis = { 12904 .f = cmd_config_e_tag_stripping_parsed, 12905 .data = NULL, 12906 .help_str = "E-tag ... : E-tag stripping enable/disable", 12907 .tokens = { 12908 (void *)&cmd_config_e_tag_e_tag, 12909 (void *)&cmd_config_e_tag_set, 12910 (void *)&cmd_config_e_tag_stripping, 12911 (void *)&cmd_config_e_tag_on_off, 12912 (void *)&cmd_config_e_tag_port, 12913 (void *)&cmd_config_e_tag_port_id, 12914 NULL, 12915 }, 12916 }; 12917 12918 /* E-tag forwarding configuration */ 12919 static void 12920 cmd_config_e_tag_forwarding_parsed( 12921 void *parsed_result, 12922 __attribute__((unused)) struct cmdline *cl, 12923 __attribute__((unused)) void *data) 12924 { 12925 struct cmd_config_e_tag_result *res = parsed_result; 12926 struct rte_eth_l2_tunnel_conf entry; 12927 12928 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12929 return; 12930 12931 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12932 12933 if (!strcmp(res->on_off, "on")) 12934 rte_eth_dev_l2_tunnel_offload_set 12935 (res->port_id, 12936 &entry, 12937 ETH_L2_TUNNEL_FORWARDING_MASK, 12938 1); 12939 else 12940 rte_eth_dev_l2_tunnel_offload_set 12941 (res->port_id, 12942 &entry, 12943 ETH_L2_TUNNEL_FORWARDING_MASK, 12944 0); 12945 } 12946 12947 cmdline_parse_inst_t cmd_config_e_tag_forwarding_en_dis = { 12948 .f = cmd_config_e_tag_forwarding_parsed, 12949 .data = NULL, 12950 .help_str = "E-tag ... : E-tag forwarding enable/disable", 12951 .tokens = { 12952 (void *)&cmd_config_e_tag_e_tag, 12953 (void *)&cmd_config_e_tag_set, 12954 (void *)&cmd_config_e_tag_forwarding, 12955 (void *)&cmd_config_e_tag_on_off, 12956 (void *)&cmd_config_e_tag_port, 12957 (void *)&cmd_config_e_tag_port_id, 12958 NULL, 12959 }, 12960 }; 12961 12962 /* E-tag filter configuration */ 12963 static void 12964 cmd_config_e_tag_filter_add_parsed( 12965 void *parsed_result, 12966 __attribute__((unused)) struct cmdline *cl, 12967 __attribute__((unused)) void *data) 12968 { 12969 struct cmd_config_e_tag_result *res = parsed_result; 12970 struct rte_eth_l2_tunnel_conf entry; 12971 int ret = 0; 12972 12973 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 12974 return; 12975 12976 if (res->e_tag_id_val > 0x3fff) { 12977 printf("e-tag-id must be equal or less than 0x3fff.\n"); 12978 return; 12979 } 12980 12981 ret = rte_eth_dev_filter_supported(res->port_id, 12982 RTE_ETH_FILTER_L2_TUNNEL); 12983 if (ret < 0) { 12984 printf("E-tag filter is not supported on port %u.\n", 12985 res->port_id); 12986 return; 12987 } 12988 12989 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 12990 entry.tunnel_id = res->e_tag_id_val; 12991 entry.pool = res->dst_pool_val; 12992 12993 ret = rte_eth_dev_filter_ctrl(res->port_id, 12994 RTE_ETH_FILTER_L2_TUNNEL, 12995 RTE_ETH_FILTER_ADD, 12996 &entry); 12997 if (ret < 0) 12998 printf("E-tag filter programming error: (%s)\n", 12999 strerror(-ret)); 13000 } 13001 13002 cmdline_parse_inst_t cmd_config_e_tag_filter_add = { 13003 .f = cmd_config_e_tag_filter_add_parsed, 13004 .data = NULL, 13005 .help_str = "E-tag ... : E-tag filter add", 13006 .tokens = { 13007 (void *)&cmd_config_e_tag_e_tag, 13008 (void *)&cmd_config_e_tag_set, 13009 (void *)&cmd_config_e_tag_filter, 13010 (void *)&cmd_config_e_tag_add, 13011 (void *)&cmd_config_e_tag_e_tag_id, 13012 (void *)&cmd_config_e_tag_e_tag_id_val, 13013 (void *)&cmd_config_e_tag_dst_pool, 13014 (void *)&cmd_config_e_tag_dst_pool_val, 13015 (void *)&cmd_config_e_tag_port, 13016 (void *)&cmd_config_e_tag_port_id, 13017 NULL, 13018 }, 13019 }; 13020 13021 static void 13022 cmd_config_e_tag_filter_del_parsed( 13023 void *parsed_result, 13024 __attribute__((unused)) struct cmdline *cl, 13025 __attribute__((unused)) void *data) 13026 { 13027 struct cmd_config_e_tag_result *res = parsed_result; 13028 struct rte_eth_l2_tunnel_conf entry; 13029 int ret = 0; 13030 13031 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13032 return; 13033 13034 if (res->e_tag_id_val > 0x3fff) { 13035 printf("e-tag-id must be less than 0x3fff.\n"); 13036 return; 13037 } 13038 13039 ret = rte_eth_dev_filter_supported(res->port_id, 13040 RTE_ETH_FILTER_L2_TUNNEL); 13041 if (ret < 0) { 13042 printf("E-tag filter is not supported on port %u.\n", 13043 res->port_id); 13044 return; 13045 } 13046 13047 entry.l2_tunnel_type = RTE_L2_TUNNEL_TYPE_E_TAG; 13048 entry.tunnel_id = res->e_tag_id_val; 13049 13050 ret = rte_eth_dev_filter_ctrl(res->port_id, 13051 RTE_ETH_FILTER_L2_TUNNEL, 13052 RTE_ETH_FILTER_DELETE, 13053 &entry); 13054 if (ret < 0) 13055 printf("E-tag filter programming error: (%s)\n", 13056 strerror(-ret)); 13057 } 13058 13059 cmdline_parse_inst_t cmd_config_e_tag_filter_del = { 13060 .f = cmd_config_e_tag_filter_del_parsed, 13061 .data = NULL, 13062 .help_str = "E-tag ... : E-tag filter delete", 13063 .tokens = { 13064 (void *)&cmd_config_e_tag_e_tag, 13065 (void *)&cmd_config_e_tag_set, 13066 (void *)&cmd_config_e_tag_filter, 13067 (void *)&cmd_config_e_tag_del, 13068 (void *)&cmd_config_e_tag_e_tag_id, 13069 (void *)&cmd_config_e_tag_e_tag_id_val, 13070 (void *)&cmd_config_e_tag_port, 13071 (void *)&cmd_config_e_tag_port_id, 13072 NULL, 13073 }, 13074 }; 13075 13076 /* vf vlan anti spoof configuration */ 13077 13078 /* Common result structure for vf vlan anti spoof */ 13079 struct cmd_vf_vlan_anti_spoof_result { 13080 cmdline_fixed_string_t set; 13081 cmdline_fixed_string_t vf; 13082 cmdline_fixed_string_t vlan; 13083 cmdline_fixed_string_t antispoof; 13084 portid_t port_id; 13085 uint32_t vf_id; 13086 cmdline_fixed_string_t on_off; 13087 }; 13088 13089 /* Common CLI fields for vf vlan anti spoof enable disable */ 13090 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set = 13091 TOKEN_STRING_INITIALIZER 13092 (struct cmd_vf_vlan_anti_spoof_result, 13093 set, "set"); 13094 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf = 13095 TOKEN_STRING_INITIALIZER 13096 (struct cmd_vf_vlan_anti_spoof_result, 13097 vf, "vf"); 13098 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan = 13099 TOKEN_STRING_INITIALIZER 13100 (struct cmd_vf_vlan_anti_spoof_result, 13101 vlan, "vlan"); 13102 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof = 13103 TOKEN_STRING_INITIALIZER 13104 (struct cmd_vf_vlan_anti_spoof_result, 13105 antispoof, "antispoof"); 13106 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id = 13107 TOKEN_NUM_INITIALIZER 13108 (struct cmd_vf_vlan_anti_spoof_result, 13109 port_id, UINT16); 13110 cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id = 13111 TOKEN_NUM_INITIALIZER 13112 (struct cmd_vf_vlan_anti_spoof_result, 13113 vf_id, UINT32); 13114 cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off = 13115 TOKEN_STRING_INITIALIZER 13116 (struct cmd_vf_vlan_anti_spoof_result, 13117 on_off, "on#off"); 13118 13119 static void 13120 cmd_set_vf_vlan_anti_spoof_parsed( 13121 void *parsed_result, 13122 __attribute__((unused)) struct cmdline *cl, 13123 __attribute__((unused)) void *data) 13124 { 13125 struct cmd_vf_vlan_anti_spoof_result *res = parsed_result; 13126 int ret = -ENOTSUP; 13127 13128 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13129 13130 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13131 return; 13132 13133 #ifdef RTE_LIBRTE_IXGBE_PMD 13134 if (ret == -ENOTSUP) 13135 ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, 13136 res->vf_id, is_on); 13137 #endif 13138 #ifdef RTE_LIBRTE_I40E_PMD 13139 if (ret == -ENOTSUP) 13140 ret = rte_pmd_i40e_set_vf_vlan_anti_spoof(res->port_id, 13141 res->vf_id, is_on); 13142 #endif 13143 #ifdef RTE_LIBRTE_BNXT_PMD 13144 if (ret == -ENOTSUP) 13145 ret = rte_pmd_bnxt_set_vf_vlan_anti_spoof(res->port_id, 13146 res->vf_id, is_on); 13147 #endif 13148 13149 switch (ret) { 13150 case 0: 13151 break; 13152 case -EINVAL: 13153 printf("invalid vf_id %d\n", res->vf_id); 13154 break; 13155 case -ENODEV: 13156 printf("invalid port_id %d\n", res->port_id); 13157 break; 13158 case -ENOTSUP: 13159 printf("function not implemented\n"); 13160 break; 13161 default: 13162 printf("programming error: (%s)\n", strerror(-ret)); 13163 } 13164 } 13165 13166 cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = { 13167 .f = cmd_set_vf_vlan_anti_spoof_parsed, 13168 .data = NULL, 13169 .help_str = "set vf vlan antispoof <port_id> <vf_id> on|off", 13170 .tokens = { 13171 (void *)&cmd_vf_vlan_anti_spoof_set, 13172 (void *)&cmd_vf_vlan_anti_spoof_vf, 13173 (void *)&cmd_vf_vlan_anti_spoof_vlan, 13174 (void *)&cmd_vf_vlan_anti_spoof_antispoof, 13175 (void *)&cmd_vf_vlan_anti_spoof_port_id, 13176 (void *)&cmd_vf_vlan_anti_spoof_vf_id, 13177 (void *)&cmd_vf_vlan_anti_spoof_on_off, 13178 NULL, 13179 }, 13180 }; 13181 13182 /* vf mac anti spoof configuration */ 13183 13184 /* Common result structure for vf mac anti spoof */ 13185 struct cmd_vf_mac_anti_spoof_result { 13186 cmdline_fixed_string_t set; 13187 cmdline_fixed_string_t vf; 13188 cmdline_fixed_string_t mac; 13189 cmdline_fixed_string_t antispoof; 13190 portid_t port_id; 13191 uint32_t vf_id; 13192 cmdline_fixed_string_t on_off; 13193 }; 13194 13195 /* Common CLI fields for vf mac anti spoof enable disable */ 13196 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set = 13197 TOKEN_STRING_INITIALIZER 13198 (struct cmd_vf_mac_anti_spoof_result, 13199 set, "set"); 13200 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf = 13201 TOKEN_STRING_INITIALIZER 13202 (struct cmd_vf_mac_anti_spoof_result, 13203 vf, "vf"); 13204 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac = 13205 TOKEN_STRING_INITIALIZER 13206 (struct cmd_vf_mac_anti_spoof_result, 13207 mac, "mac"); 13208 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof = 13209 TOKEN_STRING_INITIALIZER 13210 (struct cmd_vf_mac_anti_spoof_result, 13211 antispoof, "antispoof"); 13212 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id = 13213 TOKEN_NUM_INITIALIZER 13214 (struct cmd_vf_mac_anti_spoof_result, 13215 port_id, UINT16); 13216 cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id = 13217 TOKEN_NUM_INITIALIZER 13218 (struct cmd_vf_mac_anti_spoof_result, 13219 vf_id, UINT32); 13220 cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off = 13221 TOKEN_STRING_INITIALIZER 13222 (struct cmd_vf_mac_anti_spoof_result, 13223 on_off, "on#off"); 13224 13225 static void 13226 cmd_set_vf_mac_anti_spoof_parsed( 13227 void *parsed_result, 13228 __attribute__((unused)) struct cmdline *cl, 13229 __attribute__((unused)) void *data) 13230 { 13231 struct cmd_vf_mac_anti_spoof_result *res = parsed_result; 13232 int ret = -ENOTSUP; 13233 13234 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13235 13236 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13237 return; 13238 13239 #ifdef RTE_LIBRTE_IXGBE_PMD 13240 if (ret == -ENOTSUP) 13241 ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, 13242 res->vf_id, is_on); 13243 #endif 13244 #ifdef RTE_LIBRTE_I40E_PMD 13245 if (ret == -ENOTSUP) 13246 ret = rte_pmd_i40e_set_vf_mac_anti_spoof(res->port_id, 13247 res->vf_id, is_on); 13248 #endif 13249 #ifdef RTE_LIBRTE_BNXT_PMD 13250 if (ret == -ENOTSUP) 13251 ret = rte_pmd_bnxt_set_vf_mac_anti_spoof(res->port_id, 13252 res->vf_id, is_on); 13253 #endif 13254 13255 switch (ret) { 13256 case 0: 13257 break; 13258 case -EINVAL: 13259 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13260 break; 13261 case -ENODEV: 13262 printf("invalid port_id %d\n", res->port_id); 13263 break; 13264 case -ENOTSUP: 13265 printf("function not implemented\n"); 13266 break; 13267 default: 13268 printf("programming error: (%s)\n", strerror(-ret)); 13269 } 13270 } 13271 13272 cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = { 13273 .f = cmd_set_vf_mac_anti_spoof_parsed, 13274 .data = NULL, 13275 .help_str = "set vf mac antispoof <port_id> <vf_id> on|off", 13276 .tokens = { 13277 (void *)&cmd_vf_mac_anti_spoof_set, 13278 (void *)&cmd_vf_mac_anti_spoof_vf, 13279 (void *)&cmd_vf_mac_anti_spoof_mac, 13280 (void *)&cmd_vf_mac_anti_spoof_antispoof, 13281 (void *)&cmd_vf_mac_anti_spoof_port_id, 13282 (void *)&cmd_vf_mac_anti_spoof_vf_id, 13283 (void *)&cmd_vf_mac_anti_spoof_on_off, 13284 NULL, 13285 }, 13286 }; 13287 13288 /* vf vlan strip queue configuration */ 13289 13290 /* Common result structure for vf mac anti spoof */ 13291 struct cmd_vf_vlan_stripq_result { 13292 cmdline_fixed_string_t set; 13293 cmdline_fixed_string_t vf; 13294 cmdline_fixed_string_t vlan; 13295 cmdline_fixed_string_t stripq; 13296 portid_t port_id; 13297 uint16_t vf_id; 13298 cmdline_fixed_string_t on_off; 13299 }; 13300 13301 /* Common CLI fields for vf vlan strip enable disable */ 13302 cmdline_parse_token_string_t cmd_vf_vlan_stripq_set = 13303 TOKEN_STRING_INITIALIZER 13304 (struct cmd_vf_vlan_stripq_result, 13305 set, "set"); 13306 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf = 13307 TOKEN_STRING_INITIALIZER 13308 (struct cmd_vf_vlan_stripq_result, 13309 vf, "vf"); 13310 cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan = 13311 TOKEN_STRING_INITIALIZER 13312 (struct cmd_vf_vlan_stripq_result, 13313 vlan, "vlan"); 13314 cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq = 13315 TOKEN_STRING_INITIALIZER 13316 (struct cmd_vf_vlan_stripq_result, 13317 stripq, "stripq"); 13318 cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id = 13319 TOKEN_NUM_INITIALIZER 13320 (struct cmd_vf_vlan_stripq_result, 13321 port_id, UINT16); 13322 cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id = 13323 TOKEN_NUM_INITIALIZER 13324 (struct cmd_vf_vlan_stripq_result, 13325 vf_id, UINT16); 13326 cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off = 13327 TOKEN_STRING_INITIALIZER 13328 (struct cmd_vf_vlan_stripq_result, 13329 on_off, "on#off"); 13330 13331 static void 13332 cmd_set_vf_vlan_stripq_parsed( 13333 void *parsed_result, 13334 __attribute__((unused)) struct cmdline *cl, 13335 __attribute__((unused)) void *data) 13336 { 13337 struct cmd_vf_vlan_stripq_result *res = parsed_result; 13338 int ret = -ENOTSUP; 13339 13340 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13341 13342 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13343 return; 13344 13345 #ifdef RTE_LIBRTE_IXGBE_PMD 13346 if (ret == -ENOTSUP) 13347 ret = rte_pmd_ixgbe_set_vf_vlan_stripq(res->port_id, 13348 res->vf_id, is_on); 13349 #endif 13350 #ifdef RTE_LIBRTE_I40E_PMD 13351 if (ret == -ENOTSUP) 13352 ret = rte_pmd_i40e_set_vf_vlan_stripq(res->port_id, 13353 res->vf_id, is_on); 13354 #endif 13355 #ifdef RTE_LIBRTE_BNXT_PMD 13356 if (ret == -ENOTSUP) 13357 ret = rte_pmd_bnxt_set_vf_vlan_stripq(res->port_id, 13358 res->vf_id, is_on); 13359 #endif 13360 13361 switch (ret) { 13362 case 0: 13363 break; 13364 case -EINVAL: 13365 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13366 break; 13367 case -ENODEV: 13368 printf("invalid port_id %d\n", res->port_id); 13369 break; 13370 case -ENOTSUP: 13371 printf("function not implemented\n"); 13372 break; 13373 default: 13374 printf("programming error: (%s)\n", strerror(-ret)); 13375 } 13376 } 13377 13378 cmdline_parse_inst_t cmd_set_vf_vlan_stripq = { 13379 .f = cmd_set_vf_vlan_stripq_parsed, 13380 .data = NULL, 13381 .help_str = "set vf vlan stripq <port_id> <vf_id> on|off", 13382 .tokens = { 13383 (void *)&cmd_vf_vlan_stripq_set, 13384 (void *)&cmd_vf_vlan_stripq_vf, 13385 (void *)&cmd_vf_vlan_stripq_vlan, 13386 (void *)&cmd_vf_vlan_stripq_stripq, 13387 (void *)&cmd_vf_vlan_stripq_port_id, 13388 (void *)&cmd_vf_vlan_stripq_vf_id, 13389 (void *)&cmd_vf_vlan_stripq_on_off, 13390 NULL, 13391 }, 13392 }; 13393 13394 /* vf vlan insert configuration */ 13395 13396 /* Common result structure for vf vlan insert */ 13397 struct cmd_vf_vlan_insert_result { 13398 cmdline_fixed_string_t set; 13399 cmdline_fixed_string_t vf; 13400 cmdline_fixed_string_t vlan; 13401 cmdline_fixed_string_t insert; 13402 portid_t port_id; 13403 uint16_t vf_id; 13404 uint16_t vlan_id; 13405 }; 13406 13407 /* Common CLI fields for vf vlan insert enable disable */ 13408 cmdline_parse_token_string_t cmd_vf_vlan_insert_set = 13409 TOKEN_STRING_INITIALIZER 13410 (struct cmd_vf_vlan_insert_result, 13411 set, "set"); 13412 cmdline_parse_token_string_t cmd_vf_vlan_insert_vf = 13413 TOKEN_STRING_INITIALIZER 13414 (struct cmd_vf_vlan_insert_result, 13415 vf, "vf"); 13416 cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan = 13417 TOKEN_STRING_INITIALIZER 13418 (struct cmd_vf_vlan_insert_result, 13419 vlan, "vlan"); 13420 cmdline_parse_token_string_t cmd_vf_vlan_insert_insert = 13421 TOKEN_STRING_INITIALIZER 13422 (struct cmd_vf_vlan_insert_result, 13423 insert, "insert"); 13424 cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id = 13425 TOKEN_NUM_INITIALIZER 13426 (struct cmd_vf_vlan_insert_result, 13427 port_id, UINT16); 13428 cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id = 13429 TOKEN_NUM_INITIALIZER 13430 (struct cmd_vf_vlan_insert_result, 13431 vf_id, UINT16); 13432 cmdline_parse_token_num_t cmd_vf_vlan_insert_vlan_id = 13433 TOKEN_NUM_INITIALIZER 13434 (struct cmd_vf_vlan_insert_result, 13435 vlan_id, UINT16); 13436 13437 static void 13438 cmd_set_vf_vlan_insert_parsed( 13439 void *parsed_result, 13440 __attribute__((unused)) struct cmdline *cl, 13441 __attribute__((unused)) void *data) 13442 { 13443 struct cmd_vf_vlan_insert_result *res = parsed_result; 13444 int ret = -ENOTSUP; 13445 13446 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13447 return; 13448 13449 #ifdef RTE_LIBRTE_IXGBE_PMD 13450 if (ret == -ENOTSUP) 13451 ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, 13452 res->vlan_id); 13453 #endif 13454 #ifdef RTE_LIBRTE_I40E_PMD 13455 if (ret == -ENOTSUP) 13456 ret = rte_pmd_i40e_set_vf_vlan_insert(res->port_id, res->vf_id, 13457 res->vlan_id); 13458 #endif 13459 #ifdef RTE_LIBRTE_BNXT_PMD 13460 if (ret == -ENOTSUP) 13461 ret = rte_pmd_bnxt_set_vf_vlan_insert(res->port_id, res->vf_id, 13462 res->vlan_id); 13463 #endif 13464 13465 switch (ret) { 13466 case 0: 13467 break; 13468 case -EINVAL: 13469 printf("invalid vf_id %d or vlan_id %d\n", res->vf_id, res->vlan_id); 13470 break; 13471 case -ENODEV: 13472 printf("invalid port_id %d\n", res->port_id); 13473 break; 13474 case -ENOTSUP: 13475 printf("function not implemented\n"); 13476 break; 13477 default: 13478 printf("programming error: (%s)\n", strerror(-ret)); 13479 } 13480 } 13481 13482 cmdline_parse_inst_t cmd_set_vf_vlan_insert = { 13483 .f = cmd_set_vf_vlan_insert_parsed, 13484 .data = NULL, 13485 .help_str = "set vf vlan insert <port_id> <vf_id> <vlan_id>", 13486 .tokens = { 13487 (void *)&cmd_vf_vlan_insert_set, 13488 (void *)&cmd_vf_vlan_insert_vf, 13489 (void *)&cmd_vf_vlan_insert_vlan, 13490 (void *)&cmd_vf_vlan_insert_insert, 13491 (void *)&cmd_vf_vlan_insert_port_id, 13492 (void *)&cmd_vf_vlan_insert_vf_id, 13493 (void *)&cmd_vf_vlan_insert_vlan_id, 13494 NULL, 13495 }, 13496 }; 13497 13498 /* tx loopback configuration */ 13499 13500 /* Common result structure for tx loopback */ 13501 struct cmd_tx_loopback_result { 13502 cmdline_fixed_string_t set; 13503 cmdline_fixed_string_t tx; 13504 cmdline_fixed_string_t loopback; 13505 portid_t port_id; 13506 cmdline_fixed_string_t on_off; 13507 }; 13508 13509 /* Common CLI fields for tx loopback enable disable */ 13510 cmdline_parse_token_string_t cmd_tx_loopback_set = 13511 TOKEN_STRING_INITIALIZER 13512 (struct cmd_tx_loopback_result, 13513 set, "set"); 13514 cmdline_parse_token_string_t cmd_tx_loopback_tx = 13515 TOKEN_STRING_INITIALIZER 13516 (struct cmd_tx_loopback_result, 13517 tx, "tx"); 13518 cmdline_parse_token_string_t cmd_tx_loopback_loopback = 13519 TOKEN_STRING_INITIALIZER 13520 (struct cmd_tx_loopback_result, 13521 loopback, "loopback"); 13522 cmdline_parse_token_num_t cmd_tx_loopback_port_id = 13523 TOKEN_NUM_INITIALIZER 13524 (struct cmd_tx_loopback_result, 13525 port_id, UINT16); 13526 cmdline_parse_token_string_t cmd_tx_loopback_on_off = 13527 TOKEN_STRING_INITIALIZER 13528 (struct cmd_tx_loopback_result, 13529 on_off, "on#off"); 13530 13531 static void 13532 cmd_set_tx_loopback_parsed( 13533 void *parsed_result, 13534 __attribute__((unused)) struct cmdline *cl, 13535 __attribute__((unused)) void *data) 13536 { 13537 struct cmd_tx_loopback_result *res = parsed_result; 13538 int ret = -ENOTSUP; 13539 13540 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13541 13542 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13543 return; 13544 13545 #ifdef RTE_LIBRTE_IXGBE_PMD 13546 if (ret == -ENOTSUP) 13547 ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on); 13548 #endif 13549 #ifdef RTE_LIBRTE_I40E_PMD 13550 if (ret == -ENOTSUP) 13551 ret = rte_pmd_i40e_set_tx_loopback(res->port_id, is_on); 13552 #endif 13553 #ifdef RTE_LIBRTE_BNXT_PMD 13554 if (ret == -ENOTSUP) 13555 ret = rte_pmd_bnxt_set_tx_loopback(res->port_id, is_on); 13556 #endif 13557 #if defined RTE_LIBRTE_DPAA_BUS && defined RTE_LIBRTE_DPAA_PMD 13558 if (ret == -ENOTSUP) 13559 ret = rte_pmd_dpaa_set_tx_loopback(res->port_id, is_on); 13560 #endif 13561 13562 switch (ret) { 13563 case 0: 13564 break; 13565 case -EINVAL: 13566 printf("invalid is_on %d\n", is_on); 13567 break; 13568 case -ENODEV: 13569 printf("invalid port_id %d\n", res->port_id); 13570 break; 13571 case -ENOTSUP: 13572 printf("function not implemented\n"); 13573 break; 13574 default: 13575 printf("programming error: (%s)\n", strerror(-ret)); 13576 } 13577 } 13578 13579 cmdline_parse_inst_t cmd_set_tx_loopback = { 13580 .f = cmd_set_tx_loopback_parsed, 13581 .data = NULL, 13582 .help_str = "set tx loopback <port_id> on|off", 13583 .tokens = { 13584 (void *)&cmd_tx_loopback_set, 13585 (void *)&cmd_tx_loopback_tx, 13586 (void *)&cmd_tx_loopback_loopback, 13587 (void *)&cmd_tx_loopback_port_id, 13588 (void *)&cmd_tx_loopback_on_off, 13589 NULL, 13590 }, 13591 }; 13592 13593 /* all queues drop enable configuration */ 13594 13595 /* Common result structure for all queues drop enable */ 13596 struct cmd_all_queues_drop_en_result { 13597 cmdline_fixed_string_t set; 13598 cmdline_fixed_string_t all; 13599 cmdline_fixed_string_t queues; 13600 cmdline_fixed_string_t drop; 13601 portid_t port_id; 13602 cmdline_fixed_string_t on_off; 13603 }; 13604 13605 /* Common CLI fields for tx loopback enable disable */ 13606 cmdline_parse_token_string_t cmd_all_queues_drop_en_set = 13607 TOKEN_STRING_INITIALIZER 13608 (struct cmd_all_queues_drop_en_result, 13609 set, "set"); 13610 cmdline_parse_token_string_t cmd_all_queues_drop_en_all = 13611 TOKEN_STRING_INITIALIZER 13612 (struct cmd_all_queues_drop_en_result, 13613 all, "all"); 13614 cmdline_parse_token_string_t cmd_all_queues_drop_en_queues = 13615 TOKEN_STRING_INITIALIZER 13616 (struct cmd_all_queues_drop_en_result, 13617 queues, "queues"); 13618 cmdline_parse_token_string_t cmd_all_queues_drop_en_drop = 13619 TOKEN_STRING_INITIALIZER 13620 (struct cmd_all_queues_drop_en_result, 13621 drop, "drop"); 13622 cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id = 13623 TOKEN_NUM_INITIALIZER 13624 (struct cmd_all_queues_drop_en_result, 13625 port_id, UINT16); 13626 cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off = 13627 TOKEN_STRING_INITIALIZER 13628 (struct cmd_all_queues_drop_en_result, 13629 on_off, "on#off"); 13630 13631 static void 13632 cmd_set_all_queues_drop_en_parsed( 13633 void *parsed_result, 13634 __attribute__((unused)) struct cmdline *cl, 13635 __attribute__((unused)) void *data) 13636 { 13637 struct cmd_all_queues_drop_en_result *res = parsed_result; 13638 int ret = -ENOTSUP; 13639 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13640 13641 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13642 return; 13643 13644 #ifdef RTE_LIBRTE_IXGBE_PMD 13645 if (ret == -ENOTSUP) 13646 ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on); 13647 #endif 13648 #ifdef RTE_LIBRTE_BNXT_PMD 13649 if (ret == -ENOTSUP) 13650 ret = rte_pmd_bnxt_set_all_queues_drop_en(res->port_id, is_on); 13651 #endif 13652 switch (ret) { 13653 case 0: 13654 break; 13655 case -EINVAL: 13656 printf("invalid is_on %d\n", is_on); 13657 break; 13658 case -ENODEV: 13659 printf("invalid port_id %d\n", res->port_id); 13660 break; 13661 case -ENOTSUP: 13662 printf("function not implemented\n"); 13663 break; 13664 default: 13665 printf("programming error: (%s)\n", strerror(-ret)); 13666 } 13667 } 13668 13669 cmdline_parse_inst_t cmd_set_all_queues_drop_en = { 13670 .f = cmd_set_all_queues_drop_en_parsed, 13671 .data = NULL, 13672 .help_str = "set all queues drop <port_id> on|off", 13673 .tokens = { 13674 (void *)&cmd_all_queues_drop_en_set, 13675 (void *)&cmd_all_queues_drop_en_all, 13676 (void *)&cmd_all_queues_drop_en_queues, 13677 (void *)&cmd_all_queues_drop_en_drop, 13678 (void *)&cmd_all_queues_drop_en_port_id, 13679 (void *)&cmd_all_queues_drop_en_on_off, 13680 NULL, 13681 }, 13682 }; 13683 13684 /* vf split drop enable configuration */ 13685 13686 /* Common result structure for vf split drop enable */ 13687 struct cmd_vf_split_drop_en_result { 13688 cmdline_fixed_string_t set; 13689 cmdline_fixed_string_t vf; 13690 cmdline_fixed_string_t split; 13691 cmdline_fixed_string_t drop; 13692 portid_t port_id; 13693 uint16_t vf_id; 13694 cmdline_fixed_string_t on_off; 13695 }; 13696 13697 /* Common CLI fields for vf split drop enable disable */ 13698 cmdline_parse_token_string_t cmd_vf_split_drop_en_set = 13699 TOKEN_STRING_INITIALIZER 13700 (struct cmd_vf_split_drop_en_result, 13701 set, "set"); 13702 cmdline_parse_token_string_t cmd_vf_split_drop_en_vf = 13703 TOKEN_STRING_INITIALIZER 13704 (struct cmd_vf_split_drop_en_result, 13705 vf, "vf"); 13706 cmdline_parse_token_string_t cmd_vf_split_drop_en_split = 13707 TOKEN_STRING_INITIALIZER 13708 (struct cmd_vf_split_drop_en_result, 13709 split, "split"); 13710 cmdline_parse_token_string_t cmd_vf_split_drop_en_drop = 13711 TOKEN_STRING_INITIALIZER 13712 (struct cmd_vf_split_drop_en_result, 13713 drop, "drop"); 13714 cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id = 13715 TOKEN_NUM_INITIALIZER 13716 (struct cmd_vf_split_drop_en_result, 13717 port_id, UINT16); 13718 cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id = 13719 TOKEN_NUM_INITIALIZER 13720 (struct cmd_vf_split_drop_en_result, 13721 vf_id, UINT16); 13722 cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off = 13723 TOKEN_STRING_INITIALIZER 13724 (struct cmd_vf_split_drop_en_result, 13725 on_off, "on#off"); 13726 13727 static void 13728 cmd_set_vf_split_drop_en_parsed( 13729 void *parsed_result, 13730 __attribute__((unused)) struct cmdline *cl, 13731 __attribute__((unused)) void *data) 13732 { 13733 struct cmd_vf_split_drop_en_result *res = parsed_result; 13734 int ret = -ENOTSUP; 13735 int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 13736 13737 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13738 return; 13739 13740 #ifdef RTE_LIBRTE_IXGBE_PMD 13741 ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, 13742 is_on); 13743 #endif 13744 switch (ret) { 13745 case 0: 13746 break; 13747 case -EINVAL: 13748 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 13749 break; 13750 case -ENODEV: 13751 printf("invalid port_id %d\n", res->port_id); 13752 break; 13753 case -ENOTSUP: 13754 printf("not supported on port %d\n", res->port_id); 13755 break; 13756 default: 13757 printf("programming error: (%s)\n", strerror(-ret)); 13758 } 13759 } 13760 13761 cmdline_parse_inst_t cmd_set_vf_split_drop_en = { 13762 .f = cmd_set_vf_split_drop_en_parsed, 13763 .data = NULL, 13764 .help_str = "set vf split drop <port_id> <vf_id> on|off", 13765 .tokens = { 13766 (void *)&cmd_vf_split_drop_en_set, 13767 (void *)&cmd_vf_split_drop_en_vf, 13768 (void *)&cmd_vf_split_drop_en_split, 13769 (void *)&cmd_vf_split_drop_en_drop, 13770 (void *)&cmd_vf_split_drop_en_port_id, 13771 (void *)&cmd_vf_split_drop_en_vf_id, 13772 (void *)&cmd_vf_split_drop_en_on_off, 13773 NULL, 13774 }, 13775 }; 13776 13777 /* vf mac address configuration */ 13778 13779 /* Common result structure for vf mac address */ 13780 struct cmd_set_vf_mac_addr_result { 13781 cmdline_fixed_string_t set; 13782 cmdline_fixed_string_t vf; 13783 cmdline_fixed_string_t mac; 13784 cmdline_fixed_string_t addr; 13785 portid_t port_id; 13786 uint16_t vf_id; 13787 struct ether_addr mac_addr; 13788 13789 }; 13790 13791 /* Common CLI fields for vf split drop enable disable */ 13792 cmdline_parse_token_string_t cmd_set_vf_mac_addr_set = 13793 TOKEN_STRING_INITIALIZER 13794 (struct cmd_set_vf_mac_addr_result, 13795 set, "set"); 13796 cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf = 13797 TOKEN_STRING_INITIALIZER 13798 (struct cmd_set_vf_mac_addr_result, 13799 vf, "vf"); 13800 cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac = 13801 TOKEN_STRING_INITIALIZER 13802 (struct cmd_set_vf_mac_addr_result, 13803 mac, "mac"); 13804 cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr = 13805 TOKEN_STRING_INITIALIZER 13806 (struct cmd_set_vf_mac_addr_result, 13807 addr, "addr"); 13808 cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id = 13809 TOKEN_NUM_INITIALIZER 13810 (struct cmd_set_vf_mac_addr_result, 13811 port_id, UINT16); 13812 cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id = 13813 TOKEN_NUM_INITIALIZER 13814 (struct cmd_set_vf_mac_addr_result, 13815 vf_id, UINT16); 13816 cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr = 13817 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result, 13818 mac_addr); 13819 13820 static void 13821 cmd_set_vf_mac_addr_parsed( 13822 void *parsed_result, 13823 __attribute__((unused)) struct cmdline *cl, 13824 __attribute__((unused)) void *data) 13825 { 13826 struct cmd_set_vf_mac_addr_result *res = parsed_result; 13827 int ret = -ENOTSUP; 13828 13829 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 13830 return; 13831 13832 #ifdef RTE_LIBRTE_IXGBE_PMD 13833 if (ret == -ENOTSUP) 13834 ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, 13835 &res->mac_addr); 13836 #endif 13837 #ifdef RTE_LIBRTE_I40E_PMD 13838 if (ret == -ENOTSUP) 13839 ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id, 13840 &res->mac_addr); 13841 #endif 13842 #ifdef RTE_LIBRTE_BNXT_PMD 13843 if (ret == -ENOTSUP) 13844 ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id, 13845 &res->mac_addr); 13846 #endif 13847 13848 switch (ret) { 13849 case 0: 13850 break; 13851 case -EINVAL: 13852 printf("invalid vf_id %d or mac_addr\n", res->vf_id); 13853 break; 13854 case -ENODEV: 13855 printf("invalid port_id %d\n", res->port_id); 13856 break; 13857 case -ENOTSUP: 13858 printf("function not implemented\n"); 13859 break; 13860 default: 13861 printf("programming error: (%s)\n", strerror(-ret)); 13862 } 13863 } 13864 13865 cmdline_parse_inst_t cmd_set_vf_mac_addr = { 13866 .f = cmd_set_vf_mac_addr_parsed, 13867 .data = NULL, 13868 .help_str = "set vf mac addr <port_id> <vf_id> <mac_addr>", 13869 .tokens = { 13870 (void *)&cmd_set_vf_mac_addr_set, 13871 (void *)&cmd_set_vf_mac_addr_vf, 13872 (void *)&cmd_set_vf_mac_addr_mac, 13873 (void *)&cmd_set_vf_mac_addr_addr, 13874 (void *)&cmd_set_vf_mac_addr_port_id, 13875 (void *)&cmd_set_vf_mac_addr_vf_id, 13876 (void *)&cmd_set_vf_mac_addr_mac_addr, 13877 NULL, 13878 }, 13879 }; 13880 13881 /* MACsec configuration */ 13882 13883 /* Common result structure for MACsec offload enable */ 13884 struct cmd_macsec_offload_on_result { 13885 cmdline_fixed_string_t set; 13886 cmdline_fixed_string_t macsec; 13887 cmdline_fixed_string_t offload; 13888 portid_t port_id; 13889 cmdline_fixed_string_t on; 13890 cmdline_fixed_string_t encrypt; 13891 cmdline_fixed_string_t en_on_off; 13892 cmdline_fixed_string_t replay_protect; 13893 cmdline_fixed_string_t rp_on_off; 13894 }; 13895 13896 /* Common CLI fields for MACsec offload disable */ 13897 cmdline_parse_token_string_t cmd_macsec_offload_on_set = 13898 TOKEN_STRING_INITIALIZER 13899 (struct cmd_macsec_offload_on_result, 13900 set, "set"); 13901 cmdline_parse_token_string_t cmd_macsec_offload_on_macsec = 13902 TOKEN_STRING_INITIALIZER 13903 (struct cmd_macsec_offload_on_result, 13904 macsec, "macsec"); 13905 cmdline_parse_token_string_t cmd_macsec_offload_on_offload = 13906 TOKEN_STRING_INITIALIZER 13907 (struct cmd_macsec_offload_on_result, 13908 offload, "offload"); 13909 cmdline_parse_token_num_t cmd_macsec_offload_on_port_id = 13910 TOKEN_NUM_INITIALIZER 13911 (struct cmd_macsec_offload_on_result, 13912 port_id, UINT16); 13913 cmdline_parse_token_string_t cmd_macsec_offload_on_on = 13914 TOKEN_STRING_INITIALIZER 13915 (struct cmd_macsec_offload_on_result, 13916 on, "on"); 13917 cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt = 13918 TOKEN_STRING_INITIALIZER 13919 (struct cmd_macsec_offload_on_result, 13920 encrypt, "encrypt"); 13921 cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off = 13922 TOKEN_STRING_INITIALIZER 13923 (struct cmd_macsec_offload_on_result, 13924 en_on_off, "on#off"); 13925 cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect = 13926 TOKEN_STRING_INITIALIZER 13927 (struct cmd_macsec_offload_on_result, 13928 replay_protect, "replay-protect"); 13929 cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off = 13930 TOKEN_STRING_INITIALIZER 13931 (struct cmd_macsec_offload_on_result, 13932 rp_on_off, "on#off"); 13933 13934 static void 13935 cmd_set_macsec_offload_on_parsed( 13936 void *parsed_result, 13937 __attribute__((unused)) struct cmdline *cl, 13938 __attribute__((unused)) void *data) 13939 { 13940 struct cmd_macsec_offload_on_result *res = parsed_result; 13941 int ret = -ENOTSUP; 13942 portid_t port_id = res->port_id; 13943 int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0; 13944 int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0; 13945 struct rte_eth_dev_info dev_info; 13946 13947 if (port_id_is_invalid(port_id, ENABLED_WARN)) 13948 return; 13949 if (!port_is_stopped(port_id)) { 13950 printf("Please stop port %d first\n", port_id); 13951 return; 13952 } 13953 13954 rte_eth_dev_info_get(port_id, &dev_info); 13955 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 13956 #ifdef RTE_LIBRTE_IXGBE_PMD 13957 ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp); 13958 #endif 13959 } 13960 RTE_SET_USED(en); 13961 RTE_SET_USED(rp); 13962 13963 switch (ret) { 13964 case 0: 13965 ports[port_id].dev_conf.txmode.offloads |= 13966 DEV_TX_OFFLOAD_MACSEC_INSERT; 13967 cmd_reconfig_device_queue(port_id, 1, 1); 13968 break; 13969 case -ENODEV: 13970 printf("invalid port_id %d\n", port_id); 13971 break; 13972 case -ENOTSUP: 13973 printf("not supported on port %d\n", port_id); 13974 break; 13975 default: 13976 printf("programming error: (%s)\n", strerror(-ret)); 13977 } 13978 } 13979 13980 cmdline_parse_inst_t cmd_set_macsec_offload_on = { 13981 .f = cmd_set_macsec_offload_on_parsed, 13982 .data = NULL, 13983 .help_str = "set macsec offload <port_id> on " 13984 "encrypt on|off replay-protect on|off", 13985 .tokens = { 13986 (void *)&cmd_macsec_offload_on_set, 13987 (void *)&cmd_macsec_offload_on_macsec, 13988 (void *)&cmd_macsec_offload_on_offload, 13989 (void *)&cmd_macsec_offload_on_port_id, 13990 (void *)&cmd_macsec_offload_on_on, 13991 (void *)&cmd_macsec_offload_on_encrypt, 13992 (void *)&cmd_macsec_offload_on_en_on_off, 13993 (void *)&cmd_macsec_offload_on_replay_protect, 13994 (void *)&cmd_macsec_offload_on_rp_on_off, 13995 NULL, 13996 }, 13997 }; 13998 13999 /* Common result structure for MACsec offload disable */ 14000 struct cmd_macsec_offload_off_result { 14001 cmdline_fixed_string_t set; 14002 cmdline_fixed_string_t macsec; 14003 cmdline_fixed_string_t offload; 14004 portid_t port_id; 14005 cmdline_fixed_string_t off; 14006 }; 14007 14008 /* Common CLI fields for MACsec offload disable */ 14009 cmdline_parse_token_string_t cmd_macsec_offload_off_set = 14010 TOKEN_STRING_INITIALIZER 14011 (struct cmd_macsec_offload_off_result, 14012 set, "set"); 14013 cmdline_parse_token_string_t cmd_macsec_offload_off_macsec = 14014 TOKEN_STRING_INITIALIZER 14015 (struct cmd_macsec_offload_off_result, 14016 macsec, "macsec"); 14017 cmdline_parse_token_string_t cmd_macsec_offload_off_offload = 14018 TOKEN_STRING_INITIALIZER 14019 (struct cmd_macsec_offload_off_result, 14020 offload, "offload"); 14021 cmdline_parse_token_num_t cmd_macsec_offload_off_port_id = 14022 TOKEN_NUM_INITIALIZER 14023 (struct cmd_macsec_offload_off_result, 14024 port_id, UINT16); 14025 cmdline_parse_token_string_t cmd_macsec_offload_off_off = 14026 TOKEN_STRING_INITIALIZER 14027 (struct cmd_macsec_offload_off_result, 14028 off, "off"); 14029 14030 static void 14031 cmd_set_macsec_offload_off_parsed( 14032 void *parsed_result, 14033 __attribute__((unused)) struct cmdline *cl, 14034 __attribute__((unused)) void *data) 14035 { 14036 struct cmd_macsec_offload_off_result *res = parsed_result; 14037 int ret = -ENOTSUP; 14038 struct rte_eth_dev_info dev_info; 14039 portid_t port_id = res->port_id; 14040 14041 if (port_id_is_invalid(port_id, ENABLED_WARN)) 14042 return; 14043 if (!port_is_stopped(port_id)) { 14044 printf("Please stop port %d first\n", port_id); 14045 return; 14046 } 14047 14048 rte_eth_dev_info_get(port_id, &dev_info); 14049 if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) { 14050 #ifdef RTE_LIBRTE_IXGBE_PMD 14051 ret = rte_pmd_ixgbe_macsec_disable(port_id); 14052 #endif 14053 } 14054 switch (ret) { 14055 case 0: 14056 ports[port_id].dev_conf.txmode.offloads &= 14057 ~DEV_TX_OFFLOAD_MACSEC_INSERT; 14058 cmd_reconfig_device_queue(port_id, 1, 1); 14059 break; 14060 case -ENODEV: 14061 printf("invalid port_id %d\n", port_id); 14062 break; 14063 case -ENOTSUP: 14064 printf("not supported on port %d\n", port_id); 14065 break; 14066 default: 14067 printf("programming error: (%s)\n", strerror(-ret)); 14068 } 14069 } 14070 14071 cmdline_parse_inst_t cmd_set_macsec_offload_off = { 14072 .f = cmd_set_macsec_offload_off_parsed, 14073 .data = NULL, 14074 .help_str = "set macsec offload <port_id> off", 14075 .tokens = { 14076 (void *)&cmd_macsec_offload_off_set, 14077 (void *)&cmd_macsec_offload_off_macsec, 14078 (void *)&cmd_macsec_offload_off_offload, 14079 (void *)&cmd_macsec_offload_off_port_id, 14080 (void *)&cmd_macsec_offload_off_off, 14081 NULL, 14082 }, 14083 }; 14084 14085 /* Common result structure for MACsec secure connection configure */ 14086 struct cmd_macsec_sc_result { 14087 cmdline_fixed_string_t set; 14088 cmdline_fixed_string_t macsec; 14089 cmdline_fixed_string_t sc; 14090 cmdline_fixed_string_t tx_rx; 14091 portid_t port_id; 14092 struct ether_addr mac; 14093 uint16_t pi; 14094 }; 14095 14096 /* Common CLI fields for MACsec secure connection configure */ 14097 cmdline_parse_token_string_t cmd_macsec_sc_set = 14098 TOKEN_STRING_INITIALIZER 14099 (struct cmd_macsec_sc_result, 14100 set, "set"); 14101 cmdline_parse_token_string_t cmd_macsec_sc_macsec = 14102 TOKEN_STRING_INITIALIZER 14103 (struct cmd_macsec_sc_result, 14104 macsec, "macsec"); 14105 cmdline_parse_token_string_t cmd_macsec_sc_sc = 14106 TOKEN_STRING_INITIALIZER 14107 (struct cmd_macsec_sc_result, 14108 sc, "sc"); 14109 cmdline_parse_token_string_t cmd_macsec_sc_tx_rx = 14110 TOKEN_STRING_INITIALIZER 14111 (struct cmd_macsec_sc_result, 14112 tx_rx, "tx#rx"); 14113 cmdline_parse_token_num_t cmd_macsec_sc_port_id = 14114 TOKEN_NUM_INITIALIZER 14115 (struct cmd_macsec_sc_result, 14116 port_id, UINT16); 14117 cmdline_parse_token_etheraddr_t cmd_macsec_sc_mac = 14118 TOKEN_ETHERADDR_INITIALIZER 14119 (struct cmd_macsec_sc_result, 14120 mac); 14121 cmdline_parse_token_num_t cmd_macsec_sc_pi = 14122 TOKEN_NUM_INITIALIZER 14123 (struct cmd_macsec_sc_result, 14124 pi, UINT16); 14125 14126 static void 14127 cmd_set_macsec_sc_parsed( 14128 void *parsed_result, 14129 __attribute__((unused)) struct cmdline *cl, 14130 __attribute__((unused)) void *data) 14131 { 14132 struct cmd_macsec_sc_result *res = parsed_result; 14133 int ret = -ENOTSUP; 14134 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 14135 14136 #ifdef RTE_LIBRTE_IXGBE_PMD 14137 ret = is_tx ? 14138 rte_pmd_ixgbe_macsec_config_txsc(res->port_id, 14139 res->mac.addr_bytes) : 14140 rte_pmd_ixgbe_macsec_config_rxsc(res->port_id, 14141 res->mac.addr_bytes, res->pi); 14142 #endif 14143 RTE_SET_USED(is_tx); 14144 14145 switch (ret) { 14146 case 0: 14147 break; 14148 case -ENODEV: 14149 printf("invalid port_id %d\n", res->port_id); 14150 break; 14151 case -ENOTSUP: 14152 printf("not supported on port %d\n", res->port_id); 14153 break; 14154 default: 14155 printf("programming error: (%s)\n", strerror(-ret)); 14156 } 14157 } 14158 14159 cmdline_parse_inst_t cmd_set_macsec_sc = { 14160 .f = cmd_set_macsec_sc_parsed, 14161 .data = NULL, 14162 .help_str = "set macsec sc tx|rx <port_id> <mac> <pi>", 14163 .tokens = { 14164 (void *)&cmd_macsec_sc_set, 14165 (void *)&cmd_macsec_sc_macsec, 14166 (void *)&cmd_macsec_sc_sc, 14167 (void *)&cmd_macsec_sc_tx_rx, 14168 (void *)&cmd_macsec_sc_port_id, 14169 (void *)&cmd_macsec_sc_mac, 14170 (void *)&cmd_macsec_sc_pi, 14171 NULL, 14172 }, 14173 }; 14174 14175 /* Common result structure for MACsec secure connection configure */ 14176 struct cmd_macsec_sa_result { 14177 cmdline_fixed_string_t set; 14178 cmdline_fixed_string_t macsec; 14179 cmdline_fixed_string_t sa; 14180 cmdline_fixed_string_t tx_rx; 14181 portid_t port_id; 14182 uint8_t idx; 14183 uint8_t an; 14184 uint32_t pn; 14185 cmdline_fixed_string_t key; 14186 }; 14187 14188 /* Common CLI fields for MACsec secure connection configure */ 14189 cmdline_parse_token_string_t cmd_macsec_sa_set = 14190 TOKEN_STRING_INITIALIZER 14191 (struct cmd_macsec_sa_result, 14192 set, "set"); 14193 cmdline_parse_token_string_t cmd_macsec_sa_macsec = 14194 TOKEN_STRING_INITIALIZER 14195 (struct cmd_macsec_sa_result, 14196 macsec, "macsec"); 14197 cmdline_parse_token_string_t cmd_macsec_sa_sa = 14198 TOKEN_STRING_INITIALIZER 14199 (struct cmd_macsec_sa_result, 14200 sa, "sa"); 14201 cmdline_parse_token_string_t cmd_macsec_sa_tx_rx = 14202 TOKEN_STRING_INITIALIZER 14203 (struct cmd_macsec_sa_result, 14204 tx_rx, "tx#rx"); 14205 cmdline_parse_token_num_t cmd_macsec_sa_port_id = 14206 TOKEN_NUM_INITIALIZER 14207 (struct cmd_macsec_sa_result, 14208 port_id, UINT16); 14209 cmdline_parse_token_num_t cmd_macsec_sa_idx = 14210 TOKEN_NUM_INITIALIZER 14211 (struct cmd_macsec_sa_result, 14212 idx, UINT8); 14213 cmdline_parse_token_num_t cmd_macsec_sa_an = 14214 TOKEN_NUM_INITIALIZER 14215 (struct cmd_macsec_sa_result, 14216 an, UINT8); 14217 cmdline_parse_token_num_t cmd_macsec_sa_pn = 14218 TOKEN_NUM_INITIALIZER 14219 (struct cmd_macsec_sa_result, 14220 pn, UINT32); 14221 cmdline_parse_token_string_t cmd_macsec_sa_key = 14222 TOKEN_STRING_INITIALIZER 14223 (struct cmd_macsec_sa_result, 14224 key, NULL); 14225 14226 static void 14227 cmd_set_macsec_sa_parsed( 14228 void *parsed_result, 14229 __attribute__((unused)) struct cmdline *cl, 14230 __attribute__((unused)) void *data) 14231 { 14232 struct cmd_macsec_sa_result *res = parsed_result; 14233 int ret = -ENOTSUP; 14234 int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0; 14235 uint8_t key[16] = { 0 }; 14236 uint8_t xdgt0; 14237 uint8_t xdgt1; 14238 int key_len; 14239 int i; 14240 14241 key_len = strlen(res->key) / 2; 14242 if (key_len > 16) 14243 key_len = 16; 14244 14245 for (i = 0; i < key_len; i++) { 14246 xdgt0 = parse_and_check_key_hexa_digit(res->key, (i * 2)); 14247 if (xdgt0 == 0xFF) 14248 return; 14249 xdgt1 = parse_and_check_key_hexa_digit(res->key, (i * 2) + 1); 14250 if (xdgt1 == 0xFF) 14251 return; 14252 key[i] = (uint8_t) ((xdgt0 * 16) + xdgt1); 14253 } 14254 14255 #ifdef RTE_LIBRTE_IXGBE_PMD 14256 ret = is_tx ? 14257 rte_pmd_ixgbe_macsec_select_txsa(res->port_id, 14258 res->idx, res->an, res->pn, key) : 14259 rte_pmd_ixgbe_macsec_select_rxsa(res->port_id, 14260 res->idx, res->an, res->pn, key); 14261 #endif 14262 RTE_SET_USED(is_tx); 14263 RTE_SET_USED(key); 14264 14265 switch (ret) { 14266 case 0: 14267 break; 14268 case -EINVAL: 14269 printf("invalid idx %d or an %d\n", res->idx, res->an); 14270 break; 14271 case -ENODEV: 14272 printf("invalid port_id %d\n", res->port_id); 14273 break; 14274 case -ENOTSUP: 14275 printf("not supported on port %d\n", res->port_id); 14276 break; 14277 default: 14278 printf("programming error: (%s)\n", strerror(-ret)); 14279 } 14280 } 14281 14282 cmdline_parse_inst_t cmd_set_macsec_sa = { 14283 .f = cmd_set_macsec_sa_parsed, 14284 .data = NULL, 14285 .help_str = "set macsec sa tx|rx <port_id> <idx> <an> <pn> <key>", 14286 .tokens = { 14287 (void *)&cmd_macsec_sa_set, 14288 (void *)&cmd_macsec_sa_macsec, 14289 (void *)&cmd_macsec_sa_sa, 14290 (void *)&cmd_macsec_sa_tx_rx, 14291 (void *)&cmd_macsec_sa_port_id, 14292 (void *)&cmd_macsec_sa_idx, 14293 (void *)&cmd_macsec_sa_an, 14294 (void *)&cmd_macsec_sa_pn, 14295 (void *)&cmd_macsec_sa_key, 14296 NULL, 14297 }, 14298 }; 14299 14300 /* VF unicast promiscuous mode configuration */ 14301 14302 /* Common result structure for VF unicast promiscuous mode */ 14303 struct cmd_vf_promisc_result { 14304 cmdline_fixed_string_t set; 14305 cmdline_fixed_string_t vf; 14306 cmdline_fixed_string_t promisc; 14307 portid_t port_id; 14308 uint32_t vf_id; 14309 cmdline_fixed_string_t on_off; 14310 }; 14311 14312 /* Common CLI fields for VF unicast promiscuous mode enable disable */ 14313 cmdline_parse_token_string_t cmd_vf_promisc_set = 14314 TOKEN_STRING_INITIALIZER 14315 (struct cmd_vf_promisc_result, 14316 set, "set"); 14317 cmdline_parse_token_string_t cmd_vf_promisc_vf = 14318 TOKEN_STRING_INITIALIZER 14319 (struct cmd_vf_promisc_result, 14320 vf, "vf"); 14321 cmdline_parse_token_string_t cmd_vf_promisc_promisc = 14322 TOKEN_STRING_INITIALIZER 14323 (struct cmd_vf_promisc_result, 14324 promisc, "promisc"); 14325 cmdline_parse_token_num_t cmd_vf_promisc_port_id = 14326 TOKEN_NUM_INITIALIZER 14327 (struct cmd_vf_promisc_result, 14328 port_id, UINT16); 14329 cmdline_parse_token_num_t cmd_vf_promisc_vf_id = 14330 TOKEN_NUM_INITIALIZER 14331 (struct cmd_vf_promisc_result, 14332 vf_id, UINT32); 14333 cmdline_parse_token_string_t cmd_vf_promisc_on_off = 14334 TOKEN_STRING_INITIALIZER 14335 (struct cmd_vf_promisc_result, 14336 on_off, "on#off"); 14337 14338 static void 14339 cmd_set_vf_promisc_parsed( 14340 void *parsed_result, 14341 __attribute__((unused)) struct cmdline *cl, 14342 __attribute__((unused)) void *data) 14343 { 14344 struct cmd_vf_promisc_result *res = parsed_result; 14345 int ret = -ENOTSUP; 14346 14347 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14348 14349 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14350 return; 14351 14352 #ifdef RTE_LIBRTE_I40E_PMD 14353 ret = rte_pmd_i40e_set_vf_unicast_promisc(res->port_id, 14354 res->vf_id, is_on); 14355 #endif 14356 14357 switch (ret) { 14358 case 0: 14359 break; 14360 case -EINVAL: 14361 printf("invalid vf_id %d\n", res->vf_id); 14362 break; 14363 case -ENODEV: 14364 printf("invalid port_id %d\n", res->port_id); 14365 break; 14366 case -ENOTSUP: 14367 printf("function not implemented\n"); 14368 break; 14369 default: 14370 printf("programming error: (%s)\n", strerror(-ret)); 14371 } 14372 } 14373 14374 cmdline_parse_inst_t cmd_set_vf_promisc = { 14375 .f = cmd_set_vf_promisc_parsed, 14376 .data = NULL, 14377 .help_str = "set vf promisc <port_id> <vf_id> on|off: " 14378 "Set unicast promiscuous mode for a VF from the PF", 14379 .tokens = { 14380 (void *)&cmd_vf_promisc_set, 14381 (void *)&cmd_vf_promisc_vf, 14382 (void *)&cmd_vf_promisc_promisc, 14383 (void *)&cmd_vf_promisc_port_id, 14384 (void *)&cmd_vf_promisc_vf_id, 14385 (void *)&cmd_vf_promisc_on_off, 14386 NULL, 14387 }, 14388 }; 14389 14390 /* VF multicast promiscuous mode configuration */ 14391 14392 /* Common result structure for VF multicast promiscuous mode */ 14393 struct cmd_vf_allmulti_result { 14394 cmdline_fixed_string_t set; 14395 cmdline_fixed_string_t vf; 14396 cmdline_fixed_string_t allmulti; 14397 portid_t port_id; 14398 uint32_t vf_id; 14399 cmdline_fixed_string_t on_off; 14400 }; 14401 14402 /* Common CLI fields for VF multicast promiscuous mode enable disable */ 14403 cmdline_parse_token_string_t cmd_vf_allmulti_set = 14404 TOKEN_STRING_INITIALIZER 14405 (struct cmd_vf_allmulti_result, 14406 set, "set"); 14407 cmdline_parse_token_string_t cmd_vf_allmulti_vf = 14408 TOKEN_STRING_INITIALIZER 14409 (struct cmd_vf_allmulti_result, 14410 vf, "vf"); 14411 cmdline_parse_token_string_t cmd_vf_allmulti_allmulti = 14412 TOKEN_STRING_INITIALIZER 14413 (struct cmd_vf_allmulti_result, 14414 allmulti, "allmulti"); 14415 cmdline_parse_token_num_t cmd_vf_allmulti_port_id = 14416 TOKEN_NUM_INITIALIZER 14417 (struct cmd_vf_allmulti_result, 14418 port_id, UINT16); 14419 cmdline_parse_token_num_t cmd_vf_allmulti_vf_id = 14420 TOKEN_NUM_INITIALIZER 14421 (struct cmd_vf_allmulti_result, 14422 vf_id, UINT32); 14423 cmdline_parse_token_string_t cmd_vf_allmulti_on_off = 14424 TOKEN_STRING_INITIALIZER 14425 (struct cmd_vf_allmulti_result, 14426 on_off, "on#off"); 14427 14428 static void 14429 cmd_set_vf_allmulti_parsed( 14430 void *parsed_result, 14431 __attribute__((unused)) struct cmdline *cl, 14432 __attribute__((unused)) void *data) 14433 { 14434 struct cmd_vf_allmulti_result *res = parsed_result; 14435 int ret = -ENOTSUP; 14436 14437 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14438 14439 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14440 return; 14441 14442 #ifdef RTE_LIBRTE_I40E_PMD 14443 ret = rte_pmd_i40e_set_vf_multicast_promisc(res->port_id, 14444 res->vf_id, is_on); 14445 #endif 14446 14447 switch (ret) { 14448 case 0: 14449 break; 14450 case -EINVAL: 14451 printf("invalid vf_id %d\n", res->vf_id); 14452 break; 14453 case -ENODEV: 14454 printf("invalid port_id %d\n", res->port_id); 14455 break; 14456 case -ENOTSUP: 14457 printf("function not implemented\n"); 14458 break; 14459 default: 14460 printf("programming error: (%s)\n", strerror(-ret)); 14461 } 14462 } 14463 14464 cmdline_parse_inst_t cmd_set_vf_allmulti = { 14465 .f = cmd_set_vf_allmulti_parsed, 14466 .data = NULL, 14467 .help_str = "set vf allmulti <port_id> <vf_id> on|off: " 14468 "Set multicast promiscuous mode for a VF from the PF", 14469 .tokens = { 14470 (void *)&cmd_vf_allmulti_set, 14471 (void *)&cmd_vf_allmulti_vf, 14472 (void *)&cmd_vf_allmulti_allmulti, 14473 (void *)&cmd_vf_allmulti_port_id, 14474 (void *)&cmd_vf_allmulti_vf_id, 14475 (void *)&cmd_vf_allmulti_on_off, 14476 NULL, 14477 }, 14478 }; 14479 14480 /* vf broadcast mode configuration */ 14481 14482 /* Common result structure for vf broadcast */ 14483 struct cmd_set_vf_broadcast_result { 14484 cmdline_fixed_string_t set; 14485 cmdline_fixed_string_t vf; 14486 cmdline_fixed_string_t broadcast; 14487 portid_t port_id; 14488 uint16_t vf_id; 14489 cmdline_fixed_string_t on_off; 14490 }; 14491 14492 /* Common CLI fields for vf broadcast enable disable */ 14493 cmdline_parse_token_string_t cmd_set_vf_broadcast_set = 14494 TOKEN_STRING_INITIALIZER 14495 (struct cmd_set_vf_broadcast_result, 14496 set, "set"); 14497 cmdline_parse_token_string_t cmd_set_vf_broadcast_vf = 14498 TOKEN_STRING_INITIALIZER 14499 (struct cmd_set_vf_broadcast_result, 14500 vf, "vf"); 14501 cmdline_parse_token_string_t cmd_set_vf_broadcast_broadcast = 14502 TOKEN_STRING_INITIALIZER 14503 (struct cmd_set_vf_broadcast_result, 14504 broadcast, "broadcast"); 14505 cmdline_parse_token_num_t cmd_set_vf_broadcast_port_id = 14506 TOKEN_NUM_INITIALIZER 14507 (struct cmd_set_vf_broadcast_result, 14508 port_id, UINT16); 14509 cmdline_parse_token_num_t cmd_set_vf_broadcast_vf_id = 14510 TOKEN_NUM_INITIALIZER 14511 (struct cmd_set_vf_broadcast_result, 14512 vf_id, UINT16); 14513 cmdline_parse_token_string_t cmd_set_vf_broadcast_on_off = 14514 TOKEN_STRING_INITIALIZER 14515 (struct cmd_set_vf_broadcast_result, 14516 on_off, "on#off"); 14517 14518 static void 14519 cmd_set_vf_broadcast_parsed( 14520 void *parsed_result, 14521 __attribute__((unused)) struct cmdline *cl, 14522 __attribute__((unused)) void *data) 14523 { 14524 struct cmd_set_vf_broadcast_result *res = parsed_result; 14525 int ret = -ENOTSUP; 14526 14527 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 14528 14529 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14530 return; 14531 14532 #ifdef RTE_LIBRTE_I40E_PMD 14533 ret = rte_pmd_i40e_set_vf_broadcast(res->port_id, 14534 res->vf_id, is_on); 14535 #endif 14536 14537 switch (ret) { 14538 case 0: 14539 break; 14540 case -EINVAL: 14541 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14542 break; 14543 case -ENODEV: 14544 printf("invalid port_id %d\n", res->port_id); 14545 break; 14546 case -ENOTSUP: 14547 printf("function not implemented\n"); 14548 break; 14549 default: 14550 printf("programming error: (%s)\n", strerror(-ret)); 14551 } 14552 } 14553 14554 cmdline_parse_inst_t cmd_set_vf_broadcast = { 14555 .f = cmd_set_vf_broadcast_parsed, 14556 .data = NULL, 14557 .help_str = "set vf broadcast <port_id> <vf_id> on|off", 14558 .tokens = { 14559 (void *)&cmd_set_vf_broadcast_set, 14560 (void *)&cmd_set_vf_broadcast_vf, 14561 (void *)&cmd_set_vf_broadcast_broadcast, 14562 (void *)&cmd_set_vf_broadcast_port_id, 14563 (void *)&cmd_set_vf_broadcast_vf_id, 14564 (void *)&cmd_set_vf_broadcast_on_off, 14565 NULL, 14566 }, 14567 }; 14568 14569 /* vf vlan tag configuration */ 14570 14571 /* Common result structure for vf vlan tag */ 14572 struct cmd_set_vf_vlan_tag_result { 14573 cmdline_fixed_string_t set; 14574 cmdline_fixed_string_t vf; 14575 cmdline_fixed_string_t vlan; 14576 cmdline_fixed_string_t tag; 14577 portid_t port_id; 14578 uint16_t vf_id; 14579 cmdline_fixed_string_t on_off; 14580 }; 14581 14582 /* Common CLI fields for vf vlan tag enable disable */ 14583 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_set = 14584 TOKEN_STRING_INITIALIZER 14585 (struct cmd_set_vf_vlan_tag_result, 14586 set, "set"); 14587 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vf = 14588 TOKEN_STRING_INITIALIZER 14589 (struct cmd_set_vf_vlan_tag_result, 14590 vf, "vf"); 14591 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_vlan = 14592 TOKEN_STRING_INITIALIZER 14593 (struct cmd_set_vf_vlan_tag_result, 14594 vlan, "vlan"); 14595 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_tag = 14596 TOKEN_STRING_INITIALIZER 14597 (struct cmd_set_vf_vlan_tag_result, 14598 tag, "tag"); 14599 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_port_id = 14600 TOKEN_NUM_INITIALIZER 14601 (struct cmd_set_vf_vlan_tag_result, 14602 port_id, UINT16); 14603 cmdline_parse_token_num_t cmd_set_vf_vlan_tag_vf_id = 14604 TOKEN_NUM_INITIALIZER 14605 (struct cmd_set_vf_vlan_tag_result, 14606 vf_id, UINT16); 14607 cmdline_parse_token_string_t cmd_set_vf_vlan_tag_on_off = 14608 TOKEN_STRING_INITIALIZER 14609 (struct cmd_set_vf_vlan_tag_result, 14610 on_off, "on#off"); 14611 14612 static void 14613 cmd_set_vf_vlan_tag_parsed( 14614 void *parsed_result, 14615 __attribute__((unused)) struct cmdline *cl, 14616 __attribute__((unused)) void *data) 14617 { 14618 struct cmd_set_vf_vlan_tag_result *res = parsed_result; 14619 int ret = -ENOTSUP; 14620 14621 __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; 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_vlan_tag(res->port_id, 14628 res->vf_id, is_on); 14629 #endif 14630 14631 switch (ret) { 14632 case 0: 14633 break; 14634 case -EINVAL: 14635 printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on); 14636 break; 14637 case -ENODEV: 14638 printf("invalid port_id %d\n", res->port_id); 14639 break; 14640 case -ENOTSUP: 14641 printf("function not implemented\n"); 14642 break; 14643 default: 14644 printf("programming error: (%s)\n", strerror(-ret)); 14645 } 14646 } 14647 14648 cmdline_parse_inst_t cmd_set_vf_vlan_tag = { 14649 .f = cmd_set_vf_vlan_tag_parsed, 14650 .data = NULL, 14651 .help_str = "set vf vlan tag <port_id> <vf_id> on|off", 14652 .tokens = { 14653 (void *)&cmd_set_vf_vlan_tag_set, 14654 (void *)&cmd_set_vf_vlan_tag_vf, 14655 (void *)&cmd_set_vf_vlan_tag_vlan, 14656 (void *)&cmd_set_vf_vlan_tag_tag, 14657 (void *)&cmd_set_vf_vlan_tag_port_id, 14658 (void *)&cmd_set_vf_vlan_tag_vf_id, 14659 (void *)&cmd_set_vf_vlan_tag_on_off, 14660 NULL, 14661 }, 14662 }; 14663 14664 /* Common definition of VF and TC TX bandwidth configuration */ 14665 struct cmd_vf_tc_bw_result { 14666 cmdline_fixed_string_t set; 14667 cmdline_fixed_string_t vf; 14668 cmdline_fixed_string_t tc; 14669 cmdline_fixed_string_t tx; 14670 cmdline_fixed_string_t min_bw; 14671 cmdline_fixed_string_t max_bw; 14672 cmdline_fixed_string_t strict_link_prio; 14673 portid_t port_id; 14674 uint16_t vf_id; 14675 uint8_t tc_no; 14676 uint32_t bw; 14677 cmdline_fixed_string_t bw_list; 14678 uint8_t tc_map; 14679 }; 14680 14681 cmdline_parse_token_string_t cmd_vf_tc_bw_set = 14682 TOKEN_STRING_INITIALIZER 14683 (struct cmd_vf_tc_bw_result, 14684 set, "set"); 14685 cmdline_parse_token_string_t cmd_vf_tc_bw_vf = 14686 TOKEN_STRING_INITIALIZER 14687 (struct cmd_vf_tc_bw_result, 14688 vf, "vf"); 14689 cmdline_parse_token_string_t cmd_vf_tc_bw_tc = 14690 TOKEN_STRING_INITIALIZER 14691 (struct cmd_vf_tc_bw_result, 14692 tc, "tc"); 14693 cmdline_parse_token_string_t cmd_vf_tc_bw_tx = 14694 TOKEN_STRING_INITIALIZER 14695 (struct cmd_vf_tc_bw_result, 14696 tx, "tx"); 14697 cmdline_parse_token_string_t cmd_vf_tc_bw_strict_link_prio = 14698 TOKEN_STRING_INITIALIZER 14699 (struct cmd_vf_tc_bw_result, 14700 strict_link_prio, "strict-link-priority"); 14701 cmdline_parse_token_string_t cmd_vf_tc_bw_min_bw = 14702 TOKEN_STRING_INITIALIZER 14703 (struct cmd_vf_tc_bw_result, 14704 min_bw, "min-bandwidth"); 14705 cmdline_parse_token_string_t cmd_vf_tc_bw_max_bw = 14706 TOKEN_STRING_INITIALIZER 14707 (struct cmd_vf_tc_bw_result, 14708 max_bw, "max-bandwidth"); 14709 cmdline_parse_token_num_t cmd_vf_tc_bw_port_id = 14710 TOKEN_NUM_INITIALIZER 14711 (struct cmd_vf_tc_bw_result, 14712 port_id, UINT16); 14713 cmdline_parse_token_num_t cmd_vf_tc_bw_vf_id = 14714 TOKEN_NUM_INITIALIZER 14715 (struct cmd_vf_tc_bw_result, 14716 vf_id, UINT16); 14717 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_no = 14718 TOKEN_NUM_INITIALIZER 14719 (struct cmd_vf_tc_bw_result, 14720 tc_no, UINT8); 14721 cmdline_parse_token_num_t cmd_vf_tc_bw_bw = 14722 TOKEN_NUM_INITIALIZER 14723 (struct cmd_vf_tc_bw_result, 14724 bw, UINT32); 14725 cmdline_parse_token_string_t cmd_vf_tc_bw_bw_list = 14726 TOKEN_STRING_INITIALIZER 14727 (struct cmd_vf_tc_bw_result, 14728 bw_list, NULL); 14729 cmdline_parse_token_num_t cmd_vf_tc_bw_tc_map = 14730 TOKEN_NUM_INITIALIZER 14731 (struct cmd_vf_tc_bw_result, 14732 tc_map, UINT8); 14733 14734 /* VF max bandwidth setting */ 14735 static void 14736 cmd_vf_max_bw_parsed( 14737 void *parsed_result, 14738 __attribute__((unused)) struct cmdline *cl, 14739 __attribute__((unused)) void *data) 14740 { 14741 struct cmd_vf_tc_bw_result *res = parsed_result; 14742 int ret = -ENOTSUP; 14743 14744 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14745 return; 14746 14747 #ifdef RTE_LIBRTE_I40E_PMD 14748 ret = rte_pmd_i40e_set_vf_max_bw(res->port_id, 14749 res->vf_id, res->bw); 14750 #endif 14751 14752 switch (ret) { 14753 case 0: 14754 break; 14755 case -EINVAL: 14756 printf("invalid vf_id %d or bandwidth %d\n", 14757 res->vf_id, res->bw); 14758 break; 14759 case -ENODEV: 14760 printf("invalid port_id %d\n", res->port_id); 14761 break; 14762 case -ENOTSUP: 14763 printf("function not implemented\n"); 14764 break; 14765 default: 14766 printf("programming error: (%s)\n", strerror(-ret)); 14767 } 14768 } 14769 14770 cmdline_parse_inst_t cmd_vf_max_bw = { 14771 .f = cmd_vf_max_bw_parsed, 14772 .data = NULL, 14773 .help_str = "set vf tx max-bandwidth <port_id> <vf_id> <bandwidth>", 14774 .tokens = { 14775 (void *)&cmd_vf_tc_bw_set, 14776 (void *)&cmd_vf_tc_bw_vf, 14777 (void *)&cmd_vf_tc_bw_tx, 14778 (void *)&cmd_vf_tc_bw_max_bw, 14779 (void *)&cmd_vf_tc_bw_port_id, 14780 (void *)&cmd_vf_tc_bw_vf_id, 14781 (void *)&cmd_vf_tc_bw_bw, 14782 NULL, 14783 }, 14784 }; 14785 14786 static int 14787 vf_tc_min_bw_parse_bw_list(uint8_t *bw_list, 14788 uint8_t *tc_num, 14789 char *str) 14790 { 14791 uint32_t size; 14792 const char *p, *p0 = str; 14793 char s[256]; 14794 char *end; 14795 char *str_fld[16]; 14796 uint16_t i; 14797 int ret; 14798 14799 p = strchr(p0, '('); 14800 if (p == NULL) { 14801 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 14802 return -1; 14803 } 14804 p++; 14805 p0 = strchr(p, ')'); 14806 if (p0 == NULL) { 14807 printf("The bandwidth-list should be '(bw1, bw2, ...)'\n"); 14808 return -1; 14809 } 14810 size = p0 - p; 14811 if (size >= sizeof(s)) { 14812 printf("The string size exceeds the internal buffer size\n"); 14813 return -1; 14814 } 14815 snprintf(s, sizeof(s), "%.*s", size, p); 14816 ret = rte_strsplit(s, sizeof(s), str_fld, 16, ','); 14817 if (ret <= 0) { 14818 printf("Failed to get the bandwidth list. "); 14819 return -1; 14820 } 14821 *tc_num = ret; 14822 for (i = 0; i < ret; i++) 14823 bw_list[i] = (uint8_t)strtoul(str_fld[i], &end, 0); 14824 14825 return 0; 14826 } 14827 14828 /* TC min bandwidth setting */ 14829 static void 14830 cmd_vf_tc_min_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 uint8_t tc_num; 14837 uint8_t bw[16]; 14838 int ret = -ENOTSUP; 14839 14840 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14841 return; 14842 14843 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 14844 if (ret) 14845 return; 14846 14847 #ifdef RTE_LIBRTE_I40E_PMD 14848 ret = rte_pmd_i40e_set_vf_tc_bw_alloc(res->port_id, res->vf_id, 14849 tc_num, bw); 14850 #endif 14851 14852 switch (ret) { 14853 case 0: 14854 break; 14855 case -EINVAL: 14856 printf("invalid vf_id %d or bandwidth\n", res->vf_id); 14857 break; 14858 case -ENODEV: 14859 printf("invalid port_id %d\n", res->port_id); 14860 break; 14861 case -ENOTSUP: 14862 printf("function not implemented\n"); 14863 break; 14864 default: 14865 printf("programming error: (%s)\n", strerror(-ret)); 14866 } 14867 } 14868 14869 cmdline_parse_inst_t cmd_vf_tc_min_bw = { 14870 .f = cmd_vf_tc_min_bw_parsed, 14871 .data = NULL, 14872 .help_str = "set vf tc tx min-bandwidth <port_id> <vf_id>" 14873 " <bw1, bw2, ...>", 14874 .tokens = { 14875 (void *)&cmd_vf_tc_bw_set, 14876 (void *)&cmd_vf_tc_bw_vf, 14877 (void *)&cmd_vf_tc_bw_tc, 14878 (void *)&cmd_vf_tc_bw_tx, 14879 (void *)&cmd_vf_tc_bw_min_bw, 14880 (void *)&cmd_vf_tc_bw_port_id, 14881 (void *)&cmd_vf_tc_bw_vf_id, 14882 (void *)&cmd_vf_tc_bw_bw_list, 14883 NULL, 14884 }, 14885 }; 14886 14887 static void 14888 cmd_tc_min_bw_parsed( 14889 void *parsed_result, 14890 __attribute__((unused)) struct cmdline *cl, 14891 __attribute__((unused)) void *data) 14892 { 14893 struct cmd_vf_tc_bw_result *res = parsed_result; 14894 struct rte_port *port; 14895 uint8_t tc_num; 14896 uint8_t bw[16]; 14897 int ret = -ENOTSUP; 14898 14899 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14900 return; 14901 14902 port = &ports[res->port_id]; 14903 /** Check if the port is not started **/ 14904 if (port->port_status != RTE_PORT_STOPPED) { 14905 printf("Please stop port %d first\n", res->port_id); 14906 return; 14907 } 14908 14909 ret = vf_tc_min_bw_parse_bw_list(bw, &tc_num, res->bw_list); 14910 if (ret) 14911 return; 14912 14913 #ifdef RTE_LIBRTE_IXGBE_PMD 14914 ret = rte_pmd_ixgbe_set_tc_bw_alloc(res->port_id, tc_num, bw); 14915 #endif 14916 14917 switch (ret) { 14918 case 0: 14919 break; 14920 case -EINVAL: 14921 printf("invalid bandwidth\n"); 14922 break; 14923 case -ENODEV: 14924 printf("invalid port_id %d\n", res->port_id); 14925 break; 14926 case -ENOTSUP: 14927 printf("function not implemented\n"); 14928 break; 14929 default: 14930 printf("programming error: (%s)\n", strerror(-ret)); 14931 } 14932 } 14933 14934 cmdline_parse_inst_t cmd_tc_min_bw = { 14935 .f = cmd_tc_min_bw_parsed, 14936 .data = NULL, 14937 .help_str = "set tc tx min-bandwidth <port_id> <bw1, bw2, ...>", 14938 .tokens = { 14939 (void *)&cmd_vf_tc_bw_set, 14940 (void *)&cmd_vf_tc_bw_tc, 14941 (void *)&cmd_vf_tc_bw_tx, 14942 (void *)&cmd_vf_tc_bw_min_bw, 14943 (void *)&cmd_vf_tc_bw_port_id, 14944 (void *)&cmd_vf_tc_bw_bw_list, 14945 NULL, 14946 }, 14947 }; 14948 14949 /* TC max bandwidth setting */ 14950 static void 14951 cmd_vf_tc_max_bw_parsed( 14952 void *parsed_result, 14953 __attribute__((unused)) struct cmdline *cl, 14954 __attribute__((unused)) void *data) 14955 { 14956 struct cmd_vf_tc_bw_result *res = parsed_result; 14957 int ret = -ENOTSUP; 14958 14959 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 14960 return; 14961 14962 #ifdef RTE_LIBRTE_I40E_PMD 14963 ret = rte_pmd_i40e_set_vf_tc_max_bw(res->port_id, res->vf_id, 14964 res->tc_no, res->bw); 14965 #endif 14966 14967 switch (ret) { 14968 case 0: 14969 break; 14970 case -EINVAL: 14971 printf("invalid vf_id %d, tc_no %d or bandwidth %d\n", 14972 res->vf_id, res->tc_no, res->bw); 14973 break; 14974 case -ENODEV: 14975 printf("invalid port_id %d\n", res->port_id); 14976 break; 14977 case -ENOTSUP: 14978 printf("function not implemented\n"); 14979 break; 14980 default: 14981 printf("programming error: (%s)\n", strerror(-ret)); 14982 } 14983 } 14984 14985 cmdline_parse_inst_t cmd_vf_tc_max_bw = { 14986 .f = cmd_vf_tc_max_bw_parsed, 14987 .data = NULL, 14988 .help_str = "set vf tc tx max-bandwidth <port_id> <vf_id> <tc_no>" 14989 " <bandwidth>", 14990 .tokens = { 14991 (void *)&cmd_vf_tc_bw_set, 14992 (void *)&cmd_vf_tc_bw_vf, 14993 (void *)&cmd_vf_tc_bw_tc, 14994 (void *)&cmd_vf_tc_bw_tx, 14995 (void *)&cmd_vf_tc_bw_max_bw, 14996 (void *)&cmd_vf_tc_bw_port_id, 14997 (void *)&cmd_vf_tc_bw_vf_id, 14998 (void *)&cmd_vf_tc_bw_tc_no, 14999 (void *)&cmd_vf_tc_bw_bw, 15000 NULL, 15001 }, 15002 }; 15003 15004 15005 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 15006 15007 /* *** Set Port default Traffic Management Hierarchy *** */ 15008 struct cmd_set_port_tm_hierarchy_default_result { 15009 cmdline_fixed_string_t set; 15010 cmdline_fixed_string_t port; 15011 cmdline_fixed_string_t tm; 15012 cmdline_fixed_string_t hierarchy; 15013 cmdline_fixed_string_t def; 15014 portid_t port_id; 15015 }; 15016 15017 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_set = 15018 TOKEN_STRING_INITIALIZER( 15019 struct cmd_set_port_tm_hierarchy_default_result, set, "set"); 15020 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_port = 15021 TOKEN_STRING_INITIALIZER( 15022 struct cmd_set_port_tm_hierarchy_default_result, port, "port"); 15023 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_tm = 15024 TOKEN_STRING_INITIALIZER( 15025 struct cmd_set_port_tm_hierarchy_default_result, tm, "tm"); 15026 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_hierarchy = 15027 TOKEN_STRING_INITIALIZER( 15028 struct cmd_set_port_tm_hierarchy_default_result, 15029 hierarchy, "hierarchy"); 15030 cmdline_parse_token_string_t cmd_set_port_tm_hierarchy_default_default = 15031 TOKEN_STRING_INITIALIZER( 15032 struct cmd_set_port_tm_hierarchy_default_result, 15033 def, "default"); 15034 cmdline_parse_token_num_t cmd_set_port_tm_hierarchy_default_port_id = 15035 TOKEN_NUM_INITIALIZER( 15036 struct cmd_set_port_tm_hierarchy_default_result, 15037 port_id, UINT16); 15038 15039 static void cmd_set_port_tm_hierarchy_default_parsed(void *parsed_result, 15040 __attribute__((unused)) struct cmdline *cl, 15041 __attribute__((unused)) void *data) 15042 { 15043 struct cmd_set_port_tm_hierarchy_default_result *res = parsed_result; 15044 struct rte_port *p; 15045 portid_t port_id = res->port_id; 15046 15047 if (port_id_is_invalid(port_id, ENABLED_WARN)) 15048 return; 15049 15050 p = &ports[port_id]; 15051 15052 /* Forward mode: tm */ 15053 if (strcmp(cur_fwd_config.fwd_eng->fwd_mode_name, "softnic")) { 15054 printf(" softnicfwd mode not enabled(error)\n"); 15055 return; 15056 } 15057 15058 /* Set the default tm hierarchy */ 15059 p->softport.default_tm_hierarchy_enable = 1; 15060 } 15061 15062 cmdline_parse_inst_t cmd_set_port_tm_hierarchy_default = { 15063 .f = cmd_set_port_tm_hierarchy_default_parsed, 15064 .data = NULL, 15065 .help_str = "set port tm hierarchy default <port_id>", 15066 .tokens = { 15067 (void *)&cmd_set_port_tm_hierarchy_default_set, 15068 (void *)&cmd_set_port_tm_hierarchy_default_port, 15069 (void *)&cmd_set_port_tm_hierarchy_default_tm, 15070 (void *)&cmd_set_port_tm_hierarchy_default_hierarchy, 15071 (void *)&cmd_set_port_tm_hierarchy_default_default, 15072 (void *)&cmd_set_port_tm_hierarchy_default_port_id, 15073 NULL, 15074 }, 15075 }; 15076 #endif 15077 15078 /** Set VXLAN encapsulation details */ 15079 struct cmd_set_vxlan_result { 15080 cmdline_fixed_string_t set; 15081 cmdline_fixed_string_t vxlan; 15082 cmdline_fixed_string_t pos_token; 15083 cmdline_fixed_string_t ip_version; 15084 uint32_t vlan_present:1; 15085 uint32_t vni; 15086 uint16_t udp_src; 15087 uint16_t udp_dst; 15088 cmdline_ipaddr_t ip_src; 15089 cmdline_ipaddr_t ip_dst; 15090 uint16_t tci; 15091 uint8_t tos; 15092 uint8_t ttl; 15093 struct ether_addr eth_src; 15094 struct ether_addr eth_dst; 15095 }; 15096 15097 cmdline_parse_token_string_t cmd_set_vxlan_set = 15098 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, set, "set"); 15099 cmdline_parse_token_string_t cmd_set_vxlan_vxlan = 15100 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, "vxlan"); 15101 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_tos_ttl = 15102 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 15103 "vxlan-tos-ttl"); 15104 cmdline_parse_token_string_t cmd_set_vxlan_vxlan_with_vlan = 15105 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, vxlan, 15106 "vxlan-with-vlan"); 15107 cmdline_parse_token_string_t cmd_set_vxlan_ip_version = 15108 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15109 "ip-version"); 15110 cmdline_parse_token_string_t cmd_set_vxlan_ip_version_value = 15111 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, ip_version, 15112 "ipv4#ipv6"); 15113 cmdline_parse_token_string_t cmd_set_vxlan_vni = 15114 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15115 "vni"); 15116 cmdline_parse_token_num_t cmd_set_vxlan_vni_value = 15117 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, vni, UINT32); 15118 cmdline_parse_token_string_t cmd_set_vxlan_udp_src = 15119 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15120 "udp-src"); 15121 cmdline_parse_token_num_t cmd_set_vxlan_udp_src_value = 15122 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_src, UINT16); 15123 cmdline_parse_token_string_t cmd_set_vxlan_udp_dst = 15124 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15125 "udp-dst"); 15126 cmdline_parse_token_num_t cmd_set_vxlan_udp_dst_value = 15127 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, udp_dst, UINT16); 15128 cmdline_parse_token_string_t cmd_set_vxlan_ip_tos = 15129 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15130 "ip-tos"); 15131 cmdline_parse_token_num_t cmd_set_vxlan_ip_tos_value = 15132 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tos, UINT8); 15133 cmdline_parse_token_string_t cmd_set_vxlan_ip_ttl = 15134 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15135 "ip-ttl"); 15136 cmdline_parse_token_num_t cmd_set_vxlan_ip_ttl_value = 15137 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, ttl, UINT8); 15138 cmdline_parse_token_string_t cmd_set_vxlan_ip_src = 15139 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15140 "ip-src"); 15141 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_src_value = 15142 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_src); 15143 cmdline_parse_token_string_t cmd_set_vxlan_ip_dst = 15144 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15145 "ip-dst"); 15146 cmdline_parse_token_ipaddr_t cmd_set_vxlan_ip_dst_value = 15147 TOKEN_IPADDR_INITIALIZER(struct cmd_set_vxlan_result, ip_dst); 15148 cmdline_parse_token_string_t cmd_set_vxlan_vlan = 15149 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15150 "vlan-tci"); 15151 cmdline_parse_token_num_t cmd_set_vxlan_vlan_value = 15152 TOKEN_NUM_INITIALIZER(struct cmd_set_vxlan_result, tci, UINT16); 15153 cmdline_parse_token_string_t cmd_set_vxlan_eth_src = 15154 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15155 "eth-src"); 15156 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_src_value = 15157 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_src); 15158 cmdline_parse_token_string_t cmd_set_vxlan_eth_dst = 15159 TOKEN_STRING_INITIALIZER(struct cmd_set_vxlan_result, pos_token, 15160 "eth-dst"); 15161 cmdline_parse_token_etheraddr_t cmd_set_vxlan_eth_dst_value = 15162 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vxlan_result, eth_dst); 15163 15164 static void cmd_set_vxlan_parsed(void *parsed_result, 15165 __attribute__((unused)) struct cmdline *cl, 15166 __attribute__((unused)) void *data) 15167 { 15168 struct cmd_set_vxlan_result *res = parsed_result; 15169 union { 15170 uint32_t vxlan_id; 15171 uint8_t vni[4]; 15172 } id = { 15173 .vxlan_id = rte_cpu_to_be_32(res->vni) & RTE_BE32(0x00ffffff), 15174 }; 15175 15176 vxlan_encap_conf.select_tos_ttl = 0; 15177 if (strcmp(res->vxlan, "vxlan") == 0) 15178 vxlan_encap_conf.select_vlan = 0; 15179 else if (strcmp(res->vxlan, "vxlan-with-vlan") == 0) 15180 vxlan_encap_conf.select_vlan = 1; 15181 else if (strcmp(res->vxlan, "vxlan-tos-ttl") == 0) { 15182 vxlan_encap_conf.select_vlan = 0; 15183 vxlan_encap_conf.select_tos_ttl = 1; 15184 } 15185 if (strcmp(res->ip_version, "ipv4") == 0) 15186 vxlan_encap_conf.select_ipv4 = 1; 15187 else if (strcmp(res->ip_version, "ipv6") == 0) 15188 vxlan_encap_conf.select_ipv4 = 0; 15189 else 15190 return; 15191 rte_memcpy(vxlan_encap_conf.vni, &id.vni[1], 3); 15192 vxlan_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 15193 vxlan_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 15194 vxlan_encap_conf.ip_tos = res->tos; 15195 vxlan_encap_conf.ip_ttl = res->ttl; 15196 if (vxlan_encap_conf.select_ipv4) { 15197 IPV4_ADDR_TO_UINT(res->ip_src, vxlan_encap_conf.ipv4_src); 15198 IPV4_ADDR_TO_UINT(res->ip_dst, vxlan_encap_conf.ipv4_dst); 15199 } else { 15200 IPV6_ADDR_TO_ARRAY(res->ip_src, vxlan_encap_conf.ipv6_src); 15201 IPV6_ADDR_TO_ARRAY(res->ip_dst, vxlan_encap_conf.ipv6_dst); 15202 } 15203 if (vxlan_encap_conf.select_vlan) 15204 vxlan_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15205 rte_memcpy(vxlan_encap_conf.eth_src, res->eth_src.addr_bytes, 15206 ETHER_ADDR_LEN); 15207 rte_memcpy(vxlan_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15208 ETHER_ADDR_LEN); 15209 } 15210 15211 cmdline_parse_inst_t cmd_set_vxlan = { 15212 .f = cmd_set_vxlan_parsed, 15213 .data = NULL, 15214 .help_str = "set vxlan ip-version ipv4|ipv6 vni <vni> udp-src" 15215 " <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst <ip-dst>" 15216 " eth-src <eth-src> eth-dst <eth-dst>", 15217 .tokens = { 15218 (void *)&cmd_set_vxlan_set, 15219 (void *)&cmd_set_vxlan_vxlan, 15220 (void *)&cmd_set_vxlan_ip_version, 15221 (void *)&cmd_set_vxlan_ip_version_value, 15222 (void *)&cmd_set_vxlan_vni, 15223 (void *)&cmd_set_vxlan_vni_value, 15224 (void *)&cmd_set_vxlan_udp_src, 15225 (void *)&cmd_set_vxlan_udp_src_value, 15226 (void *)&cmd_set_vxlan_udp_dst, 15227 (void *)&cmd_set_vxlan_udp_dst_value, 15228 (void *)&cmd_set_vxlan_ip_src, 15229 (void *)&cmd_set_vxlan_ip_src_value, 15230 (void *)&cmd_set_vxlan_ip_dst, 15231 (void *)&cmd_set_vxlan_ip_dst_value, 15232 (void *)&cmd_set_vxlan_eth_src, 15233 (void *)&cmd_set_vxlan_eth_src_value, 15234 (void *)&cmd_set_vxlan_eth_dst, 15235 (void *)&cmd_set_vxlan_eth_dst_value, 15236 NULL, 15237 }, 15238 }; 15239 15240 cmdline_parse_inst_t cmd_set_vxlan_tos_ttl = { 15241 .f = cmd_set_vxlan_parsed, 15242 .data = NULL, 15243 .help_str = "set vxlan-tos-ttl ip-version ipv4|ipv6 vni <vni> udp-src" 15244 " <udp-src> udp-dst <udp-dst> ip-tos <ip-tos> ip-ttl <ip-ttl>" 15245 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15246 " eth-dst <eth-dst>", 15247 .tokens = { 15248 (void *)&cmd_set_vxlan_set, 15249 (void *)&cmd_set_vxlan_vxlan_tos_ttl, 15250 (void *)&cmd_set_vxlan_ip_version, 15251 (void *)&cmd_set_vxlan_ip_version_value, 15252 (void *)&cmd_set_vxlan_vni, 15253 (void *)&cmd_set_vxlan_vni_value, 15254 (void *)&cmd_set_vxlan_udp_src, 15255 (void *)&cmd_set_vxlan_udp_src_value, 15256 (void *)&cmd_set_vxlan_udp_dst, 15257 (void *)&cmd_set_vxlan_udp_dst_value, 15258 (void *)&cmd_set_vxlan_ip_tos, 15259 (void *)&cmd_set_vxlan_ip_tos_value, 15260 (void *)&cmd_set_vxlan_ip_ttl, 15261 (void *)&cmd_set_vxlan_ip_ttl_value, 15262 (void *)&cmd_set_vxlan_ip_src, 15263 (void *)&cmd_set_vxlan_ip_src_value, 15264 (void *)&cmd_set_vxlan_ip_dst, 15265 (void *)&cmd_set_vxlan_ip_dst_value, 15266 (void *)&cmd_set_vxlan_eth_src, 15267 (void *)&cmd_set_vxlan_eth_src_value, 15268 (void *)&cmd_set_vxlan_eth_dst, 15269 (void *)&cmd_set_vxlan_eth_dst_value, 15270 NULL, 15271 }, 15272 }; 15273 15274 cmdline_parse_inst_t cmd_set_vxlan_with_vlan = { 15275 .f = cmd_set_vxlan_parsed, 15276 .data = NULL, 15277 .help_str = "set vxlan-with-vlan ip-version ipv4|ipv6 vni <vni>" 15278 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src> ip-dst" 15279 " <ip-dst> vlan-tci <vlan-tci> eth-src <eth-src> eth-dst" 15280 " <eth-dst>", 15281 .tokens = { 15282 (void *)&cmd_set_vxlan_set, 15283 (void *)&cmd_set_vxlan_vxlan_with_vlan, 15284 (void *)&cmd_set_vxlan_ip_version, 15285 (void *)&cmd_set_vxlan_ip_version_value, 15286 (void *)&cmd_set_vxlan_vni, 15287 (void *)&cmd_set_vxlan_vni_value, 15288 (void *)&cmd_set_vxlan_udp_src, 15289 (void *)&cmd_set_vxlan_udp_src_value, 15290 (void *)&cmd_set_vxlan_udp_dst, 15291 (void *)&cmd_set_vxlan_udp_dst_value, 15292 (void *)&cmd_set_vxlan_ip_src, 15293 (void *)&cmd_set_vxlan_ip_src_value, 15294 (void *)&cmd_set_vxlan_ip_dst, 15295 (void *)&cmd_set_vxlan_ip_dst_value, 15296 (void *)&cmd_set_vxlan_vlan, 15297 (void *)&cmd_set_vxlan_vlan_value, 15298 (void *)&cmd_set_vxlan_eth_src, 15299 (void *)&cmd_set_vxlan_eth_src_value, 15300 (void *)&cmd_set_vxlan_eth_dst, 15301 (void *)&cmd_set_vxlan_eth_dst_value, 15302 NULL, 15303 }, 15304 }; 15305 15306 /** Set NVGRE encapsulation details */ 15307 struct cmd_set_nvgre_result { 15308 cmdline_fixed_string_t set; 15309 cmdline_fixed_string_t nvgre; 15310 cmdline_fixed_string_t pos_token; 15311 cmdline_fixed_string_t ip_version; 15312 uint32_t tni; 15313 cmdline_ipaddr_t ip_src; 15314 cmdline_ipaddr_t ip_dst; 15315 uint16_t tci; 15316 struct ether_addr eth_src; 15317 struct ether_addr eth_dst; 15318 }; 15319 15320 cmdline_parse_token_string_t cmd_set_nvgre_set = 15321 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, set, "set"); 15322 cmdline_parse_token_string_t cmd_set_nvgre_nvgre = 15323 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, "nvgre"); 15324 cmdline_parse_token_string_t cmd_set_nvgre_nvgre_with_vlan = 15325 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, nvgre, 15326 "nvgre-with-vlan"); 15327 cmdline_parse_token_string_t cmd_set_nvgre_ip_version = 15328 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15329 "ip-version"); 15330 cmdline_parse_token_string_t cmd_set_nvgre_ip_version_value = 15331 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, ip_version, 15332 "ipv4#ipv6"); 15333 cmdline_parse_token_string_t cmd_set_nvgre_tni = 15334 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15335 "tni"); 15336 cmdline_parse_token_num_t cmd_set_nvgre_tni_value = 15337 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tni, UINT32); 15338 cmdline_parse_token_string_t cmd_set_nvgre_ip_src = 15339 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15340 "ip-src"); 15341 cmdline_parse_token_num_t cmd_set_nvgre_ip_src_value = 15342 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_src); 15343 cmdline_parse_token_string_t cmd_set_nvgre_ip_dst = 15344 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15345 "ip-dst"); 15346 cmdline_parse_token_ipaddr_t cmd_set_nvgre_ip_dst_value = 15347 TOKEN_IPADDR_INITIALIZER(struct cmd_set_nvgre_result, ip_dst); 15348 cmdline_parse_token_string_t cmd_set_nvgre_vlan = 15349 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15350 "vlan-tci"); 15351 cmdline_parse_token_num_t cmd_set_nvgre_vlan_value = 15352 TOKEN_NUM_INITIALIZER(struct cmd_set_nvgre_result, tci, UINT16); 15353 cmdline_parse_token_string_t cmd_set_nvgre_eth_src = 15354 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15355 "eth-src"); 15356 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_src_value = 15357 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_src); 15358 cmdline_parse_token_string_t cmd_set_nvgre_eth_dst = 15359 TOKEN_STRING_INITIALIZER(struct cmd_set_nvgre_result, pos_token, 15360 "eth-dst"); 15361 cmdline_parse_token_etheraddr_t cmd_set_nvgre_eth_dst_value = 15362 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_nvgre_result, eth_dst); 15363 15364 static void cmd_set_nvgre_parsed(void *parsed_result, 15365 __attribute__((unused)) struct cmdline *cl, 15366 __attribute__((unused)) void *data) 15367 { 15368 struct cmd_set_nvgre_result *res = parsed_result; 15369 union { 15370 uint32_t nvgre_tni; 15371 uint8_t tni[4]; 15372 } id = { 15373 .nvgre_tni = rte_cpu_to_be_32(res->tni) & RTE_BE32(0x00ffffff), 15374 }; 15375 15376 if (strcmp(res->nvgre, "nvgre") == 0) 15377 nvgre_encap_conf.select_vlan = 0; 15378 else if (strcmp(res->nvgre, "nvgre-with-vlan") == 0) 15379 nvgre_encap_conf.select_vlan = 1; 15380 if (strcmp(res->ip_version, "ipv4") == 0) 15381 nvgre_encap_conf.select_ipv4 = 1; 15382 else if (strcmp(res->ip_version, "ipv6") == 0) 15383 nvgre_encap_conf.select_ipv4 = 0; 15384 else 15385 return; 15386 rte_memcpy(nvgre_encap_conf.tni, &id.tni[1], 3); 15387 if (nvgre_encap_conf.select_ipv4) { 15388 IPV4_ADDR_TO_UINT(res->ip_src, nvgre_encap_conf.ipv4_src); 15389 IPV4_ADDR_TO_UINT(res->ip_dst, nvgre_encap_conf.ipv4_dst); 15390 } else { 15391 IPV6_ADDR_TO_ARRAY(res->ip_src, nvgre_encap_conf.ipv6_src); 15392 IPV6_ADDR_TO_ARRAY(res->ip_dst, nvgre_encap_conf.ipv6_dst); 15393 } 15394 if (nvgre_encap_conf.select_vlan) 15395 nvgre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15396 rte_memcpy(nvgre_encap_conf.eth_src, res->eth_src.addr_bytes, 15397 ETHER_ADDR_LEN); 15398 rte_memcpy(nvgre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15399 ETHER_ADDR_LEN); 15400 } 15401 15402 cmdline_parse_inst_t cmd_set_nvgre = { 15403 .f = cmd_set_nvgre_parsed, 15404 .data = NULL, 15405 .help_str = "set nvgre ip-version <ipv4|ipv6> tni <tni> ip-src" 15406 " <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15407 " eth-dst <eth-dst>", 15408 .tokens = { 15409 (void *)&cmd_set_nvgre_set, 15410 (void *)&cmd_set_nvgre_nvgre, 15411 (void *)&cmd_set_nvgre_ip_version, 15412 (void *)&cmd_set_nvgre_ip_version_value, 15413 (void *)&cmd_set_nvgre_tni, 15414 (void *)&cmd_set_nvgre_tni_value, 15415 (void *)&cmd_set_nvgre_ip_src, 15416 (void *)&cmd_set_nvgre_ip_src_value, 15417 (void *)&cmd_set_nvgre_ip_dst, 15418 (void *)&cmd_set_nvgre_ip_dst_value, 15419 (void *)&cmd_set_nvgre_eth_src, 15420 (void *)&cmd_set_nvgre_eth_src_value, 15421 (void *)&cmd_set_nvgre_eth_dst, 15422 (void *)&cmd_set_nvgre_eth_dst_value, 15423 NULL, 15424 }, 15425 }; 15426 15427 cmdline_parse_inst_t cmd_set_nvgre_with_vlan = { 15428 .f = cmd_set_nvgre_parsed, 15429 .data = NULL, 15430 .help_str = "set nvgre-with-vlan ip-version <ipv4|ipv6> tni <tni>" 15431 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 15432 " eth-src <eth-src> eth-dst <eth-dst>", 15433 .tokens = { 15434 (void *)&cmd_set_nvgre_set, 15435 (void *)&cmd_set_nvgre_nvgre_with_vlan, 15436 (void *)&cmd_set_nvgre_ip_version, 15437 (void *)&cmd_set_nvgre_ip_version_value, 15438 (void *)&cmd_set_nvgre_tni, 15439 (void *)&cmd_set_nvgre_tni_value, 15440 (void *)&cmd_set_nvgre_ip_src, 15441 (void *)&cmd_set_nvgre_ip_src_value, 15442 (void *)&cmd_set_nvgre_ip_dst, 15443 (void *)&cmd_set_nvgre_ip_dst_value, 15444 (void *)&cmd_set_nvgre_vlan, 15445 (void *)&cmd_set_nvgre_vlan_value, 15446 (void *)&cmd_set_nvgre_eth_src, 15447 (void *)&cmd_set_nvgre_eth_src_value, 15448 (void *)&cmd_set_nvgre_eth_dst, 15449 (void *)&cmd_set_nvgre_eth_dst_value, 15450 NULL, 15451 }, 15452 }; 15453 15454 /** Set L2 encapsulation details */ 15455 struct cmd_set_l2_encap_result { 15456 cmdline_fixed_string_t set; 15457 cmdline_fixed_string_t l2_encap; 15458 cmdline_fixed_string_t pos_token; 15459 cmdline_fixed_string_t ip_version; 15460 uint32_t vlan_present:1; 15461 uint16_t tci; 15462 struct ether_addr eth_src; 15463 struct ether_addr eth_dst; 15464 }; 15465 15466 cmdline_parse_token_string_t cmd_set_l2_encap_set = 15467 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, set, "set"); 15468 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap = 15469 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, "l2_encap"); 15470 cmdline_parse_token_string_t cmd_set_l2_encap_l2_encap_with_vlan = 15471 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, l2_encap, 15472 "l2_encap-with-vlan"); 15473 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version = 15474 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15475 "ip-version"); 15476 cmdline_parse_token_string_t cmd_set_l2_encap_ip_version_value = 15477 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, ip_version, 15478 "ipv4#ipv6"); 15479 cmdline_parse_token_string_t cmd_set_l2_encap_vlan = 15480 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15481 "vlan-tci"); 15482 cmdline_parse_token_num_t cmd_set_l2_encap_vlan_value = 15483 TOKEN_NUM_INITIALIZER(struct cmd_set_l2_encap_result, tci, UINT16); 15484 cmdline_parse_token_string_t cmd_set_l2_encap_eth_src = 15485 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15486 "eth-src"); 15487 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_src_value = 15488 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_src); 15489 cmdline_parse_token_string_t cmd_set_l2_encap_eth_dst = 15490 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_encap_result, pos_token, 15491 "eth-dst"); 15492 cmdline_parse_token_etheraddr_t cmd_set_l2_encap_eth_dst_value = 15493 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_l2_encap_result, eth_dst); 15494 15495 static void cmd_set_l2_encap_parsed(void *parsed_result, 15496 __attribute__((unused)) struct cmdline *cl, 15497 __attribute__((unused)) void *data) 15498 { 15499 struct cmd_set_l2_encap_result *res = parsed_result; 15500 15501 if (strcmp(res->l2_encap, "l2_encap") == 0) 15502 l2_encap_conf.select_vlan = 0; 15503 else if (strcmp(res->l2_encap, "l2_encap-with-vlan") == 0) 15504 l2_encap_conf.select_vlan = 1; 15505 if (strcmp(res->ip_version, "ipv4") == 0) 15506 l2_encap_conf.select_ipv4 = 1; 15507 else if (strcmp(res->ip_version, "ipv6") == 0) 15508 l2_encap_conf.select_ipv4 = 0; 15509 else 15510 return; 15511 if (l2_encap_conf.select_vlan) 15512 l2_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15513 rte_memcpy(l2_encap_conf.eth_src, res->eth_src.addr_bytes, 15514 ETHER_ADDR_LEN); 15515 rte_memcpy(l2_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15516 ETHER_ADDR_LEN); 15517 } 15518 15519 cmdline_parse_inst_t cmd_set_l2_encap = { 15520 .f = cmd_set_l2_encap_parsed, 15521 .data = NULL, 15522 .help_str = "set l2_encap ip-version ipv4|ipv6" 15523 " eth-src <eth-src> eth-dst <eth-dst>", 15524 .tokens = { 15525 (void *)&cmd_set_l2_encap_set, 15526 (void *)&cmd_set_l2_encap_l2_encap, 15527 (void *)&cmd_set_l2_encap_ip_version, 15528 (void *)&cmd_set_l2_encap_ip_version_value, 15529 (void *)&cmd_set_l2_encap_eth_src, 15530 (void *)&cmd_set_l2_encap_eth_src_value, 15531 (void *)&cmd_set_l2_encap_eth_dst, 15532 (void *)&cmd_set_l2_encap_eth_dst_value, 15533 NULL, 15534 }, 15535 }; 15536 15537 cmdline_parse_inst_t cmd_set_l2_encap_with_vlan = { 15538 .f = cmd_set_l2_encap_parsed, 15539 .data = NULL, 15540 .help_str = "set l2_encap-with-vlan ip-version ipv4|ipv6" 15541 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 15542 .tokens = { 15543 (void *)&cmd_set_l2_encap_set, 15544 (void *)&cmd_set_l2_encap_l2_encap_with_vlan, 15545 (void *)&cmd_set_l2_encap_ip_version, 15546 (void *)&cmd_set_l2_encap_ip_version_value, 15547 (void *)&cmd_set_l2_encap_vlan, 15548 (void *)&cmd_set_l2_encap_vlan_value, 15549 (void *)&cmd_set_l2_encap_eth_src, 15550 (void *)&cmd_set_l2_encap_eth_src_value, 15551 (void *)&cmd_set_l2_encap_eth_dst, 15552 (void *)&cmd_set_l2_encap_eth_dst_value, 15553 NULL, 15554 }, 15555 }; 15556 15557 /** Set L2 decapsulation details */ 15558 struct cmd_set_l2_decap_result { 15559 cmdline_fixed_string_t set; 15560 cmdline_fixed_string_t l2_decap; 15561 cmdline_fixed_string_t pos_token; 15562 uint32_t vlan_present:1; 15563 }; 15564 15565 cmdline_parse_token_string_t cmd_set_l2_decap_set = 15566 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, set, "set"); 15567 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap = 15568 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 15569 "l2_decap"); 15570 cmdline_parse_token_string_t cmd_set_l2_decap_l2_decap_with_vlan = 15571 TOKEN_STRING_INITIALIZER(struct cmd_set_l2_decap_result, l2_decap, 15572 "l2_decap-with-vlan"); 15573 15574 static void cmd_set_l2_decap_parsed(void *parsed_result, 15575 __attribute__((unused)) struct cmdline *cl, 15576 __attribute__((unused)) void *data) 15577 { 15578 struct cmd_set_l2_decap_result *res = parsed_result; 15579 15580 if (strcmp(res->l2_decap, "l2_decap") == 0) 15581 l2_decap_conf.select_vlan = 0; 15582 else if (strcmp(res->l2_decap, "l2_decap-with-vlan") == 0) 15583 l2_decap_conf.select_vlan = 1; 15584 } 15585 15586 cmdline_parse_inst_t cmd_set_l2_decap = { 15587 .f = cmd_set_l2_decap_parsed, 15588 .data = NULL, 15589 .help_str = "set l2_decap", 15590 .tokens = { 15591 (void *)&cmd_set_l2_decap_set, 15592 (void *)&cmd_set_l2_decap_l2_decap, 15593 NULL, 15594 }, 15595 }; 15596 15597 cmdline_parse_inst_t cmd_set_l2_decap_with_vlan = { 15598 .f = cmd_set_l2_decap_parsed, 15599 .data = NULL, 15600 .help_str = "set l2_decap-with-vlan", 15601 .tokens = { 15602 (void *)&cmd_set_l2_decap_set, 15603 (void *)&cmd_set_l2_decap_l2_decap_with_vlan, 15604 NULL, 15605 }, 15606 }; 15607 15608 /** Set MPLSoGRE encapsulation details */ 15609 struct cmd_set_mplsogre_encap_result { 15610 cmdline_fixed_string_t set; 15611 cmdline_fixed_string_t mplsogre; 15612 cmdline_fixed_string_t pos_token; 15613 cmdline_fixed_string_t ip_version; 15614 uint32_t vlan_present:1; 15615 uint32_t label; 15616 cmdline_ipaddr_t ip_src; 15617 cmdline_ipaddr_t ip_dst; 15618 uint16_t tci; 15619 struct ether_addr eth_src; 15620 struct ether_addr eth_dst; 15621 }; 15622 15623 cmdline_parse_token_string_t cmd_set_mplsogre_encap_set = 15624 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, set, 15625 "set"); 15626 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap = 15627 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, mplsogre, 15628 "mplsogre_encap"); 15629 cmdline_parse_token_string_t cmd_set_mplsogre_encap_mplsogre_encap_with_vlan = 15630 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15631 mplsogre, "mplsogre_encap-with-vlan"); 15632 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version = 15633 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15634 pos_token, "ip-version"); 15635 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_version_value = 15636 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15637 ip_version, "ipv4#ipv6"); 15638 cmdline_parse_token_string_t cmd_set_mplsogre_encap_label = 15639 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15640 pos_token, "label"); 15641 cmdline_parse_token_num_t cmd_set_mplsogre_encap_label_value = 15642 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, label, 15643 UINT32); 15644 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_src = 15645 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15646 pos_token, "ip-src"); 15647 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_src_value = 15648 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_src); 15649 cmdline_parse_token_string_t cmd_set_mplsogre_encap_ip_dst = 15650 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15651 pos_token, "ip-dst"); 15652 cmdline_parse_token_ipaddr_t cmd_set_mplsogre_encap_ip_dst_value = 15653 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, ip_dst); 15654 cmdline_parse_token_string_t cmd_set_mplsogre_encap_vlan = 15655 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15656 pos_token, "vlan-tci"); 15657 cmdline_parse_token_num_t cmd_set_mplsogre_encap_vlan_value = 15658 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_encap_result, tci, 15659 UINT16); 15660 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_src = 15661 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15662 pos_token, "eth-src"); 15663 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_src_value = 15664 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15665 eth_src); 15666 cmdline_parse_token_string_t cmd_set_mplsogre_encap_eth_dst = 15667 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15668 pos_token, "eth-dst"); 15669 cmdline_parse_token_etheraddr_t cmd_set_mplsogre_encap_eth_dst_value = 15670 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_encap_result, 15671 eth_dst); 15672 15673 static void cmd_set_mplsogre_encap_parsed(void *parsed_result, 15674 __attribute__((unused)) struct cmdline *cl, 15675 __attribute__((unused)) void *data) 15676 { 15677 struct cmd_set_mplsogre_encap_result *res = parsed_result; 15678 union { 15679 uint32_t mplsogre_label; 15680 uint8_t label[4]; 15681 } id = { 15682 .mplsogre_label = rte_cpu_to_be_32(res->label<<12), 15683 }; 15684 15685 if (strcmp(res->mplsogre, "mplsogre_encap") == 0) 15686 mplsogre_encap_conf.select_vlan = 0; 15687 else if (strcmp(res->mplsogre, "mplsogre_encap-with-vlan") == 0) 15688 mplsogre_encap_conf.select_vlan = 1; 15689 if (strcmp(res->ip_version, "ipv4") == 0) 15690 mplsogre_encap_conf.select_ipv4 = 1; 15691 else if (strcmp(res->ip_version, "ipv6") == 0) 15692 mplsogre_encap_conf.select_ipv4 = 0; 15693 else 15694 return; 15695 rte_memcpy(mplsogre_encap_conf.label, &id.label, 3); 15696 if (mplsogre_encap_conf.select_ipv4) { 15697 IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src); 15698 IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst); 15699 } else { 15700 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src); 15701 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst); 15702 } 15703 if (mplsogre_encap_conf.select_vlan) 15704 mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15705 rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes, 15706 ETHER_ADDR_LEN); 15707 rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15708 ETHER_ADDR_LEN); 15709 } 15710 15711 cmdline_parse_inst_t cmd_set_mplsogre_encap = { 15712 .f = cmd_set_mplsogre_encap_parsed, 15713 .data = NULL, 15714 .help_str = "set mplsogre_encap ip-version ipv4|ipv6 label <label>" 15715 " ip-src <ip-src> ip-dst <ip-dst> eth-src <eth-src>" 15716 " eth-dst <eth-dst>", 15717 .tokens = { 15718 (void *)&cmd_set_mplsogre_encap_set, 15719 (void *)&cmd_set_mplsogre_encap_mplsogre_encap, 15720 (void *)&cmd_set_mplsogre_encap_ip_version, 15721 (void *)&cmd_set_mplsogre_encap_ip_version_value, 15722 (void *)&cmd_set_mplsogre_encap_label, 15723 (void *)&cmd_set_mplsogre_encap_label_value, 15724 (void *)&cmd_set_mplsogre_encap_ip_src, 15725 (void *)&cmd_set_mplsogre_encap_ip_src_value, 15726 (void *)&cmd_set_mplsogre_encap_ip_dst, 15727 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 15728 (void *)&cmd_set_mplsogre_encap_eth_src, 15729 (void *)&cmd_set_mplsogre_encap_eth_src_value, 15730 (void *)&cmd_set_mplsogre_encap_eth_dst, 15731 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 15732 NULL, 15733 }, 15734 }; 15735 15736 cmdline_parse_inst_t cmd_set_mplsogre_encap_with_vlan = { 15737 .f = cmd_set_mplsogre_encap_parsed, 15738 .data = NULL, 15739 .help_str = "set mplsogre_encap-with-vlan ip-version ipv4|ipv6" 15740 " label <label> ip-src <ip-src> ip-dst <ip-dst>" 15741 " vlan-tci <vlan-tci> eth-src <eth-src> eth-dst <eth-dst>", 15742 .tokens = { 15743 (void *)&cmd_set_mplsogre_encap_set, 15744 (void *)&cmd_set_mplsogre_encap_mplsogre_encap_with_vlan, 15745 (void *)&cmd_set_mplsogre_encap_ip_version, 15746 (void *)&cmd_set_mplsogre_encap_ip_version_value, 15747 (void *)&cmd_set_mplsogre_encap_label, 15748 (void *)&cmd_set_mplsogre_encap_label_value, 15749 (void *)&cmd_set_mplsogre_encap_ip_src, 15750 (void *)&cmd_set_mplsogre_encap_ip_src_value, 15751 (void *)&cmd_set_mplsogre_encap_ip_dst, 15752 (void *)&cmd_set_mplsogre_encap_ip_dst_value, 15753 (void *)&cmd_set_mplsogre_encap_vlan, 15754 (void *)&cmd_set_mplsogre_encap_vlan_value, 15755 (void *)&cmd_set_mplsogre_encap_eth_src, 15756 (void *)&cmd_set_mplsogre_encap_eth_src_value, 15757 (void *)&cmd_set_mplsogre_encap_eth_dst, 15758 (void *)&cmd_set_mplsogre_encap_eth_dst_value, 15759 NULL, 15760 }, 15761 }; 15762 15763 /** Set MPLSoGRE decapsulation details */ 15764 struct cmd_set_mplsogre_decap_result { 15765 cmdline_fixed_string_t set; 15766 cmdline_fixed_string_t mplsogre; 15767 cmdline_fixed_string_t pos_token; 15768 cmdline_fixed_string_t ip_version; 15769 uint32_t vlan_present:1; 15770 }; 15771 15772 cmdline_parse_token_string_t cmd_set_mplsogre_decap_set = 15773 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, set, 15774 "set"); 15775 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap = 15776 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, mplsogre, 15777 "mplsogre_decap"); 15778 cmdline_parse_token_string_t cmd_set_mplsogre_decap_mplsogre_decap_with_vlan = 15779 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 15780 mplsogre, "mplsogre_decap-with-vlan"); 15781 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version = 15782 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 15783 pos_token, "ip-version"); 15784 cmdline_parse_token_string_t cmd_set_mplsogre_decap_ip_version_value = 15785 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_decap_result, 15786 ip_version, "ipv4#ipv6"); 15787 15788 static void cmd_set_mplsogre_decap_parsed(void *parsed_result, 15789 __attribute__((unused)) struct cmdline *cl, 15790 __attribute__((unused)) void *data) 15791 { 15792 struct cmd_set_mplsogre_decap_result *res = parsed_result; 15793 15794 if (strcmp(res->mplsogre, "mplsogre_decap") == 0) 15795 mplsogre_decap_conf.select_vlan = 0; 15796 else if (strcmp(res->mplsogre, "mplsogre_decap-with-vlan") == 0) 15797 mplsogre_decap_conf.select_vlan = 1; 15798 if (strcmp(res->ip_version, "ipv4") == 0) 15799 mplsogre_decap_conf.select_ipv4 = 1; 15800 else if (strcmp(res->ip_version, "ipv6") == 0) 15801 mplsogre_decap_conf.select_ipv4 = 0; 15802 } 15803 15804 cmdline_parse_inst_t cmd_set_mplsogre_decap = { 15805 .f = cmd_set_mplsogre_decap_parsed, 15806 .data = NULL, 15807 .help_str = "set mplsogre_decap ip-version ipv4|ipv6", 15808 .tokens = { 15809 (void *)&cmd_set_mplsogre_decap_set, 15810 (void *)&cmd_set_mplsogre_decap_mplsogre_decap, 15811 (void *)&cmd_set_mplsogre_decap_ip_version, 15812 (void *)&cmd_set_mplsogre_decap_ip_version_value, 15813 NULL, 15814 }, 15815 }; 15816 15817 cmdline_parse_inst_t cmd_set_mplsogre_decap_with_vlan = { 15818 .f = cmd_set_mplsogre_decap_parsed, 15819 .data = NULL, 15820 .help_str = "set mplsogre_decap-with-vlan ip-version ipv4|ipv6", 15821 .tokens = { 15822 (void *)&cmd_set_mplsogre_decap_set, 15823 (void *)&cmd_set_mplsogre_decap_mplsogre_decap_with_vlan, 15824 (void *)&cmd_set_mplsogre_decap_ip_version, 15825 (void *)&cmd_set_mplsogre_decap_ip_version_value, 15826 NULL, 15827 }, 15828 }; 15829 15830 /** Set MPLSoUDP encapsulation details */ 15831 struct cmd_set_mplsoudp_encap_result { 15832 cmdline_fixed_string_t set; 15833 cmdline_fixed_string_t mplsoudp; 15834 cmdline_fixed_string_t pos_token; 15835 cmdline_fixed_string_t ip_version; 15836 uint32_t vlan_present:1; 15837 uint32_t label; 15838 uint16_t udp_src; 15839 uint16_t udp_dst; 15840 cmdline_ipaddr_t ip_src; 15841 cmdline_ipaddr_t ip_dst; 15842 uint16_t tci; 15843 struct ether_addr eth_src; 15844 struct ether_addr eth_dst; 15845 }; 15846 15847 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_set = 15848 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, set, 15849 "set"); 15850 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap = 15851 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, mplsoudp, 15852 "mplsoudp_encap"); 15853 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan = 15854 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15855 mplsoudp, "mplsoudp_encap-with-vlan"); 15856 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version = 15857 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15858 pos_token, "ip-version"); 15859 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_version_value = 15860 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15861 ip_version, "ipv4#ipv6"); 15862 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_label = 15863 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15864 pos_token, "label"); 15865 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_label_value = 15866 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, label, 15867 UINT32); 15868 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_src = 15869 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15870 pos_token, "udp-src"); 15871 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_src_value = 15872 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_src, 15873 UINT16); 15874 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_udp_dst = 15875 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15876 pos_token, "udp-dst"); 15877 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_udp_dst_value = 15878 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, udp_dst, 15879 UINT16); 15880 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_src = 15881 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15882 pos_token, "ip-src"); 15883 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_src_value = 15884 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_src); 15885 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_ip_dst = 15886 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15887 pos_token, "ip-dst"); 15888 cmdline_parse_token_ipaddr_t cmd_set_mplsoudp_encap_ip_dst_value = 15889 TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, ip_dst); 15890 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_vlan = 15891 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15892 pos_token, "vlan-tci"); 15893 cmdline_parse_token_num_t cmd_set_mplsoudp_encap_vlan_value = 15894 TOKEN_NUM_INITIALIZER(struct cmd_set_mplsoudp_encap_result, tci, 15895 UINT16); 15896 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_src = 15897 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15898 pos_token, "eth-src"); 15899 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_src_value = 15900 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15901 eth_src); 15902 cmdline_parse_token_string_t cmd_set_mplsoudp_encap_eth_dst = 15903 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15904 pos_token, "eth-dst"); 15905 cmdline_parse_token_etheraddr_t cmd_set_mplsoudp_encap_eth_dst_value = 15906 TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsoudp_encap_result, 15907 eth_dst); 15908 15909 static void cmd_set_mplsoudp_encap_parsed(void *parsed_result, 15910 __attribute__((unused)) struct cmdline *cl, 15911 __attribute__((unused)) void *data) 15912 { 15913 struct cmd_set_mplsoudp_encap_result *res = parsed_result; 15914 union { 15915 uint32_t mplsoudp_label; 15916 uint8_t label[4]; 15917 } id = { 15918 .mplsoudp_label = rte_cpu_to_be_32(res->label<<12), 15919 }; 15920 15921 if (strcmp(res->mplsoudp, "mplsoudp_encap") == 0) 15922 mplsoudp_encap_conf.select_vlan = 0; 15923 else if (strcmp(res->mplsoudp, "mplsoudp_encap-with-vlan") == 0) 15924 mplsoudp_encap_conf.select_vlan = 1; 15925 if (strcmp(res->ip_version, "ipv4") == 0) 15926 mplsoudp_encap_conf.select_ipv4 = 1; 15927 else if (strcmp(res->ip_version, "ipv6") == 0) 15928 mplsoudp_encap_conf.select_ipv4 = 0; 15929 else 15930 return; 15931 rte_memcpy(mplsoudp_encap_conf.label, &id.label, 3); 15932 mplsoudp_encap_conf.udp_src = rte_cpu_to_be_16(res->udp_src); 15933 mplsoudp_encap_conf.udp_dst = rte_cpu_to_be_16(res->udp_dst); 15934 if (mplsoudp_encap_conf.select_ipv4) { 15935 IPV4_ADDR_TO_UINT(res->ip_src, mplsoudp_encap_conf.ipv4_src); 15936 IPV4_ADDR_TO_UINT(res->ip_dst, mplsoudp_encap_conf.ipv4_dst); 15937 } else { 15938 IPV6_ADDR_TO_ARRAY(res->ip_src, mplsoudp_encap_conf.ipv6_src); 15939 IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsoudp_encap_conf.ipv6_dst); 15940 } 15941 if (mplsoudp_encap_conf.select_vlan) 15942 mplsoudp_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); 15943 rte_memcpy(mplsoudp_encap_conf.eth_src, res->eth_src.addr_bytes, 15944 ETHER_ADDR_LEN); 15945 rte_memcpy(mplsoudp_encap_conf.eth_dst, res->eth_dst.addr_bytes, 15946 ETHER_ADDR_LEN); 15947 } 15948 15949 cmdline_parse_inst_t cmd_set_mplsoudp_encap = { 15950 .f = cmd_set_mplsoudp_encap_parsed, 15951 .data = NULL, 15952 .help_str = "set mplsoudp_encap ip-version ipv4|ipv6 label <label>" 15953 " udp-src <udp-src> udp-dst <udp-dst> ip-src <ip-src>" 15954 " ip-dst <ip-dst> eth-src <eth-src> eth-dst <eth-dst>", 15955 .tokens = { 15956 (void *)&cmd_set_mplsoudp_encap_set, 15957 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap, 15958 (void *)&cmd_set_mplsoudp_encap_ip_version, 15959 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 15960 (void *)&cmd_set_mplsoudp_encap_label, 15961 (void *)&cmd_set_mplsoudp_encap_label_value, 15962 (void *)&cmd_set_mplsoudp_encap_udp_src, 15963 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 15964 (void *)&cmd_set_mplsoudp_encap_udp_dst, 15965 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 15966 (void *)&cmd_set_mplsoudp_encap_ip_src, 15967 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 15968 (void *)&cmd_set_mplsoudp_encap_ip_dst, 15969 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 15970 (void *)&cmd_set_mplsoudp_encap_eth_src, 15971 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 15972 (void *)&cmd_set_mplsoudp_encap_eth_dst, 15973 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 15974 NULL, 15975 }, 15976 }; 15977 15978 cmdline_parse_inst_t cmd_set_mplsoudp_encap_with_vlan = { 15979 .f = cmd_set_mplsoudp_encap_parsed, 15980 .data = NULL, 15981 .help_str = "set mplsoudp_encap-with-vlan ip-version ipv4|ipv6" 15982 " label <label> udp-src <udp-src> udp-dst <udp-dst>" 15983 " ip-src <ip-src> ip-dst <ip-dst> vlan-tci <vlan-tci>" 15984 " eth-src <eth-src> eth-dst <eth-dst>", 15985 .tokens = { 15986 (void *)&cmd_set_mplsoudp_encap_set, 15987 (void *)&cmd_set_mplsoudp_encap_mplsoudp_encap_with_vlan, 15988 (void *)&cmd_set_mplsoudp_encap_ip_version, 15989 (void *)&cmd_set_mplsoudp_encap_ip_version_value, 15990 (void *)&cmd_set_mplsoudp_encap_label, 15991 (void *)&cmd_set_mplsoudp_encap_label_value, 15992 (void *)&cmd_set_mplsoudp_encap_udp_src, 15993 (void *)&cmd_set_mplsoudp_encap_udp_src_value, 15994 (void *)&cmd_set_mplsoudp_encap_udp_dst, 15995 (void *)&cmd_set_mplsoudp_encap_udp_dst_value, 15996 (void *)&cmd_set_mplsoudp_encap_ip_src, 15997 (void *)&cmd_set_mplsoudp_encap_ip_src_value, 15998 (void *)&cmd_set_mplsoudp_encap_ip_dst, 15999 (void *)&cmd_set_mplsoudp_encap_ip_dst_value, 16000 (void *)&cmd_set_mplsoudp_encap_vlan, 16001 (void *)&cmd_set_mplsoudp_encap_vlan_value, 16002 (void *)&cmd_set_mplsoudp_encap_eth_src, 16003 (void *)&cmd_set_mplsoudp_encap_eth_src_value, 16004 (void *)&cmd_set_mplsoudp_encap_eth_dst, 16005 (void *)&cmd_set_mplsoudp_encap_eth_dst_value, 16006 NULL, 16007 }, 16008 }; 16009 16010 /** Set MPLSoUDP decapsulation details */ 16011 struct cmd_set_mplsoudp_decap_result { 16012 cmdline_fixed_string_t set; 16013 cmdline_fixed_string_t mplsoudp; 16014 cmdline_fixed_string_t pos_token; 16015 cmdline_fixed_string_t ip_version; 16016 uint32_t vlan_present:1; 16017 }; 16018 16019 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_set = 16020 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, set, 16021 "set"); 16022 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap = 16023 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, mplsoudp, 16024 "mplsoudp_decap"); 16025 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan = 16026 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16027 mplsoudp, "mplsoudp_decap-with-vlan"); 16028 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version = 16029 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16030 pos_token, "ip-version"); 16031 cmdline_parse_token_string_t cmd_set_mplsoudp_decap_ip_version_value = 16032 TOKEN_STRING_INITIALIZER(struct cmd_set_mplsoudp_decap_result, 16033 ip_version, "ipv4#ipv6"); 16034 16035 static void cmd_set_mplsoudp_decap_parsed(void *parsed_result, 16036 __attribute__((unused)) struct cmdline *cl, 16037 __attribute__((unused)) void *data) 16038 { 16039 struct cmd_set_mplsoudp_decap_result *res = parsed_result; 16040 16041 if (strcmp(res->mplsoudp, "mplsoudp_decap") == 0) 16042 mplsoudp_decap_conf.select_vlan = 0; 16043 else if (strcmp(res->mplsoudp, "mplsoudp_decap-with-vlan") == 0) 16044 mplsoudp_decap_conf.select_vlan = 1; 16045 if (strcmp(res->ip_version, "ipv4") == 0) 16046 mplsoudp_decap_conf.select_ipv4 = 1; 16047 else if (strcmp(res->ip_version, "ipv6") == 0) 16048 mplsoudp_decap_conf.select_ipv4 = 0; 16049 } 16050 16051 cmdline_parse_inst_t cmd_set_mplsoudp_decap = { 16052 .f = cmd_set_mplsoudp_decap_parsed, 16053 .data = NULL, 16054 .help_str = "set mplsoudp_decap ip-version ipv4|ipv6", 16055 .tokens = { 16056 (void *)&cmd_set_mplsoudp_decap_set, 16057 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap, 16058 (void *)&cmd_set_mplsoudp_decap_ip_version, 16059 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 16060 NULL, 16061 }, 16062 }; 16063 16064 cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { 16065 .f = cmd_set_mplsoudp_decap_parsed, 16066 .data = NULL, 16067 .help_str = "set mplsoudp_decap-with-vlan ip-version ipv4|ipv6", 16068 .tokens = { 16069 (void *)&cmd_set_mplsoudp_decap_set, 16070 (void *)&cmd_set_mplsoudp_decap_mplsoudp_decap_with_vlan, 16071 (void *)&cmd_set_mplsoudp_decap_ip_version, 16072 (void *)&cmd_set_mplsoudp_decap_ip_version_value, 16073 NULL, 16074 }, 16075 }; 16076 16077 /* Strict link priority scheduling mode setting */ 16078 static void 16079 cmd_strict_link_prio_parsed( 16080 void *parsed_result, 16081 __attribute__((unused)) struct cmdline *cl, 16082 __attribute__((unused)) void *data) 16083 { 16084 struct cmd_vf_tc_bw_result *res = parsed_result; 16085 int ret = -ENOTSUP; 16086 16087 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16088 return; 16089 16090 #ifdef RTE_LIBRTE_I40E_PMD 16091 ret = rte_pmd_i40e_set_tc_strict_prio(res->port_id, res->tc_map); 16092 #endif 16093 16094 switch (ret) { 16095 case 0: 16096 break; 16097 case -EINVAL: 16098 printf("invalid tc_bitmap 0x%x\n", res->tc_map); 16099 break; 16100 case -ENODEV: 16101 printf("invalid port_id %d\n", res->port_id); 16102 break; 16103 case -ENOTSUP: 16104 printf("function not implemented\n"); 16105 break; 16106 default: 16107 printf("programming error: (%s)\n", strerror(-ret)); 16108 } 16109 } 16110 16111 cmdline_parse_inst_t cmd_strict_link_prio = { 16112 .f = cmd_strict_link_prio_parsed, 16113 .data = NULL, 16114 .help_str = "set tx strict-link-priority <port_id> <tc_bitmap>", 16115 .tokens = { 16116 (void *)&cmd_vf_tc_bw_set, 16117 (void *)&cmd_vf_tc_bw_tx, 16118 (void *)&cmd_vf_tc_bw_strict_link_prio, 16119 (void *)&cmd_vf_tc_bw_port_id, 16120 (void *)&cmd_vf_tc_bw_tc_map, 16121 NULL, 16122 }, 16123 }; 16124 16125 /* Load dynamic device personalization*/ 16126 struct cmd_ddp_add_result { 16127 cmdline_fixed_string_t ddp; 16128 cmdline_fixed_string_t add; 16129 portid_t port_id; 16130 char filepath[]; 16131 }; 16132 16133 cmdline_parse_token_string_t cmd_ddp_add_ddp = 16134 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, ddp, "ddp"); 16135 cmdline_parse_token_string_t cmd_ddp_add_add = 16136 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, add, "add"); 16137 cmdline_parse_token_num_t cmd_ddp_add_port_id = 16138 TOKEN_NUM_INITIALIZER(struct cmd_ddp_add_result, port_id, UINT16); 16139 cmdline_parse_token_string_t cmd_ddp_add_filepath = 16140 TOKEN_STRING_INITIALIZER(struct cmd_ddp_add_result, filepath, NULL); 16141 16142 static void 16143 cmd_ddp_add_parsed( 16144 void *parsed_result, 16145 __attribute__((unused)) struct cmdline *cl, 16146 __attribute__((unused)) void *data) 16147 { 16148 struct cmd_ddp_add_result *res = parsed_result; 16149 uint8_t *buff; 16150 uint32_t size; 16151 char *filepath; 16152 char *file_fld[2]; 16153 int file_num; 16154 int ret = -ENOTSUP; 16155 16156 if (!all_ports_stopped()) { 16157 printf("Please stop all ports first\n"); 16158 return; 16159 } 16160 16161 filepath = strdup(res->filepath); 16162 if (filepath == NULL) { 16163 printf("Failed to allocate memory\n"); 16164 return; 16165 } 16166 file_num = rte_strsplit(filepath, strlen(filepath), file_fld, 2, ','); 16167 16168 buff = open_file(file_fld[0], &size); 16169 if (!buff) { 16170 free((void *)filepath); 16171 return; 16172 } 16173 16174 #ifdef RTE_LIBRTE_I40E_PMD 16175 if (ret == -ENOTSUP) 16176 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 16177 buff, size, 16178 RTE_PMD_I40E_PKG_OP_WR_ADD); 16179 #endif 16180 16181 if (ret == -EEXIST) 16182 printf("Profile has already existed.\n"); 16183 else if (ret < 0) 16184 printf("Failed to load profile.\n"); 16185 else if (file_num == 2) 16186 save_file(file_fld[1], buff, size); 16187 16188 close_file(buff); 16189 free((void *)filepath); 16190 } 16191 16192 cmdline_parse_inst_t cmd_ddp_add = { 16193 .f = cmd_ddp_add_parsed, 16194 .data = NULL, 16195 .help_str = "ddp add <port_id> <profile_path[,backup_profile_path]>", 16196 .tokens = { 16197 (void *)&cmd_ddp_add_ddp, 16198 (void *)&cmd_ddp_add_add, 16199 (void *)&cmd_ddp_add_port_id, 16200 (void *)&cmd_ddp_add_filepath, 16201 NULL, 16202 }, 16203 }; 16204 16205 /* Delete dynamic device personalization*/ 16206 struct cmd_ddp_del_result { 16207 cmdline_fixed_string_t ddp; 16208 cmdline_fixed_string_t del; 16209 portid_t port_id; 16210 char filepath[]; 16211 }; 16212 16213 cmdline_parse_token_string_t cmd_ddp_del_ddp = 16214 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, ddp, "ddp"); 16215 cmdline_parse_token_string_t cmd_ddp_del_del = 16216 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, del, "del"); 16217 cmdline_parse_token_num_t cmd_ddp_del_port_id = 16218 TOKEN_NUM_INITIALIZER(struct cmd_ddp_del_result, port_id, UINT16); 16219 cmdline_parse_token_string_t cmd_ddp_del_filepath = 16220 TOKEN_STRING_INITIALIZER(struct cmd_ddp_del_result, filepath, NULL); 16221 16222 static void 16223 cmd_ddp_del_parsed( 16224 void *parsed_result, 16225 __attribute__((unused)) struct cmdline *cl, 16226 __attribute__((unused)) void *data) 16227 { 16228 struct cmd_ddp_del_result *res = parsed_result; 16229 uint8_t *buff; 16230 uint32_t size; 16231 int ret = -ENOTSUP; 16232 16233 if (!all_ports_stopped()) { 16234 printf("Please stop all ports first\n"); 16235 return; 16236 } 16237 16238 buff = open_file(res->filepath, &size); 16239 if (!buff) 16240 return; 16241 16242 #ifdef RTE_LIBRTE_I40E_PMD 16243 if (ret == -ENOTSUP) 16244 ret = rte_pmd_i40e_process_ddp_package(res->port_id, 16245 buff, size, 16246 RTE_PMD_I40E_PKG_OP_WR_DEL); 16247 #endif 16248 16249 if (ret == -EACCES) 16250 printf("Profile does not exist.\n"); 16251 else if (ret < 0) 16252 printf("Failed to delete profile.\n"); 16253 16254 close_file(buff); 16255 } 16256 16257 cmdline_parse_inst_t cmd_ddp_del = { 16258 .f = cmd_ddp_del_parsed, 16259 .data = NULL, 16260 .help_str = "ddp del <port_id> <backup_profile_path>", 16261 .tokens = { 16262 (void *)&cmd_ddp_del_ddp, 16263 (void *)&cmd_ddp_del_del, 16264 (void *)&cmd_ddp_del_port_id, 16265 (void *)&cmd_ddp_del_filepath, 16266 NULL, 16267 }, 16268 }; 16269 16270 /* Get dynamic device personalization profile info */ 16271 struct cmd_ddp_info_result { 16272 cmdline_fixed_string_t ddp; 16273 cmdline_fixed_string_t get; 16274 cmdline_fixed_string_t info; 16275 char filepath[]; 16276 }; 16277 16278 cmdline_parse_token_string_t cmd_ddp_info_ddp = 16279 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, ddp, "ddp"); 16280 cmdline_parse_token_string_t cmd_ddp_info_get = 16281 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, get, "get"); 16282 cmdline_parse_token_string_t cmd_ddp_info_info = 16283 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, info, "info"); 16284 cmdline_parse_token_string_t cmd_ddp_info_filepath = 16285 TOKEN_STRING_INITIALIZER(struct cmd_ddp_info_result, filepath, NULL); 16286 16287 static void 16288 cmd_ddp_info_parsed( 16289 void *parsed_result, 16290 __attribute__((unused)) struct cmdline *cl, 16291 __attribute__((unused)) void *data) 16292 { 16293 struct cmd_ddp_info_result *res = parsed_result; 16294 uint8_t *pkg; 16295 uint32_t pkg_size; 16296 int ret = -ENOTSUP; 16297 #ifdef RTE_LIBRTE_I40E_PMD 16298 uint32_t i, j, n; 16299 uint8_t *buff; 16300 uint32_t buff_size = 0; 16301 struct rte_pmd_i40e_profile_info info; 16302 uint32_t dev_num = 0; 16303 struct rte_pmd_i40e_ddp_device_id *devs; 16304 uint32_t proto_num = 0; 16305 struct rte_pmd_i40e_proto_info *proto = NULL; 16306 uint32_t pctype_num = 0; 16307 struct rte_pmd_i40e_ptype_info *pctype; 16308 uint32_t ptype_num = 0; 16309 struct rte_pmd_i40e_ptype_info *ptype; 16310 uint8_t proto_id; 16311 16312 #endif 16313 16314 pkg = open_file(res->filepath, &pkg_size); 16315 if (!pkg) 16316 return; 16317 16318 #ifdef RTE_LIBRTE_I40E_PMD 16319 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16320 (uint8_t *)&info, sizeof(info), 16321 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER); 16322 if (!ret) { 16323 printf("Global Track id: 0x%x\n", info.track_id); 16324 printf("Global Version: %d.%d.%d.%d\n", 16325 info.version.major, 16326 info.version.minor, 16327 info.version.update, 16328 info.version.draft); 16329 printf("Global Package name: %s\n\n", info.name); 16330 } 16331 16332 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16333 (uint8_t *)&info, sizeof(info), 16334 RTE_PMD_I40E_PKG_INFO_HEADER); 16335 if (!ret) { 16336 printf("i40e Profile Track id: 0x%x\n", info.track_id); 16337 printf("i40e Profile Version: %d.%d.%d.%d\n", 16338 info.version.major, 16339 info.version.minor, 16340 info.version.update, 16341 info.version.draft); 16342 printf("i40e Profile name: %s\n\n", info.name); 16343 } 16344 16345 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16346 (uint8_t *)&buff_size, sizeof(buff_size), 16347 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE); 16348 if (!ret && buff_size) { 16349 buff = (uint8_t *)malloc(buff_size); 16350 if (buff) { 16351 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16352 buff, buff_size, 16353 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES); 16354 if (!ret) 16355 printf("Package Notes:\n%s\n\n", buff); 16356 free(buff); 16357 } 16358 } 16359 16360 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16361 (uint8_t *)&dev_num, sizeof(dev_num), 16362 RTE_PMD_I40E_PKG_INFO_DEVID_NUM); 16363 if (!ret && dev_num) { 16364 buff_size = dev_num * sizeof(struct rte_pmd_i40e_ddp_device_id); 16365 devs = (struct rte_pmd_i40e_ddp_device_id *)malloc(buff_size); 16366 if (devs) { 16367 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16368 (uint8_t *)devs, buff_size, 16369 RTE_PMD_I40E_PKG_INFO_DEVID_LIST); 16370 if (!ret) { 16371 printf("List of supported devices:\n"); 16372 for (i = 0; i < dev_num; i++) { 16373 printf(" %04X:%04X %04X:%04X\n", 16374 devs[i].vendor_dev_id >> 16, 16375 devs[i].vendor_dev_id & 0xFFFF, 16376 devs[i].sub_vendor_dev_id >> 16, 16377 devs[i].sub_vendor_dev_id & 0xFFFF); 16378 } 16379 printf("\n"); 16380 } 16381 free(devs); 16382 } 16383 } 16384 16385 /* get information about protocols and packet types */ 16386 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16387 (uint8_t *)&proto_num, sizeof(proto_num), 16388 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM); 16389 if (ret || !proto_num) 16390 goto no_print_return; 16391 16392 buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info); 16393 proto = (struct rte_pmd_i40e_proto_info *)malloc(buff_size); 16394 if (!proto) 16395 goto no_print_return; 16396 16397 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)proto, 16398 buff_size, 16399 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST); 16400 if (!ret) { 16401 printf("List of used protocols:\n"); 16402 for (i = 0; i < proto_num; i++) 16403 printf(" %2u: %s\n", proto[i].proto_id, 16404 proto[i].name); 16405 printf("\n"); 16406 } 16407 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, 16408 (uint8_t *)&pctype_num, sizeof(pctype_num), 16409 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM); 16410 if (ret || !pctype_num) 16411 goto no_print_pctypes; 16412 16413 buff_size = pctype_num * sizeof(struct rte_pmd_i40e_ptype_info); 16414 pctype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 16415 if (!pctype) 16416 goto no_print_pctypes; 16417 16418 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)pctype, 16419 buff_size, 16420 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST); 16421 if (ret) { 16422 free(pctype); 16423 goto no_print_pctypes; 16424 } 16425 16426 printf("List of defined packet classification types:\n"); 16427 for (i = 0; i < pctype_num; i++) { 16428 printf(" %2u:", pctype[i].ptype_id); 16429 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 16430 proto_id = pctype[i].protocols[j]; 16431 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 16432 for (n = 0; n < proto_num; n++) { 16433 if (proto[n].proto_id == proto_id) { 16434 printf(" %s", proto[n].name); 16435 break; 16436 } 16437 } 16438 } 16439 } 16440 printf("\n"); 16441 } 16442 printf("\n"); 16443 free(pctype); 16444 16445 no_print_pctypes: 16446 16447 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)&ptype_num, 16448 sizeof(ptype_num), 16449 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM); 16450 if (ret || !ptype_num) 16451 goto no_print_return; 16452 16453 buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info); 16454 ptype = (struct rte_pmd_i40e_ptype_info *)malloc(buff_size); 16455 if (!ptype) 16456 goto no_print_return; 16457 16458 ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size, (uint8_t *)ptype, 16459 buff_size, 16460 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST); 16461 if (ret) { 16462 free(ptype); 16463 goto no_print_return; 16464 } 16465 printf("List of defined packet types:\n"); 16466 for (i = 0; i < ptype_num; i++) { 16467 printf(" %2u:", ptype[i].ptype_id); 16468 for (j = 0; j < RTE_PMD_I40E_PROTO_NUM; j++) { 16469 proto_id = ptype[i].protocols[j]; 16470 if (proto_id != RTE_PMD_I40E_PROTO_UNUSED) { 16471 for (n = 0; n < proto_num; n++) { 16472 if (proto[n].proto_id == proto_id) { 16473 printf(" %s", proto[n].name); 16474 break; 16475 } 16476 } 16477 } 16478 } 16479 printf("\n"); 16480 } 16481 free(ptype); 16482 printf("\n"); 16483 16484 ret = 0; 16485 no_print_return: 16486 if (proto) 16487 free(proto); 16488 #endif 16489 if (ret == -ENOTSUP) 16490 printf("Function not supported in PMD driver\n"); 16491 close_file(pkg); 16492 } 16493 16494 cmdline_parse_inst_t cmd_ddp_get_info = { 16495 .f = cmd_ddp_info_parsed, 16496 .data = NULL, 16497 .help_str = "ddp get info <profile_path>", 16498 .tokens = { 16499 (void *)&cmd_ddp_info_ddp, 16500 (void *)&cmd_ddp_info_get, 16501 (void *)&cmd_ddp_info_info, 16502 (void *)&cmd_ddp_info_filepath, 16503 NULL, 16504 }, 16505 }; 16506 16507 /* Get dynamic device personalization profile info list*/ 16508 #define PROFILE_INFO_SIZE 48 16509 #define MAX_PROFILE_NUM 16 16510 16511 struct cmd_ddp_get_list_result { 16512 cmdline_fixed_string_t ddp; 16513 cmdline_fixed_string_t get; 16514 cmdline_fixed_string_t list; 16515 portid_t port_id; 16516 }; 16517 16518 cmdline_parse_token_string_t cmd_ddp_get_list_ddp = 16519 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, ddp, "ddp"); 16520 cmdline_parse_token_string_t cmd_ddp_get_list_get = 16521 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, get, "get"); 16522 cmdline_parse_token_string_t cmd_ddp_get_list_list = 16523 TOKEN_STRING_INITIALIZER(struct cmd_ddp_get_list_result, list, "list"); 16524 cmdline_parse_token_num_t cmd_ddp_get_list_port_id = 16525 TOKEN_NUM_INITIALIZER(struct cmd_ddp_get_list_result, port_id, UINT16); 16526 16527 static void 16528 cmd_ddp_get_list_parsed( 16529 __attribute__((unused)) void *parsed_result, 16530 __attribute__((unused)) struct cmdline *cl, 16531 __attribute__((unused)) void *data) 16532 { 16533 #ifdef RTE_LIBRTE_I40E_PMD 16534 struct cmd_ddp_get_list_result *res = parsed_result; 16535 struct rte_pmd_i40e_profile_list *p_list; 16536 struct rte_pmd_i40e_profile_info *p_info; 16537 uint32_t p_num; 16538 uint32_t size; 16539 uint32_t i; 16540 #endif 16541 int ret = -ENOTSUP; 16542 16543 #ifdef RTE_LIBRTE_I40E_PMD 16544 size = PROFILE_INFO_SIZE * MAX_PROFILE_NUM + 4; 16545 p_list = (struct rte_pmd_i40e_profile_list *)malloc(size); 16546 if (!p_list) 16547 printf("%s: Failed to malloc buffer\n", __func__); 16548 16549 if (ret == -ENOTSUP) 16550 ret = rte_pmd_i40e_get_ddp_list(res->port_id, 16551 (uint8_t *)p_list, size); 16552 16553 if (!ret) { 16554 p_num = p_list->p_count; 16555 printf("Profile number is: %d\n\n", p_num); 16556 16557 for (i = 0; i < p_num; i++) { 16558 p_info = &p_list->p_info[i]; 16559 printf("Profile %d:\n", i); 16560 printf("Track id: 0x%x\n", p_info->track_id); 16561 printf("Version: %d.%d.%d.%d\n", 16562 p_info->version.major, 16563 p_info->version.minor, 16564 p_info->version.update, 16565 p_info->version.draft); 16566 printf("Profile name: %s\n\n", p_info->name); 16567 } 16568 } 16569 16570 free(p_list); 16571 #endif 16572 16573 if (ret < 0) 16574 printf("Failed to get ddp list\n"); 16575 } 16576 16577 cmdline_parse_inst_t cmd_ddp_get_list = { 16578 .f = cmd_ddp_get_list_parsed, 16579 .data = NULL, 16580 .help_str = "ddp get list <port_id>", 16581 .tokens = { 16582 (void *)&cmd_ddp_get_list_ddp, 16583 (void *)&cmd_ddp_get_list_get, 16584 (void *)&cmd_ddp_get_list_list, 16585 (void *)&cmd_ddp_get_list_port_id, 16586 NULL, 16587 }, 16588 }; 16589 16590 /* Configure input set */ 16591 struct cmd_cfg_input_set_result { 16592 cmdline_fixed_string_t port; 16593 cmdline_fixed_string_t cfg; 16594 portid_t port_id; 16595 cmdline_fixed_string_t pctype; 16596 uint8_t pctype_id; 16597 cmdline_fixed_string_t inset_type; 16598 cmdline_fixed_string_t opt; 16599 cmdline_fixed_string_t field; 16600 uint8_t field_idx; 16601 }; 16602 16603 static void 16604 cmd_cfg_input_set_parsed( 16605 __attribute__((unused)) void *parsed_result, 16606 __attribute__((unused)) struct cmdline *cl, 16607 __attribute__((unused)) void *data) 16608 { 16609 #ifdef RTE_LIBRTE_I40E_PMD 16610 struct cmd_cfg_input_set_result *res = parsed_result; 16611 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 16612 struct rte_pmd_i40e_inset inset; 16613 #endif 16614 int ret = -ENOTSUP; 16615 16616 if (!all_ports_stopped()) { 16617 printf("Please stop all ports first\n"); 16618 return; 16619 } 16620 16621 #ifdef RTE_LIBRTE_I40E_PMD 16622 if (!strcmp(res->inset_type, "hash_inset")) 16623 inset_type = INSET_HASH; 16624 else if (!strcmp(res->inset_type, "fdir_inset")) 16625 inset_type = INSET_FDIR; 16626 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 16627 inset_type = INSET_FDIR_FLX; 16628 ret = rte_pmd_i40e_inset_get(res->port_id, res->pctype_id, 16629 &inset, inset_type); 16630 if (ret) { 16631 printf("Failed to get input set.\n"); 16632 return; 16633 } 16634 16635 if (!strcmp(res->opt, "get")) { 16636 ret = rte_pmd_i40e_inset_field_get(inset.inset, 16637 res->field_idx); 16638 if (ret) 16639 printf("Field index %d is enabled.\n", res->field_idx); 16640 else 16641 printf("Field index %d is disabled.\n", res->field_idx); 16642 return; 16643 } else if (!strcmp(res->opt, "set")) 16644 ret = rte_pmd_i40e_inset_field_set(&inset.inset, 16645 res->field_idx); 16646 else if (!strcmp(res->opt, "clear")) 16647 ret = rte_pmd_i40e_inset_field_clear(&inset.inset, 16648 res->field_idx); 16649 if (ret) { 16650 printf("Failed to configure input set field.\n"); 16651 return; 16652 } 16653 16654 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 16655 &inset, inset_type); 16656 if (ret) { 16657 printf("Failed to set input set.\n"); 16658 return; 16659 } 16660 #endif 16661 16662 if (ret == -ENOTSUP) 16663 printf("Function not supported\n"); 16664 } 16665 16666 cmdline_parse_token_string_t cmd_cfg_input_set_port = 16667 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16668 port, "port"); 16669 cmdline_parse_token_string_t cmd_cfg_input_set_cfg = 16670 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16671 cfg, "config"); 16672 cmdline_parse_token_num_t cmd_cfg_input_set_port_id = 16673 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16674 port_id, UINT16); 16675 cmdline_parse_token_string_t cmd_cfg_input_set_pctype = 16676 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16677 pctype, "pctype"); 16678 cmdline_parse_token_num_t cmd_cfg_input_set_pctype_id = 16679 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16680 pctype_id, UINT8); 16681 cmdline_parse_token_string_t cmd_cfg_input_set_inset_type = 16682 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16683 inset_type, 16684 "hash_inset#fdir_inset#fdir_flx_inset"); 16685 cmdline_parse_token_string_t cmd_cfg_input_set_opt = 16686 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16687 opt, "get#set#clear"); 16688 cmdline_parse_token_string_t cmd_cfg_input_set_field = 16689 TOKEN_STRING_INITIALIZER(struct cmd_cfg_input_set_result, 16690 field, "field"); 16691 cmdline_parse_token_num_t cmd_cfg_input_set_field_idx = 16692 TOKEN_NUM_INITIALIZER(struct cmd_cfg_input_set_result, 16693 field_idx, UINT8); 16694 16695 cmdline_parse_inst_t cmd_cfg_input_set = { 16696 .f = cmd_cfg_input_set_parsed, 16697 .data = NULL, 16698 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 16699 "fdir_inset|fdir_flx_inset get|set|clear field <field_idx>", 16700 .tokens = { 16701 (void *)&cmd_cfg_input_set_port, 16702 (void *)&cmd_cfg_input_set_cfg, 16703 (void *)&cmd_cfg_input_set_port_id, 16704 (void *)&cmd_cfg_input_set_pctype, 16705 (void *)&cmd_cfg_input_set_pctype_id, 16706 (void *)&cmd_cfg_input_set_inset_type, 16707 (void *)&cmd_cfg_input_set_opt, 16708 (void *)&cmd_cfg_input_set_field, 16709 (void *)&cmd_cfg_input_set_field_idx, 16710 NULL, 16711 }, 16712 }; 16713 16714 /* Clear input set */ 16715 struct cmd_clear_input_set_result { 16716 cmdline_fixed_string_t port; 16717 cmdline_fixed_string_t cfg; 16718 portid_t port_id; 16719 cmdline_fixed_string_t pctype; 16720 uint8_t pctype_id; 16721 cmdline_fixed_string_t inset_type; 16722 cmdline_fixed_string_t clear; 16723 cmdline_fixed_string_t all; 16724 }; 16725 16726 static void 16727 cmd_clear_input_set_parsed( 16728 __attribute__((unused)) void *parsed_result, 16729 __attribute__((unused)) struct cmdline *cl, 16730 __attribute__((unused)) void *data) 16731 { 16732 #ifdef RTE_LIBRTE_I40E_PMD 16733 struct cmd_clear_input_set_result *res = parsed_result; 16734 enum rte_pmd_i40e_inset_type inset_type = INSET_NONE; 16735 struct rte_pmd_i40e_inset inset; 16736 #endif 16737 int ret = -ENOTSUP; 16738 16739 if (!all_ports_stopped()) { 16740 printf("Please stop all ports first\n"); 16741 return; 16742 } 16743 16744 #ifdef RTE_LIBRTE_I40E_PMD 16745 if (!strcmp(res->inset_type, "hash_inset")) 16746 inset_type = INSET_HASH; 16747 else if (!strcmp(res->inset_type, "fdir_inset")) 16748 inset_type = INSET_FDIR; 16749 else if (!strcmp(res->inset_type, "fdir_flx_inset")) 16750 inset_type = INSET_FDIR_FLX; 16751 16752 memset(&inset, 0, sizeof(inset)); 16753 16754 ret = rte_pmd_i40e_inset_set(res->port_id, res->pctype_id, 16755 &inset, inset_type); 16756 if (ret) { 16757 printf("Failed to clear input set.\n"); 16758 return; 16759 } 16760 16761 #endif 16762 16763 if (ret == -ENOTSUP) 16764 printf("Function not supported\n"); 16765 } 16766 16767 cmdline_parse_token_string_t cmd_clear_input_set_port = 16768 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16769 port, "port"); 16770 cmdline_parse_token_string_t cmd_clear_input_set_cfg = 16771 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16772 cfg, "config"); 16773 cmdline_parse_token_num_t cmd_clear_input_set_port_id = 16774 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 16775 port_id, UINT16); 16776 cmdline_parse_token_string_t cmd_clear_input_set_pctype = 16777 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16778 pctype, "pctype"); 16779 cmdline_parse_token_num_t cmd_clear_input_set_pctype_id = 16780 TOKEN_NUM_INITIALIZER(struct cmd_clear_input_set_result, 16781 pctype_id, UINT8); 16782 cmdline_parse_token_string_t cmd_clear_input_set_inset_type = 16783 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16784 inset_type, 16785 "hash_inset#fdir_inset#fdir_flx_inset"); 16786 cmdline_parse_token_string_t cmd_clear_input_set_clear = 16787 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16788 clear, "clear"); 16789 cmdline_parse_token_string_t cmd_clear_input_set_all = 16790 TOKEN_STRING_INITIALIZER(struct cmd_clear_input_set_result, 16791 all, "all"); 16792 16793 cmdline_parse_inst_t cmd_clear_input_set = { 16794 .f = cmd_clear_input_set_parsed, 16795 .data = NULL, 16796 .help_str = "port config <port_id> pctype <pctype_id> hash_inset|" 16797 "fdir_inset|fdir_flx_inset clear all", 16798 .tokens = { 16799 (void *)&cmd_clear_input_set_port, 16800 (void *)&cmd_clear_input_set_cfg, 16801 (void *)&cmd_clear_input_set_port_id, 16802 (void *)&cmd_clear_input_set_pctype, 16803 (void *)&cmd_clear_input_set_pctype_id, 16804 (void *)&cmd_clear_input_set_inset_type, 16805 (void *)&cmd_clear_input_set_clear, 16806 (void *)&cmd_clear_input_set_all, 16807 NULL, 16808 }, 16809 }; 16810 16811 /* show vf stats */ 16812 16813 /* Common result structure for show vf stats */ 16814 struct cmd_show_vf_stats_result { 16815 cmdline_fixed_string_t show; 16816 cmdline_fixed_string_t vf; 16817 cmdline_fixed_string_t stats; 16818 portid_t port_id; 16819 uint16_t vf_id; 16820 }; 16821 16822 /* Common CLI fields show vf stats*/ 16823 cmdline_parse_token_string_t cmd_show_vf_stats_show = 16824 TOKEN_STRING_INITIALIZER 16825 (struct cmd_show_vf_stats_result, 16826 show, "show"); 16827 cmdline_parse_token_string_t cmd_show_vf_stats_vf = 16828 TOKEN_STRING_INITIALIZER 16829 (struct cmd_show_vf_stats_result, 16830 vf, "vf"); 16831 cmdline_parse_token_string_t cmd_show_vf_stats_stats = 16832 TOKEN_STRING_INITIALIZER 16833 (struct cmd_show_vf_stats_result, 16834 stats, "stats"); 16835 cmdline_parse_token_num_t cmd_show_vf_stats_port_id = 16836 TOKEN_NUM_INITIALIZER 16837 (struct cmd_show_vf_stats_result, 16838 port_id, UINT16); 16839 cmdline_parse_token_num_t cmd_show_vf_stats_vf_id = 16840 TOKEN_NUM_INITIALIZER 16841 (struct cmd_show_vf_stats_result, 16842 vf_id, UINT16); 16843 16844 static void 16845 cmd_show_vf_stats_parsed( 16846 void *parsed_result, 16847 __attribute__((unused)) struct cmdline *cl, 16848 __attribute__((unused)) void *data) 16849 { 16850 struct cmd_show_vf_stats_result *res = parsed_result; 16851 struct rte_eth_stats stats; 16852 int ret = -ENOTSUP; 16853 static const char *nic_stats_border = "########################"; 16854 16855 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16856 return; 16857 16858 memset(&stats, 0, sizeof(stats)); 16859 16860 #ifdef RTE_LIBRTE_I40E_PMD 16861 if (ret == -ENOTSUP) 16862 ret = rte_pmd_i40e_get_vf_stats(res->port_id, 16863 res->vf_id, 16864 &stats); 16865 #endif 16866 #ifdef RTE_LIBRTE_BNXT_PMD 16867 if (ret == -ENOTSUP) 16868 ret = rte_pmd_bnxt_get_vf_stats(res->port_id, 16869 res->vf_id, 16870 &stats); 16871 #endif 16872 16873 switch (ret) { 16874 case 0: 16875 break; 16876 case -EINVAL: 16877 printf("invalid vf_id %d\n", res->vf_id); 16878 break; 16879 case -ENODEV: 16880 printf("invalid port_id %d\n", res->port_id); 16881 break; 16882 case -ENOTSUP: 16883 printf("function not implemented\n"); 16884 break; 16885 default: 16886 printf("programming error: (%s)\n", strerror(-ret)); 16887 } 16888 16889 printf("\n %s NIC statistics for port %-2d vf %-2d %s\n", 16890 nic_stats_border, res->port_id, res->vf_id, nic_stats_border); 16891 16892 printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " 16893 "%-"PRIu64"\n", 16894 stats.ipackets, stats.imissed, stats.ibytes); 16895 printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); 16896 printf(" RX-nombuf: %-10"PRIu64"\n", 16897 stats.rx_nombuf); 16898 printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " 16899 "%-"PRIu64"\n", 16900 stats.opackets, stats.oerrors, stats.obytes); 16901 16902 printf(" %s############################%s\n", 16903 nic_stats_border, nic_stats_border); 16904 } 16905 16906 cmdline_parse_inst_t cmd_show_vf_stats = { 16907 .f = cmd_show_vf_stats_parsed, 16908 .data = NULL, 16909 .help_str = "show vf stats <port_id> <vf_id>", 16910 .tokens = { 16911 (void *)&cmd_show_vf_stats_show, 16912 (void *)&cmd_show_vf_stats_vf, 16913 (void *)&cmd_show_vf_stats_stats, 16914 (void *)&cmd_show_vf_stats_port_id, 16915 (void *)&cmd_show_vf_stats_vf_id, 16916 NULL, 16917 }, 16918 }; 16919 16920 /* clear vf stats */ 16921 16922 /* Common result structure for clear vf stats */ 16923 struct cmd_clear_vf_stats_result { 16924 cmdline_fixed_string_t clear; 16925 cmdline_fixed_string_t vf; 16926 cmdline_fixed_string_t stats; 16927 portid_t port_id; 16928 uint16_t vf_id; 16929 }; 16930 16931 /* Common CLI fields clear vf stats*/ 16932 cmdline_parse_token_string_t cmd_clear_vf_stats_clear = 16933 TOKEN_STRING_INITIALIZER 16934 (struct cmd_clear_vf_stats_result, 16935 clear, "clear"); 16936 cmdline_parse_token_string_t cmd_clear_vf_stats_vf = 16937 TOKEN_STRING_INITIALIZER 16938 (struct cmd_clear_vf_stats_result, 16939 vf, "vf"); 16940 cmdline_parse_token_string_t cmd_clear_vf_stats_stats = 16941 TOKEN_STRING_INITIALIZER 16942 (struct cmd_clear_vf_stats_result, 16943 stats, "stats"); 16944 cmdline_parse_token_num_t cmd_clear_vf_stats_port_id = 16945 TOKEN_NUM_INITIALIZER 16946 (struct cmd_clear_vf_stats_result, 16947 port_id, UINT16); 16948 cmdline_parse_token_num_t cmd_clear_vf_stats_vf_id = 16949 TOKEN_NUM_INITIALIZER 16950 (struct cmd_clear_vf_stats_result, 16951 vf_id, UINT16); 16952 16953 static void 16954 cmd_clear_vf_stats_parsed( 16955 void *parsed_result, 16956 __attribute__((unused)) struct cmdline *cl, 16957 __attribute__((unused)) void *data) 16958 { 16959 struct cmd_clear_vf_stats_result *res = parsed_result; 16960 int ret = -ENOTSUP; 16961 16962 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 16963 return; 16964 16965 #ifdef RTE_LIBRTE_I40E_PMD 16966 if (ret == -ENOTSUP) 16967 ret = rte_pmd_i40e_reset_vf_stats(res->port_id, 16968 res->vf_id); 16969 #endif 16970 #ifdef RTE_LIBRTE_BNXT_PMD 16971 if (ret == -ENOTSUP) 16972 ret = rte_pmd_bnxt_reset_vf_stats(res->port_id, 16973 res->vf_id); 16974 #endif 16975 16976 switch (ret) { 16977 case 0: 16978 break; 16979 case -EINVAL: 16980 printf("invalid vf_id %d\n", res->vf_id); 16981 break; 16982 case -ENODEV: 16983 printf("invalid port_id %d\n", res->port_id); 16984 break; 16985 case -ENOTSUP: 16986 printf("function not implemented\n"); 16987 break; 16988 default: 16989 printf("programming error: (%s)\n", strerror(-ret)); 16990 } 16991 } 16992 16993 cmdline_parse_inst_t cmd_clear_vf_stats = { 16994 .f = cmd_clear_vf_stats_parsed, 16995 .data = NULL, 16996 .help_str = "clear vf stats <port_id> <vf_id>", 16997 .tokens = { 16998 (void *)&cmd_clear_vf_stats_clear, 16999 (void *)&cmd_clear_vf_stats_vf, 17000 (void *)&cmd_clear_vf_stats_stats, 17001 (void *)&cmd_clear_vf_stats_port_id, 17002 (void *)&cmd_clear_vf_stats_vf_id, 17003 NULL, 17004 }, 17005 }; 17006 17007 /* port config pctype mapping reset */ 17008 17009 /* Common result structure for port config pctype mapping reset */ 17010 struct cmd_pctype_mapping_reset_result { 17011 cmdline_fixed_string_t port; 17012 cmdline_fixed_string_t config; 17013 portid_t port_id; 17014 cmdline_fixed_string_t pctype; 17015 cmdline_fixed_string_t mapping; 17016 cmdline_fixed_string_t reset; 17017 }; 17018 17019 /* Common CLI fields for port config pctype mapping reset*/ 17020 cmdline_parse_token_string_t cmd_pctype_mapping_reset_port = 17021 TOKEN_STRING_INITIALIZER 17022 (struct cmd_pctype_mapping_reset_result, 17023 port, "port"); 17024 cmdline_parse_token_string_t cmd_pctype_mapping_reset_config = 17025 TOKEN_STRING_INITIALIZER 17026 (struct cmd_pctype_mapping_reset_result, 17027 config, "config"); 17028 cmdline_parse_token_num_t cmd_pctype_mapping_reset_port_id = 17029 TOKEN_NUM_INITIALIZER 17030 (struct cmd_pctype_mapping_reset_result, 17031 port_id, UINT16); 17032 cmdline_parse_token_string_t cmd_pctype_mapping_reset_pctype = 17033 TOKEN_STRING_INITIALIZER 17034 (struct cmd_pctype_mapping_reset_result, 17035 pctype, "pctype"); 17036 cmdline_parse_token_string_t cmd_pctype_mapping_reset_mapping = 17037 TOKEN_STRING_INITIALIZER 17038 (struct cmd_pctype_mapping_reset_result, 17039 mapping, "mapping"); 17040 cmdline_parse_token_string_t cmd_pctype_mapping_reset_reset = 17041 TOKEN_STRING_INITIALIZER 17042 (struct cmd_pctype_mapping_reset_result, 17043 reset, "reset"); 17044 17045 static void 17046 cmd_pctype_mapping_reset_parsed( 17047 void *parsed_result, 17048 __attribute__((unused)) struct cmdline *cl, 17049 __attribute__((unused)) void *data) 17050 { 17051 struct cmd_pctype_mapping_reset_result *res = parsed_result; 17052 int ret = -ENOTSUP; 17053 17054 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17055 return; 17056 17057 #ifdef RTE_LIBRTE_I40E_PMD 17058 ret = rte_pmd_i40e_flow_type_mapping_reset(res->port_id); 17059 #endif 17060 17061 switch (ret) { 17062 case 0: 17063 break; 17064 case -ENODEV: 17065 printf("invalid port_id %d\n", res->port_id); 17066 break; 17067 case -ENOTSUP: 17068 printf("function not implemented\n"); 17069 break; 17070 default: 17071 printf("programming error: (%s)\n", strerror(-ret)); 17072 } 17073 } 17074 17075 cmdline_parse_inst_t cmd_pctype_mapping_reset = { 17076 .f = cmd_pctype_mapping_reset_parsed, 17077 .data = NULL, 17078 .help_str = "port config <port_id> pctype mapping reset", 17079 .tokens = { 17080 (void *)&cmd_pctype_mapping_reset_port, 17081 (void *)&cmd_pctype_mapping_reset_config, 17082 (void *)&cmd_pctype_mapping_reset_port_id, 17083 (void *)&cmd_pctype_mapping_reset_pctype, 17084 (void *)&cmd_pctype_mapping_reset_mapping, 17085 (void *)&cmd_pctype_mapping_reset_reset, 17086 NULL, 17087 }, 17088 }; 17089 17090 /* show port pctype mapping */ 17091 17092 /* Common result structure for show port pctype mapping */ 17093 struct cmd_pctype_mapping_get_result { 17094 cmdline_fixed_string_t show; 17095 cmdline_fixed_string_t port; 17096 portid_t port_id; 17097 cmdline_fixed_string_t pctype; 17098 cmdline_fixed_string_t mapping; 17099 }; 17100 17101 /* Common CLI fields for pctype mapping get */ 17102 cmdline_parse_token_string_t cmd_pctype_mapping_get_show = 17103 TOKEN_STRING_INITIALIZER 17104 (struct cmd_pctype_mapping_get_result, 17105 show, "show"); 17106 cmdline_parse_token_string_t cmd_pctype_mapping_get_port = 17107 TOKEN_STRING_INITIALIZER 17108 (struct cmd_pctype_mapping_get_result, 17109 port, "port"); 17110 cmdline_parse_token_num_t cmd_pctype_mapping_get_port_id = 17111 TOKEN_NUM_INITIALIZER 17112 (struct cmd_pctype_mapping_get_result, 17113 port_id, UINT16); 17114 cmdline_parse_token_string_t cmd_pctype_mapping_get_pctype = 17115 TOKEN_STRING_INITIALIZER 17116 (struct cmd_pctype_mapping_get_result, 17117 pctype, "pctype"); 17118 cmdline_parse_token_string_t cmd_pctype_mapping_get_mapping = 17119 TOKEN_STRING_INITIALIZER 17120 (struct cmd_pctype_mapping_get_result, 17121 mapping, "mapping"); 17122 17123 static void 17124 cmd_pctype_mapping_get_parsed( 17125 void *parsed_result, 17126 __attribute__((unused)) struct cmdline *cl, 17127 __attribute__((unused)) void *data) 17128 { 17129 struct cmd_pctype_mapping_get_result *res = parsed_result; 17130 int ret = -ENOTSUP; 17131 #ifdef RTE_LIBRTE_I40E_PMD 17132 struct rte_pmd_i40e_flow_type_mapping 17133 mapping[RTE_PMD_I40E_FLOW_TYPE_MAX]; 17134 int i, j, first_pctype; 17135 #endif 17136 17137 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17138 return; 17139 17140 #ifdef RTE_LIBRTE_I40E_PMD 17141 ret = rte_pmd_i40e_flow_type_mapping_get(res->port_id, mapping); 17142 #endif 17143 17144 switch (ret) { 17145 case 0: 17146 break; 17147 case -ENODEV: 17148 printf("invalid port_id %d\n", res->port_id); 17149 return; 17150 case -ENOTSUP: 17151 printf("function not implemented\n"); 17152 return; 17153 default: 17154 printf("programming error: (%s)\n", strerror(-ret)); 17155 return; 17156 } 17157 17158 #ifdef RTE_LIBRTE_I40E_PMD 17159 for (i = 0; i < RTE_PMD_I40E_FLOW_TYPE_MAX; i++) { 17160 if (mapping[i].pctype != 0ULL) { 17161 first_pctype = 1; 17162 17163 printf("pctype: "); 17164 for (j = 0; j < RTE_PMD_I40E_PCTYPE_MAX; j++) { 17165 if (mapping[i].pctype & (1ULL << j)) { 17166 printf(first_pctype ? 17167 "%02d" : ",%02d", j); 17168 first_pctype = 0; 17169 } 17170 } 17171 printf(" -> flowtype: %02d\n", mapping[i].flow_type); 17172 } 17173 } 17174 #endif 17175 } 17176 17177 cmdline_parse_inst_t cmd_pctype_mapping_get = { 17178 .f = cmd_pctype_mapping_get_parsed, 17179 .data = NULL, 17180 .help_str = "show port <port_id> pctype mapping", 17181 .tokens = { 17182 (void *)&cmd_pctype_mapping_get_show, 17183 (void *)&cmd_pctype_mapping_get_port, 17184 (void *)&cmd_pctype_mapping_get_port_id, 17185 (void *)&cmd_pctype_mapping_get_pctype, 17186 (void *)&cmd_pctype_mapping_get_mapping, 17187 NULL, 17188 }, 17189 }; 17190 17191 /* port config pctype mapping update */ 17192 17193 /* Common result structure for port config pctype mapping update */ 17194 struct cmd_pctype_mapping_update_result { 17195 cmdline_fixed_string_t port; 17196 cmdline_fixed_string_t config; 17197 portid_t port_id; 17198 cmdline_fixed_string_t pctype; 17199 cmdline_fixed_string_t mapping; 17200 cmdline_fixed_string_t update; 17201 cmdline_fixed_string_t pctype_list; 17202 uint16_t flow_type; 17203 }; 17204 17205 /* Common CLI fields for pctype mapping update*/ 17206 cmdline_parse_token_string_t cmd_pctype_mapping_update_port = 17207 TOKEN_STRING_INITIALIZER 17208 (struct cmd_pctype_mapping_update_result, 17209 port, "port"); 17210 cmdline_parse_token_string_t cmd_pctype_mapping_update_config = 17211 TOKEN_STRING_INITIALIZER 17212 (struct cmd_pctype_mapping_update_result, 17213 config, "config"); 17214 cmdline_parse_token_num_t cmd_pctype_mapping_update_port_id = 17215 TOKEN_NUM_INITIALIZER 17216 (struct cmd_pctype_mapping_update_result, 17217 port_id, UINT16); 17218 cmdline_parse_token_string_t cmd_pctype_mapping_update_pctype = 17219 TOKEN_STRING_INITIALIZER 17220 (struct cmd_pctype_mapping_update_result, 17221 pctype, "pctype"); 17222 cmdline_parse_token_string_t cmd_pctype_mapping_update_mapping = 17223 TOKEN_STRING_INITIALIZER 17224 (struct cmd_pctype_mapping_update_result, 17225 mapping, "mapping"); 17226 cmdline_parse_token_string_t cmd_pctype_mapping_update_update = 17227 TOKEN_STRING_INITIALIZER 17228 (struct cmd_pctype_mapping_update_result, 17229 update, "update"); 17230 cmdline_parse_token_string_t cmd_pctype_mapping_update_pc_type = 17231 TOKEN_STRING_INITIALIZER 17232 (struct cmd_pctype_mapping_update_result, 17233 pctype_list, NULL); 17234 cmdline_parse_token_num_t cmd_pctype_mapping_update_flow_type = 17235 TOKEN_NUM_INITIALIZER 17236 (struct cmd_pctype_mapping_update_result, 17237 flow_type, UINT16); 17238 17239 static void 17240 cmd_pctype_mapping_update_parsed( 17241 void *parsed_result, 17242 __attribute__((unused)) struct cmdline *cl, 17243 __attribute__((unused)) void *data) 17244 { 17245 struct cmd_pctype_mapping_update_result *res = parsed_result; 17246 int ret = -ENOTSUP; 17247 #ifdef RTE_LIBRTE_I40E_PMD 17248 struct rte_pmd_i40e_flow_type_mapping mapping; 17249 unsigned int i; 17250 unsigned int nb_item; 17251 unsigned int pctype_list[RTE_PMD_I40E_PCTYPE_MAX]; 17252 #endif 17253 17254 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17255 return; 17256 17257 #ifdef RTE_LIBRTE_I40E_PMD 17258 nb_item = parse_item_list(res->pctype_list, "pctypes", 17259 RTE_PMD_I40E_PCTYPE_MAX, pctype_list, 1); 17260 mapping.flow_type = res->flow_type; 17261 for (i = 0, mapping.pctype = 0ULL; i < nb_item; i++) 17262 mapping.pctype |= (1ULL << pctype_list[i]); 17263 ret = rte_pmd_i40e_flow_type_mapping_update(res->port_id, 17264 &mapping, 17265 1, 17266 0); 17267 #endif 17268 17269 switch (ret) { 17270 case 0: 17271 break; 17272 case -EINVAL: 17273 printf("invalid pctype or flow type\n"); 17274 break; 17275 case -ENODEV: 17276 printf("invalid port_id %d\n", res->port_id); 17277 break; 17278 case -ENOTSUP: 17279 printf("function not implemented\n"); 17280 break; 17281 default: 17282 printf("programming error: (%s)\n", strerror(-ret)); 17283 } 17284 } 17285 17286 cmdline_parse_inst_t cmd_pctype_mapping_update = { 17287 .f = cmd_pctype_mapping_update_parsed, 17288 .data = NULL, 17289 .help_str = "port config <port_id> pctype mapping update" 17290 " <pctype_id_0,[pctype_id_1]*> <flowtype_id>", 17291 .tokens = { 17292 (void *)&cmd_pctype_mapping_update_port, 17293 (void *)&cmd_pctype_mapping_update_config, 17294 (void *)&cmd_pctype_mapping_update_port_id, 17295 (void *)&cmd_pctype_mapping_update_pctype, 17296 (void *)&cmd_pctype_mapping_update_mapping, 17297 (void *)&cmd_pctype_mapping_update_update, 17298 (void *)&cmd_pctype_mapping_update_pc_type, 17299 (void *)&cmd_pctype_mapping_update_flow_type, 17300 NULL, 17301 }, 17302 }; 17303 17304 /* ptype mapping get */ 17305 17306 /* Common result structure for ptype mapping get */ 17307 struct cmd_ptype_mapping_get_result { 17308 cmdline_fixed_string_t ptype; 17309 cmdline_fixed_string_t mapping; 17310 cmdline_fixed_string_t get; 17311 portid_t port_id; 17312 uint8_t valid_only; 17313 }; 17314 17315 /* Common CLI fields for ptype mapping get */ 17316 cmdline_parse_token_string_t cmd_ptype_mapping_get_ptype = 17317 TOKEN_STRING_INITIALIZER 17318 (struct cmd_ptype_mapping_get_result, 17319 ptype, "ptype"); 17320 cmdline_parse_token_string_t cmd_ptype_mapping_get_mapping = 17321 TOKEN_STRING_INITIALIZER 17322 (struct cmd_ptype_mapping_get_result, 17323 mapping, "mapping"); 17324 cmdline_parse_token_string_t cmd_ptype_mapping_get_get = 17325 TOKEN_STRING_INITIALIZER 17326 (struct cmd_ptype_mapping_get_result, 17327 get, "get"); 17328 cmdline_parse_token_num_t cmd_ptype_mapping_get_port_id = 17329 TOKEN_NUM_INITIALIZER 17330 (struct cmd_ptype_mapping_get_result, 17331 port_id, UINT16); 17332 cmdline_parse_token_num_t cmd_ptype_mapping_get_valid_only = 17333 TOKEN_NUM_INITIALIZER 17334 (struct cmd_ptype_mapping_get_result, 17335 valid_only, UINT8); 17336 17337 static void 17338 cmd_ptype_mapping_get_parsed( 17339 void *parsed_result, 17340 __attribute__((unused)) struct cmdline *cl, 17341 __attribute__((unused)) void *data) 17342 { 17343 struct cmd_ptype_mapping_get_result *res = parsed_result; 17344 int ret = -ENOTSUP; 17345 #ifdef RTE_LIBRTE_I40E_PMD 17346 int max_ptype_num = 256; 17347 struct rte_pmd_i40e_ptype_mapping mapping[max_ptype_num]; 17348 uint16_t count; 17349 int i; 17350 #endif 17351 17352 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17353 return; 17354 17355 #ifdef RTE_LIBRTE_I40E_PMD 17356 ret = rte_pmd_i40e_ptype_mapping_get(res->port_id, 17357 mapping, 17358 max_ptype_num, 17359 &count, 17360 res->valid_only); 17361 #endif 17362 17363 switch (ret) { 17364 case 0: 17365 break; 17366 case -ENODEV: 17367 printf("invalid port_id %d\n", res->port_id); 17368 break; 17369 case -ENOTSUP: 17370 printf("function not implemented\n"); 17371 break; 17372 default: 17373 printf("programming error: (%s)\n", strerror(-ret)); 17374 } 17375 17376 #ifdef RTE_LIBRTE_I40E_PMD 17377 if (!ret) { 17378 for (i = 0; i < count; i++) 17379 printf("%3d\t0x%08x\n", 17380 mapping[i].hw_ptype, mapping[i].sw_ptype); 17381 } 17382 #endif 17383 } 17384 17385 cmdline_parse_inst_t cmd_ptype_mapping_get = { 17386 .f = cmd_ptype_mapping_get_parsed, 17387 .data = NULL, 17388 .help_str = "ptype mapping get <port_id> <valid_only>", 17389 .tokens = { 17390 (void *)&cmd_ptype_mapping_get_ptype, 17391 (void *)&cmd_ptype_mapping_get_mapping, 17392 (void *)&cmd_ptype_mapping_get_get, 17393 (void *)&cmd_ptype_mapping_get_port_id, 17394 (void *)&cmd_ptype_mapping_get_valid_only, 17395 NULL, 17396 }, 17397 }; 17398 17399 /* ptype mapping replace */ 17400 17401 /* Common result structure for ptype mapping replace */ 17402 struct cmd_ptype_mapping_replace_result { 17403 cmdline_fixed_string_t ptype; 17404 cmdline_fixed_string_t mapping; 17405 cmdline_fixed_string_t replace; 17406 portid_t port_id; 17407 uint32_t target; 17408 uint8_t mask; 17409 uint32_t pkt_type; 17410 }; 17411 17412 /* Common CLI fields for ptype mapping replace */ 17413 cmdline_parse_token_string_t cmd_ptype_mapping_replace_ptype = 17414 TOKEN_STRING_INITIALIZER 17415 (struct cmd_ptype_mapping_replace_result, 17416 ptype, "ptype"); 17417 cmdline_parse_token_string_t cmd_ptype_mapping_replace_mapping = 17418 TOKEN_STRING_INITIALIZER 17419 (struct cmd_ptype_mapping_replace_result, 17420 mapping, "mapping"); 17421 cmdline_parse_token_string_t cmd_ptype_mapping_replace_replace = 17422 TOKEN_STRING_INITIALIZER 17423 (struct cmd_ptype_mapping_replace_result, 17424 replace, "replace"); 17425 cmdline_parse_token_num_t cmd_ptype_mapping_replace_port_id = 17426 TOKEN_NUM_INITIALIZER 17427 (struct cmd_ptype_mapping_replace_result, 17428 port_id, UINT16); 17429 cmdline_parse_token_num_t cmd_ptype_mapping_replace_target = 17430 TOKEN_NUM_INITIALIZER 17431 (struct cmd_ptype_mapping_replace_result, 17432 target, UINT32); 17433 cmdline_parse_token_num_t cmd_ptype_mapping_replace_mask = 17434 TOKEN_NUM_INITIALIZER 17435 (struct cmd_ptype_mapping_replace_result, 17436 mask, UINT8); 17437 cmdline_parse_token_num_t cmd_ptype_mapping_replace_pkt_type = 17438 TOKEN_NUM_INITIALIZER 17439 (struct cmd_ptype_mapping_replace_result, 17440 pkt_type, UINT32); 17441 17442 static void 17443 cmd_ptype_mapping_replace_parsed( 17444 void *parsed_result, 17445 __attribute__((unused)) struct cmdline *cl, 17446 __attribute__((unused)) void *data) 17447 { 17448 struct cmd_ptype_mapping_replace_result *res = parsed_result; 17449 int ret = -ENOTSUP; 17450 17451 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17452 return; 17453 17454 #ifdef RTE_LIBRTE_I40E_PMD 17455 ret = rte_pmd_i40e_ptype_mapping_replace(res->port_id, 17456 res->target, 17457 res->mask, 17458 res->pkt_type); 17459 #endif 17460 17461 switch (ret) { 17462 case 0: 17463 break; 17464 case -EINVAL: 17465 printf("invalid ptype 0x%8x or 0x%8x\n", 17466 res->target, res->pkt_type); 17467 break; 17468 case -ENODEV: 17469 printf("invalid port_id %d\n", res->port_id); 17470 break; 17471 case -ENOTSUP: 17472 printf("function not implemented\n"); 17473 break; 17474 default: 17475 printf("programming error: (%s)\n", strerror(-ret)); 17476 } 17477 } 17478 17479 cmdline_parse_inst_t cmd_ptype_mapping_replace = { 17480 .f = cmd_ptype_mapping_replace_parsed, 17481 .data = NULL, 17482 .help_str = 17483 "ptype mapping replace <port_id> <target> <mask> <pkt_type>", 17484 .tokens = { 17485 (void *)&cmd_ptype_mapping_replace_ptype, 17486 (void *)&cmd_ptype_mapping_replace_mapping, 17487 (void *)&cmd_ptype_mapping_replace_replace, 17488 (void *)&cmd_ptype_mapping_replace_port_id, 17489 (void *)&cmd_ptype_mapping_replace_target, 17490 (void *)&cmd_ptype_mapping_replace_mask, 17491 (void *)&cmd_ptype_mapping_replace_pkt_type, 17492 NULL, 17493 }, 17494 }; 17495 17496 /* ptype mapping reset */ 17497 17498 /* Common result structure for ptype mapping reset */ 17499 struct cmd_ptype_mapping_reset_result { 17500 cmdline_fixed_string_t ptype; 17501 cmdline_fixed_string_t mapping; 17502 cmdline_fixed_string_t reset; 17503 portid_t port_id; 17504 }; 17505 17506 /* Common CLI fields for ptype mapping reset*/ 17507 cmdline_parse_token_string_t cmd_ptype_mapping_reset_ptype = 17508 TOKEN_STRING_INITIALIZER 17509 (struct cmd_ptype_mapping_reset_result, 17510 ptype, "ptype"); 17511 cmdline_parse_token_string_t cmd_ptype_mapping_reset_mapping = 17512 TOKEN_STRING_INITIALIZER 17513 (struct cmd_ptype_mapping_reset_result, 17514 mapping, "mapping"); 17515 cmdline_parse_token_string_t cmd_ptype_mapping_reset_reset = 17516 TOKEN_STRING_INITIALIZER 17517 (struct cmd_ptype_mapping_reset_result, 17518 reset, "reset"); 17519 cmdline_parse_token_num_t cmd_ptype_mapping_reset_port_id = 17520 TOKEN_NUM_INITIALIZER 17521 (struct cmd_ptype_mapping_reset_result, 17522 port_id, UINT16); 17523 17524 static void 17525 cmd_ptype_mapping_reset_parsed( 17526 void *parsed_result, 17527 __attribute__((unused)) struct cmdline *cl, 17528 __attribute__((unused)) void *data) 17529 { 17530 struct cmd_ptype_mapping_reset_result *res = parsed_result; 17531 int ret = -ENOTSUP; 17532 17533 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17534 return; 17535 17536 #ifdef RTE_LIBRTE_I40E_PMD 17537 ret = rte_pmd_i40e_ptype_mapping_reset(res->port_id); 17538 #endif 17539 17540 switch (ret) { 17541 case 0: 17542 break; 17543 case -ENODEV: 17544 printf("invalid port_id %d\n", res->port_id); 17545 break; 17546 case -ENOTSUP: 17547 printf("function not implemented\n"); 17548 break; 17549 default: 17550 printf("programming error: (%s)\n", strerror(-ret)); 17551 } 17552 } 17553 17554 cmdline_parse_inst_t cmd_ptype_mapping_reset = { 17555 .f = cmd_ptype_mapping_reset_parsed, 17556 .data = NULL, 17557 .help_str = "ptype mapping reset <port_id>", 17558 .tokens = { 17559 (void *)&cmd_ptype_mapping_reset_ptype, 17560 (void *)&cmd_ptype_mapping_reset_mapping, 17561 (void *)&cmd_ptype_mapping_reset_reset, 17562 (void *)&cmd_ptype_mapping_reset_port_id, 17563 NULL, 17564 }, 17565 }; 17566 17567 /* ptype mapping update */ 17568 17569 /* Common result structure for ptype mapping update */ 17570 struct cmd_ptype_mapping_update_result { 17571 cmdline_fixed_string_t ptype; 17572 cmdline_fixed_string_t mapping; 17573 cmdline_fixed_string_t reset; 17574 portid_t port_id; 17575 uint8_t hw_ptype; 17576 uint32_t sw_ptype; 17577 }; 17578 17579 /* Common CLI fields for ptype mapping update*/ 17580 cmdline_parse_token_string_t cmd_ptype_mapping_update_ptype = 17581 TOKEN_STRING_INITIALIZER 17582 (struct cmd_ptype_mapping_update_result, 17583 ptype, "ptype"); 17584 cmdline_parse_token_string_t cmd_ptype_mapping_update_mapping = 17585 TOKEN_STRING_INITIALIZER 17586 (struct cmd_ptype_mapping_update_result, 17587 mapping, "mapping"); 17588 cmdline_parse_token_string_t cmd_ptype_mapping_update_update = 17589 TOKEN_STRING_INITIALIZER 17590 (struct cmd_ptype_mapping_update_result, 17591 reset, "update"); 17592 cmdline_parse_token_num_t cmd_ptype_mapping_update_port_id = 17593 TOKEN_NUM_INITIALIZER 17594 (struct cmd_ptype_mapping_update_result, 17595 port_id, UINT16); 17596 cmdline_parse_token_num_t cmd_ptype_mapping_update_hw_ptype = 17597 TOKEN_NUM_INITIALIZER 17598 (struct cmd_ptype_mapping_update_result, 17599 hw_ptype, UINT8); 17600 cmdline_parse_token_num_t cmd_ptype_mapping_update_sw_ptype = 17601 TOKEN_NUM_INITIALIZER 17602 (struct cmd_ptype_mapping_update_result, 17603 sw_ptype, UINT32); 17604 17605 static void 17606 cmd_ptype_mapping_update_parsed( 17607 void *parsed_result, 17608 __attribute__((unused)) struct cmdline *cl, 17609 __attribute__((unused)) void *data) 17610 { 17611 struct cmd_ptype_mapping_update_result *res = parsed_result; 17612 int ret = -ENOTSUP; 17613 #ifdef RTE_LIBRTE_I40E_PMD 17614 struct rte_pmd_i40e_ptype_mapping mapping; 17615 #endif 17616 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 17617 return; 17618 17619 #ifdef RTE_LIBRTE_I40E_PMD 17620 mapping.hw_ptype = res->hw_ptype; 17621 mapping.sw_ptype = res->sw_ptype; 17622 ret = rte_pmd_i40e_ptype_mapping_update(res->port_id, 17623 &mapping, 17624 1, 17625 0); 17626 #endif 17627 17628 switch (ret) { 17629 case 0: 17630 break; 17631 case -EINVAL: 17632 printf("invalid ptype 0x%8x\n", res->sw_ptype); 17633 break; 17634 case -ENODEV: 17635 printf("invalid port_id %d\n", res->port_id); 17636 break; 17637 case -ENOTSUP: 17638 printf("function not implemented\n"); 17639 break; 17640 default: 17641 printf("programming error: (%s)\n", strerror(-ret)); 17642 } 17643 } 17644 17645 cmdline_parse_inst_t cmd_ptype_mapping_update = { 17646 .f = cmd_ptype_mapping_update_parsed, 17647 .data = NULL, 17648 .help_str = "ptype mapping update <port_id> <hw_ptype> <sw_ptype>", 17649 .tokens = { 17650 (void *)&cmd_ptype_mapping_update_ptype, 17651 (void *)&cmd_ptype_mapping_update_mapping, 17652 (void *)&cmd_ptype_mapping_update_update, 17653 (void *)&cmd_ptype_mapping_update_port_id, 17654 (void *)&cmd_ptype_mapping_update_hw_ptype, 17655 (void *)&cmd_ptype_mapping_update_sw_ptype, 17656 NULL, 17657 }, 17658 }; 17659 17660 /* Common result structure for file commands */ 17661 struct cmd_cmdfile_result { 17662 cmdline_fixed_string_t load; 17663 cmdline_fixed_string_t filename; 17664 }; 17665 17666 /* Common CLI fields for file commands */ 17667 cmdline_parse_token_string_t cmd_load_cmdfile = 17668 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, load, "load"); 17669 cmdline_parse_token_string_t cmd_load_cmdfile_filename = 17670 TOKEN_STRING_INITIALIZER(struct cmd_cmdfile_result, filename, NULL); 17671 17672 static void 17673 cmd_load_from_file_parsed( 17674 void *parsed_result, 17675 __attribute__((unused)) struct cmdline *cl, 17676 __attribute__((unused)) void *data) 17677 { 17678 struct cmd_cmdfile_result *res = parsed_result; 17679 17680 cmdline_read_from_file(res->filename); 17681 } 17682 17683 cmdline_parse_inst_t cmd_load_from_file = { 17684 .f = cmd_load_from_file_parsed, 17685 .data = NULL, 17686 .help_str = "load <filename>", 17687 .tokens = { 17688 (void *)&cmd_load_cmdfile, 17689 (void *)&cmd_load_cmdfile_filename, 17690 NULL, 17691 }, 17692 }; 17693 17694 /* Get Rx offloads capabilities */ 17695 struct cmd_rx_offload_get_capa_result { 17696 cmdline_fixed_string_t show; 17697 cmdline_fixed_string_t port; 17698 portid_t port_id; 17699 cmdline_fixed_string_t rx_offload; 17700 cmdline_fixed_string_t capabilities; 17701 }; 17702 17703 cmdline_parse_token_string_t cmd_rx_offload_get_capa_show = 17704 TOKEN_STRING_INITIALIZER 17705 (struct cmd_rx_offload_get_capa_result, 17706 show, "show"); 17707 cmdline_parse_token_string_t cmd_rx_offload_get_capa_port = 17708 TOKEN_STRING_INITIALIZER 17709 (struct cmd_rx_offload_get_capa_result, 17710 port, "port"); 17711 cmdline_parse_token_num_t cmd_rx_offload_get_capa_port_id = 17712 TOKEN_NUM_INITIALIZER 17713 (struct cmd_rx_offload_get_capa_result, 17714 port_id, UINT16); 17715 cmdline_parse_token_string_t cmd_rx_offload_get_capa_rx_offload = 17716 TOKEN_STRING_INITIALIZER 17717 (struct cmd_rx_offload_get_capa_result, 17718 rx_offload, "rx_offload"); 17719 cmdline_parse_token_string_t cmd_rx_offload_get_capa_capabilities = 17720 TOKEN_STRING_INITIALIZER 17721 (struct cmd_rx_offload_get_capa_result, 17722 capabilities, "capabilities"); 17723 17724 static void 17725 print_rx_offloads(uint64_t offloads) 17726 { 17727 uint64_t single_offload; 17728 int begin; 17729 int end; 17730 int bit; 17731 17732 if (offloads == 0) 17733 return; 17734 17735 begin = __builtin_ctzll(offloads); 17736 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 17737 17738 single_offload = 1 << begin; 17739 for (bit = begin; bit < end; bit++) { 17740 if (offloads & single_offload) 17741 printf(" %s", 17742 rte_eth_dev_rx_offload_name(single_offload)); 17743 single_offload <<= 1; 17744 } 17745 } 17746 17747 static void 17748 cmd_rx_offload_get_capa_parsed( 17749 void *parsed_result, 17750 __attribute__((unused)) struct cmdline *cl, 17751 __attribute__((unused)) void *data) 17752 { 17753 struct cmd_rx_offload_get_capa_result *res = parsed_result; 17754 struct rte_eth_dev_info dev_info; 17755 portid_t port_id = res->port_id; 17756 uint64_t queue_offloads; 17757 uint64_t port_offloads; 17758 17759 rte_eth_dev_info_get(port_id, &dev_info); 17760 queue_offloads = dev_info.rx_queue_offload_capa; 17761 port_offloads = dev_info.rx_offload_capa ^ queue_offloads; 17762 17763 printf("Rx Offloading Capabilities of port %d :\n", port_id); 17764 printf(" Per Queue :"); 17765 print_rx_offloads(queue_offloads); 17766 17767 printf("\n"); 17768 printf(" Per Port :"); 17769 print_rx_offloads(port_offloads); 17770 printf("\n\n"); 17771 } 17772 17773 cmdline_parse_inst_t cmd_rx_offload_get_capa = { 17774 .f = cmd_rx_offload_get_capa_parsed, 17775 .data = NULL, 17776 .help_str = "show port <port_id> rx_offload capabilities", 17777 .tokens = { 17778 (void *)&cmd_rx_offload_get_capa_show, 17779 (void *)&cmd_rx_offload_get_capa_port, 17780 (void *)&cmd_rx_offload_get_capa_port_id, 17781 (void *)&cmd_rx_offload_get_capa_rx_offload, 17782 (void *)&cmd_rx_offload_get_capa_capabilities, 17783 NULL, 17784 } 17785 }; 17786 17787 /* Get Rx offloads configuration */ 17788 struct cmd_rx_offload_get_configuration_result { 17789 cmdline_fixed_string_t show; 17790 cmdline_fixed_string_t port; 17791 portid_t port_id; 17792 cmdline_fixed_string_t rx_offload; 17793 cmdline_fixed_string_t configuration; 17794 }; 17795 17796 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_show = 17797 TOKEN_STRING_INITIALIZER 17798 (struct cmd_rx_offload_get_configuration_result, 17799 show, "show"); 17800 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_port = 17801 TOKEN_STRING_INITIALIZER 17802 (struct cmd_rx_offload_get_configuration_result, 17803 port, "port"); 17804 cmdline_parse_token_num_t cmd_rx_offload_get_configuration_port_id = 17805 TOKEN_NUM_INITIALIZER 17806 (struct cmd_rx_offload_get_configuration_result, 17807 port_id, UINT16); 17808 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_rx_offload = 17809 TOKEN_STRING_INITIALIZER 17810 (struct cmd_rx_offload_get_configuration_result, 17811 rx_offload, "rx_offload"); 17812 cmdline_parse_token_string_t cmd_rx_offload_get_configuration_configuration = 17813 TOKEN_STRING_INITIALIZER 17814 (struct cmd_rx_offload_get_configuration_result, 17815 configuration, "configuration"); 17816 17817 static void 17818 cmd_rx_offload_get_configuration_parsed( 17819 void *parsed_result, 17820 __attribute__((unused)) struct cmdline *cl, 17821 __attribute__((unused)) void *data) 17822 { 17823 struct cmd_rx_offload_get_configuration_result *res = parsed_result; 17824 struct rte_eth_dev_info dev_info; 17825 portid_t port_id = res->port_id; 17826 struct rte_port *port = &ports[port_id]; 17827 uint64_t port_offloads; 17828 uint64_t queue_offloads; 17829 uint16_t nb_rx_queues; 17830 int q; 17831 17832 printf("Rx Offloading Configuration of port %d :\n", port_id); 17833 17834 port_offloads = port->dev_conf.rxmode.offloads; 17835 printf(" Port :"); 17836 print_rx_offloads(port_offloads); 17837 printf("\n"); 17838 17839 rte_eth_dev_info_get(port_id, &dev_info); 17840 nb_rx_queues = dev_info.nb_rx_queues; 17841 for (q = 0; q < nb_rx_queues; q++) { 17842 queue_offloads = port->rx_conf[q].offloads; 17843 printf(" Queue[%2d] :", q); 17844 print_rx_offloads(queue_offloads); 17845 printf("\n"); 17846 } 17847 printf("\n"); 17848 } 17849 17850 cmdline_parse_inst_t cmd_rx_offload_get_configuration = { 17851 .f = cmd_rx_offload_get_configuration_parsed, 17852 .data = NULL, 17853 .help_str = "show port <port_id> rx_offload configuration", 17854 .tokens = { 17855 (void *)&cmd_rx_offload_get_configuration_show, 17856 (void *)&cmd_rx_offload_get_configuration_port, 17857 (void *)&cmd_rx_offload_get_configuration_port_id, 17858 (void *)&cmd_rx_offload_get_configuration_rx_offload, 17859 (void *)&cmd_rx_offload_get_configuration_configuration, 17860 NULL, 17861 } 17862 }; 17863 17864 /* Enable/Disable a per port offloading */ 17865 struct cmd_config_per_port_rx_offload_result { 17866 cmdline_fixed_string_t port; 17867 cmdline_fixed_string_t config; 17868 portid_t port_id; 17869 cmdline_fixed_string_t rx_offload; 17870 cmdline_fixed_string_t offload; 17871 cmdline_fixed_string_t on_off; 17872 }; 17873 17874 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_port = 17875 TOKEN_STRING_INITIALIZER 17876 (struct cmd_config_per_port_rx_offload_result, 17877 port, "port"); 17878 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_config = 17879 TOKEN_STRING_INITIALIZER 17880 (struct cmd_config_per_port_rx_offload_result, 17881 config, "config"); 17882 cmdline_parse_token_num_t cmd_config_per_port_rx_offload_result_port_id = 17883 TOKEN_NUM_INITIALIZER 17884 (struct cmd_config_per_port_rx_offload_result, 17885 port_id, UINT16); 17886 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_rx_offload = 17887 TOKEN_STRING_INITIALIZER 17888 (struct cmd_config_per_port_rx_offload_result, 17889 rx_offload, "rx_offload"); 17890 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_offload = 17891 TOKEN_STRING_INITIALIZER 17892 (struct cmd_config_per_port_rx_offload_result, 17893 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 17894 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 17895 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 17896 "crc_strip#scatter#timestamp#security#keep_crc"); 17897 cmdline_parse_token_string_t cmd_config_per_port_rx_offload_result_on_off = 17898 TOKEN_STRING_INITIALIZER 17899 (struct cmd_config_per_port_rx_offload_result, 17900 on_off, "on#off"); 17901 17902 static uint64_t 17903 search_rx_offload(const char *name) 17904 { 17905 uint64_t single_offload; 17906 const char *single_name; 17907 int found = 0; 17908 unsigned int bit; 17909 17910 single_offload = 1; 17911 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 17912 single_name = rte_eth_dev_rx_offload_name(single_offload); 17913 if (!strcasecmp(single_name, name)) { 17914 found = 1; 17915 break; 17916 } 17917 single_offload <<= 1; 17918 } 17919 17920 if (found) 17921 return single_offload; 17922 17923 return 0; 17924 } 17925 17926 static void 17927 cmd_config_per_port_rx_offload_parsed(void *parsed_result, 17928 __attribute__((unused)) struct cmdline *cl, 17929 __attribute__((unused)) void *data) 17930 { 17931 struct cmd_config_per_port_rx_offload_result *res = parsed_result; 17932 portid_t port_id = res->port_id; 17933 struct rte_eth_dev_info dev_info; 17934 struct rte_port *port = &ports[port_id]; 17935 uint64_t single_offload; 17936 uint16_t nb_rx_queues; 17937 int q; 17938 17939 if (port->port_status != RTE_PORT_STOPPED) { 17940 printf("Error: Can't config offload when Port %d " 17941 "is not stopped\n", port_id); 17942 return; 17943 } 17944 17945 single_offload = search_rx_offload(res->offload); 17946 if (single_offload == 0) { 17947 printf("Unknown offload name: %s\n", res->offload); 17948 return; 17949 } 17950 17951 rte_eth_dev_info_get(port_id, &dev_info); 17952 nb_rx_queues = dev_info.nb_rx_queues; 17953 if (!strcmp(res->on_off, "on")) { 17954 port->dev_conf.rxmode.offloads |= single_offload; 17955 for (q = 0; q < nb_rx_queues; q++) 17956 port->rx_conf[q].offloads |= single_offload; 17957 } else { 17958 port->dev_conf.rxmode.offloads &= ~single_offload; 17959 for (q = 0; q < nb_rx_queues; q++) 17960 port->rx_conf[q].offloads &= ~single_offload; 17961 } 17962 17963 cmd_reconfig_device_queue(port_id, 1, 1); 17964 } 17965 17966 cmdline_parse_inst_t cmd_config_per_port_rx_offload = { 17967 .f = cmd_config_per_port_rx_offload_parsed, 17968 .data = NULL, 17969 .help_str = "port config <port_id> rx_offload vlan_strip|ipv4_cksum|" 17970 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 17971 "macsec_strip|header_split|vlan_filter|vlan_extend|" 17972 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc " 17973 "on|off", 17974 .tokens = { 17975 (void *)&cmd_config_per_port_rx_offload_result_port, 17976 (void *)&cmd_config_per_port_rx_offload_result_config, 17977 (void *)&cmd_config_per_port_rx_offload_result_port_id, 17978 (void *)&cmd_config_per_port_rx_offload_result_rx_offload, 17979 (void *)&cmd_config_per_port_rx_offload_result_offload, 17980 (void *)&cmd_config_per_port_rx_offload_result_on_off, 17981 NULL, 17982 } 17983 }; 17984 17985 /* Enable/Disable a per queue offloading */ 17986 struct cmd_config_per_queue_rx_offload_result { 17987 cmdline_fixed_string_t port; 17988 portid_t port_id; 17989 cmdline_fixed_string_t rxq; 17990 uint16_t queue_id; 17991 cmdline_fixed_string_t rx_offload; 17992 cmdline_fixed_string_t offload; 17993 cmdline_fixed_string_t on_off; 17994 }; 17995 17996 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_port = 17997 TOKEN_STRING_INITIALIZER 17998 (struct cmd_config_per_queue_rx_offload_result, 17999 port, "port"); 18000 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_port_id = 18001 TOKEN_NUM_INITIALIZER 18002 (struct cmd_config_per_queue_rx_offload_result, 18003 port_id, UINT16); 18004 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxq = 18005 TOKEN_STRING_INITIALIZER 18006 (struct cmd_config_per_queue_rx_offload_result, 18007 rxq, "rxq"); 18008 cmdline_parse_token_num_t cmd_config_per_queue_rx_offload_result_queue_id = 18009 TOKEN_NUM_INITIALIZER 18010 (struct cmd_config_per_queue_rx_offload_result, 18011 queue_id, UINT16); 18012 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_rxoffload = 18013 TOKEN_STRING_INITIALIZER 18014 (struct cmd_config_per_queue_rx_offload_result, 18015 rx_offload, "rx_offload"); 18016 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_offload = 18017 TOKEN_STRING_INITIALIZER 18018 (struct cmd_config_per_queue_rx_offload_result, 18019 offload, "vlan_strip#ipv4_cksum#udp_cksum#tcp_cksum#tcp_lro#" 18020 "qinq_strip#outer_ipv4_cksum#macsec_strip#" 18021 "header_split#vlan_filter#vlan_extend#jumbo_frame#" 18022 "crc_strip#scatter#timestamp#security#keep_crc"); 18023 cmdline_parse_token_string_t cmd_config_per_queue_rx_offload_result_on_off = 18024 TOKEN_STRING_INITIALIZER 18025 (struct cmd_config_per_queue_rx_offload_result, 18026 on_off, "on#off"); 18027 18028 static void 18029 cmd_config_per_queue_rx_offload_parsed(void *parsed_result, 18030 __attribute__((unused)) struct cmdline *cl, 18031 __attribute__((unused)) void *data) 18032 { 18033 struct cmd_config_per_queue_rx_offload_result *res = parsed_result; 18034 struct rte_eth_dev_info dev_info; 18035 portid_t port_id = res->port_id; 18036 uint16_t queue_id = res->queue_id; 18037 struct rte_port *port = &ports[port_id]; 18038 uint64_t single_offload; 18039 18040 if (port->port_status != RTE_PORT_STOPPED) { 18041 printf("Error: Can't config offload when Port %d " 18042 "is not stopped\n", port_id); 18043 return; 18044 } 18045 18046 rte_eth_dev_info_get(port_id, &dev_info); 18047 if (queue_id >= dev_info.nb_rx_queues) { 18048 printf("Error: input queue_id should be 0 ... " 18049 "%d\n", dev_info.nb_rx_queues - 1); 18050 return; 18051 } 18052 18053 single_offload = search_rx_offload(res->offload); 18054 if (single_offload == 0) { 18055 printf("Unknown offload name: %s\n", res->offload); 18056 return; 18057 } 18058 18059 if (!strcmp(res->on_off, "on")) 18060 port->rx_conf[queue_id].offloads |= single_offload; 18061 else 18062 port->rx_conf[queue_id].offloads &= ~single_offload; 18063 18064 cmd_reconfig_device_queue(port_id, 1, 1); 18065 } 18066 18067 cmdline_parse_inst_t cmd_config_per_queue_rx_offload = { 18068 .f = cmd_config_per_queue_rx_offload_parsed, 18069 .data = NULL, 18070 .help_str = "port <port_id> rxq <queue_id> rx_offload " 18071 "vlan_strip|ipv4_cksum|" 18072 "udp_cksum|tcp_cksum|tcp_lro|qinq_strip|outer_ipv4_cksum|" 18073 "macsec_strip|header_split|vlan_filter|vlan_extend|" 18074 "jumbo_frame|crc_strip|scatter|timestamp|security|keep_crc " 18075 "on|off", 18076 .tokens = { 18077 (void *)&cmd_config_per_queue_rx_offload_result_port, 18078 (void *)&cmd_config_per_queue_rx_offload_result_port_id, 18079 (void *)&cmd_config_per_queue_rx_offload_result_rxq, 18080 (void *)&cmd_config_per_queue_rx_offload_result_queue_id, 18081 (void *)&cmd_config_per_queue_rx_offload_result_rxoffload, 18082 (void *)&cmd_config_per_queue_rx_offload_result_offload, 18083 (void *)&cmd_config_per_queue_rx_offload_result_on_off, 18084 NULL, 18085 } 18086 }; 18087 18088 /* Get Tx offloads capabilities */ 18089 struct cmd_tx_offload_get_capa_result { 18090 cmdline_fixed_string_t show; 18091 cmdline_fixed_string_t port; 18092 portid_t port_id; 18093 cmdline_fixed_string_t tx_offload; 18094 cmdline_fixed_string_t capabilities; 18095 }; 18096 18097 cmdline_parse_token_string_t cmd_tx_offload_get_capa_show = 18098 TOKEN_STRING_INITIALIZER 18099 (struct cmd_tx_offload_get_capa_result, 18100 show, "show"); 18101 cmdline_parse_token_string_t cmd_tx_offload_get_capa_port = 18102 TOKEN_STRING_INITIALIZER 18103 (struct cmd_tx_offload_get_capa_result, 18104 port, "port"); 18105 cmdline_parse_token_num_t cmd_tx_offload_get_capa_port_id = 18106 TOKEN_NUM_INITIALIZER 18107 (struct cmd_tx_offload_get_capa_result, 18108 port_id, UINT16); 18109 cmdline_parse_token_string_t cmd_tx_offload_get_capa_tx_offload = 18110 TOKEN_STRING_INITIALIZER 18111 (struct cmd_tx_offload_get_capa_result, 18112 tx_offload, "tx_offload"); 18113 cmdline_parse_token_string_t cmd_tx_offload_get_capa_capabilities = 18114 TOKEN_STRING_INITIALIZER 18115 (struct cmd_tx_offload_get_capa_result, 18116 capabilities, "capabilities"); 18117 18118 static void 18119 print_tx_offloads(uint64_t offloads) 18120 { 18121 uint64_t single_offload; 18122 int begin; 18123 int end; 18124 int bit; 18125 18126 if (offloads == 0) 18127 return; 18128 18129 begin = __builtin_ctzll(offloads); 18130 end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads); 18131 18132 single_offload = 1 << begin; 18133 for (bit = begin; bit < end; bit++) { 18134 if (offloads & single_offload) 18135 printf(" %s", 18136 rte_eth_dev_tx_offload_name(single_offload)); 18137 single_offload <<= 1; 18138 } 18139 } 18140 18141 static void 18142 cmd_tx_offload_get_capa_parsed( 18143 void *parsed_result, 18144 __attribute__((unused)) struct cmdline *cl, 18145 __attribute__((unused)) void *data) 18146 { 18147 struct cmd_tx_offload_get_capa_result *res = parsed_result; 18148 struct rte_eth_dev_info dev_info; 18149 portid_t port_id = res->port_id; 18150 uint64_t queue_offloads; 18151 uint64_t port_offloads; 18152 18153 rte_eth_dev_info_get(port_id, &dev_info); 18154 queue_offloads = dev_info.tx_queue_offload_capa; 18155 port_offloads = dev_info.tx_offload_capa ^ queue_offloads; 18156 18157 printf("Tx Offloading Capabilities of port %d :\n", port_id); 18158 printf(" Per Queue :"); 18159 print_tx_offloads(queue_offloads); 18160 18161 printf("\n"); 18162 printf(" Per Port :"); 18163 print_tx_offloads(port_offloads); 18164 printf("\n\n"); 18165 } 18166 18167 cmdline_parse_inst_t cmd_tx_offload_get_capa = { 18168 .f = cmd_tx_offload_get_capa_parsed, 18169 .data = NULL, 18170 .help_str = "show port <port_id> tx_offload capabilities", 18171 .tokens = { 18172 (void *)&cmd_tx_offload_get_capa_show, 18173 (void *)&cmd_tx_offload_get_capa_port, 18174 (void *)&cmd_tx_offload_get_capa_port_id, 18175 (void *)&cmd_tx_offload_get_capa_tx_offload, 18176 (void *)&cmd_tx_offload_get_capa_capabilities, 18177 NULL, 18178 } 18179 }; 18180 18181 /* Get Tx offloads configuration */ 18182 struct cmd_tx_offload_get_configuration_result { 18183 cmdline_fixed_string_t show; 18184 cmdline_fixed_string_t port; 18185 portid_t port_id; 18186 cmdline_fixed_string_t tx_offload; 18187 cmdline_fixed_string_t configuration; 18188 }; 18189 18190 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_show = 18191 TOKEN_STRING_INITIALIZER 18192 (struct cmd_tx_offload_get_configuration_result, 18193 show, "show"); 18194 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_port = 18195 TOKEN_STRING_INITIALIZER 18196 (struct cmd_tx_offload_get_configuration_result, 18197 port, "port"); 18198 cmdline_parse_token_num_t cmd_tx_offload_get_configuration_port_id = 18199 TOKEN_NUM_INITIALIZER 18200 (struct cmd_tx_offload_get_configuration_result, 18201 port_id, UINT16); 18202 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_tx_offload = 18203 TOKEN_STRING_INITIALIZER 18204 (struct cmd_tx_offload_get_configuration_result, 18205 tx_offload, "tx_offload"); 18206 cmdline_parse_token_string_t cmd_tx_offload_get_configuration_configuration = 18207 TOKEN_STRING_INITIALIZER 18208 (struct cmd_tx_offload_get_configuration_result, 18209 configuration, "configuration"); 18210 18211 static void 18212 cmd_tx_offload_get_configuration_parsed( 18213 void *parsed_result, 18214 __attribute__((unused)) struct cmdline *cl, 18215 __attribute__((unused)) void *data) 18216 { 18217 struct cmd_tx_offload_get_configuration_result *res = parsed_result; 18218 struct rte_eth_dev_info dev_info; 18219 portid_t port_id = res->port_id; 18220 struct rte_port *port = &ports[port_id]; 18221 uint64_t port_offloads; 18222 uint64_t queue_offloads; 18223 uint16_t nb_tx_queues; 18224 int q; 18225 18226 printf("Tx Offloading Configuration of port %d :\n", port_id); 18227 18228 port_offloads = port->dev_conf.txmode.offloads; 18229 printf(" Port :"); 18230 print_tx_offloads(port_offloads); 18231 printf("\n"); 18232 18233 rte_eth_dev_info_get(port_id, &dev_info); 18234 nb_tx_queues = dev_info.nb_tx_queues; 18235 for (q = 0; q < nb_tx_queues; q++) { 18236 queue_offloads = port->tx_conf[q].offloads; 18237 printf(" Queue[%2d] :", q); 18238 print_tx_offloads(queue_offloads); 18239 printf("\n"); 18240 } 18241 printf("\n"); 18242 } 18243 18244 cmdline_parse_inst_t cmd_tx_offload_get_configuration = { 18245 .f = cmd_tx_offload_get_configuration_parsed, 18246 .data = NULL, 18247 .help_str = "show port <port_id> tx_offload configuration", 18248 .tokens = { 18249 (void *)&cmd_tx_offload_get_configuration_show, 18250 (void *)&cmd_tx_offload_get_configuration_port, 18251 (void *)&cmd_tx_offload_get_configuration_port_id, 18252 (void *)&cmd_tx_offload_get_configuration_tx_offload, 18253 (void *)&cmd_tx_offload_get_configuration_configuration, 18254 NULL, 18255 } 18256 }; 18257 18258 /* Enable/Disable a per port offloading */ 18259 struct cmd_config_per_port_tx_offload_result { 18260 cmdline_fixed_string_t port; 18261 cmdline_fixed_string_t config; 18262 portid_t port_id; 18263 cmdline_fixed_string_t tx_offload; 18264 cmdline_fixed_string_t offload; 18265 cmdline_fixed_string_t on_off; 18266 }; 18267 18268 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_port = 18269 TOKEN_STRING_INITIALIZER 18270 (struct cmd_config_per_port_tx_offload_result, 18271 port, "port"); 18272 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_config = 18273 TOKEN_STRING_INITIALIZER 18274 (struct cmd_config_per_port_tx_offload_result, 18275 config, "config"); 18276 cmdline_parse_token_num_t cmd_config_per_port_tx_offload_result_port_id = 18277 TOKEN_NUM_INITIALIZER 18278 (struct cmd_config_per_port_tx_offload_result, 18279 port_id, UINT16); 18280 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_tx_offload = 18281 TOKEN_STRING_INITIALIZER 18282 (struct cmd_config_per_port_tx_offload_result, 18283 tx_offload, "tx_offload"); 18284 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_offload = 18285 TOKEN_STRING_INITIALIZER 18286 (struct cmd_config_per_port_tx_offload_result, 18287 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 18288 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 18289 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 18290 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 18291 "mt_lockfree#multi_segs#mbuf_fast_free#security#" 18292 "match_metadata"); 18293 cmdline_parse_token_string_t cmd_config_per_port_tx_offload_result_on_off = 18294 TOKEN_STRING_INITIALIZER 18295 (struct cmd_config_per_port_tx_offload_result, 18296 on_off, "on#off"); 18297 18298 static uint64_t 18299 search_tx_offload(const char *name) 18300 { 18301 uint64_t single_offload; 18302 const char *single_name; 18303 int found = 0; 18304 unsigned int bit; 18305 18306 single_offload = 1; 18307 for (bit = 0; bit < sizeof(single_offload) * CHAR_BIT; bit++) { 18308 single_name = rte_eth_dev_tx_offload_name(single_offload); 18309 if (!strcasecmp(single_name, name)) { 18310 found = 1; 18311 break; 18312 } else if (!strcasecmp(single_name, "UNKNOWN")) 18313 break; 18314 else if (single_name == NULL) 18315 break; 18316 single_offload <<= 1; 18317 } 18318 18319 if (found) 18320 return single_offload; 18321 18322 return 0; 18323 } 18324 18325 static void 18326 cmd_config_per_port_tx_offload_parsed(void *parsed_result, 18327 __attribute__((unused)) struct cmdline *cl, 18328 __attribute__((unused)) void *data) 18329 { 18330 struct cmd_config_per_port_tx_offload_result *res = parsed_result; 18331 portid_t port_id = res->port_id; 18332 struct rte_eth_dev_info dev_info; 18333 struct rte_port *port = &ports[port_id]; 18334 uint64_t single_offload; 18335 uint16_t nb_tx_queues; 18336 int q; 18337 18338 if (port->port_status != RTE_PORT_STOPPED) { 18339 printf("Error: Can't config offload when Port %d " 18340 "is not stopped\n", port_id); 18341 return; 18342 } 18343 18344 single_offload = search_tx_offload(res->offload); 18345 if (single_offload == 0) { 18346 printf("Unknown offload name: %s\n", res->offload); 18347 return; 18348 } 18349 18350 rte_eth_dev_info_get(port_id, &dev_info); 18351 nb_tx_queues = dev_info.nb_tx_queues; 18352 if (!strcmp(res->on_off, "on")) { 18353 port->dev_conf.txmode.offloads |= single_offload; 18354 for (q = 0; q < nb_tx_queues; q++) 18355 port->tx_conf[q].offloads |= single_offload; 18356 } else { 18357 port->dev_conf.txmode.offloads &= ~single_offload; 18358 for (q = 0; q < nb_tx_queues; q++) 18359 port->tx_conf[q].offloads &= ~single_offload; 18360 } 18361 18362 cmd_reconfig_device_queue(port_id, 1, 1); 18363 } 18364 18365 cmdline_parse_inst_t cmd_config_per_port_tx_offload = { 18366 .f = cmd_config_per_port_tx_offload_parsed, 18367 .data = NULL, 18368 .help_str = "port config <port_id> tx_offload " 18369 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 18370 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 18371 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 18372 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 18373 "mt_lockfree|multi_segs|mbuf_fast_free|security|" 18374 "match_metadata on|off", 18375 .tokens = { 18376 (void *)&cmd_config_per_port_tx_offload_result_port, 18377 (void *)&cmd_config_per_port_tx_offload_result_config, 18378 (void *)&cmd_config_per_port_tx_offload_result_port_id, 18379 (void *)&cmd_config_per_port_tx_offload_result_tx_offload, 18380 (void *)&cmd_config_per_port_tx_offload_result_offload, 18381 (void *)&cmd_config_per_port_tx_offload_result_on_off, 18382 NULL, 18383 } 18384 }; 18385 18386 /* Enable/Disable a per queue offloading */ 18387 struct cmd_config_per_queue_tx_offload_result { 18388 cmdline_fixed_string_t port; 18389 portid_t port_id; 18390 cmdline_fixed_string_t txq; 18391 uint16_t queue_id; 18392 cmdline_fixed_string_t tx_offload; 18393 cmdline_fixed_string_t offload; 18394 cmdline_fixed_string_t on_off; 18395 }; 18396 18397 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_port = 18398 TOKEN_STRING_INITIALIZER 18399 (struct cmd_config_per_queue_tx_offload_result, 18400 port, "port"); 18401 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_port_id = 18402 TOKEN_NUM_INITIALIZER 18403 (struct cmd_config_per_queue_tx_offload_result, 18404 port_id, UINT16); 18405 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txq = 18406 TOKEN_STRING_INITIALIZER 18407 (struct cmd_config_per_queue_tx_offload_result, 18408 txq, "txq"); 18409 cmdline_parse_token_num_t cmd_config_per_queue_tx_offload_result_queue_id = 18410 TOKEN_NUM_INITIALIZER 18411 (struct cmd_config_per_queue_tx_offload_result, 18412 queue_id, UINT16); 18413 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_txoffload = 18414 TOKEN_STRING_INITIALIZER 18415 (struct cmd_config_per_queue_tx_offload_result, 18416 tx_offload, "tx_offload"); 18417 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_offload = 18418 TOKEN_STRING_INITIALIZER 18419 (struct cmd_config_per_queue_tx_offload_result, 18420 offload, "vlan_insert#ipv4_cksum#udp_cksum#tcp_cksum#" 18421 "sctp_cksum#tcp_tso#udp_tso#outer_ipv4_cksum#" 18422 "qinq_insert#vxlan_tnl_tso#gre_tnl_tso#" 18423 "ipip_tnl_tso#geneve_tnl_tso#macsec_insert#" 18424 "mt_lockfree#multi_segs#mbuf_fast_free#security"); 18425 cmdline_parse_token_string_t cmd_config_per_queue_tx_offload_result_on_off = 18426 TOKEN_STRING_INITIALIZER 18427 (struct cmd_config_per_queue_tx_offload_result, 18428 on_off, "on#off"); 18429 18430 static void 18431 cmd_config_per_queue_tx_offload_parsed(void *parsed_result, 18432 __attribute__((unused)) struct cmdline *cl, 18433 __attribute__((unused)) void *data) 18434 { 18435 struct cmd_config_per_queue_tx_offload_result *res = parsed_result; 18436 struct rte_eth_dev_info dev_info; 18437 portid_t port_id = res->port_id; 18438 uint16_t queue_id = res->queue_id; 18439 struct rte_port *port = &ports[port_id]; 18440 uint64_t single_offload; 18441 18442 if (port->port_status != RTE_PORT_STOPPED) { 18443 printf("Error: Can't config offload when Port %d " 18444 "is not stopped\n", port_id); 18445 return; 18446 } 18447 18448 rte_eth_dev_info_get(port_id, &dev_info); 18449 if (queue_id >= dev_info.nb_tx_queues) { 18450 printf("Error: input queue_id should be 0 ... " 18451 "%d\n", dev_info.nb_tx_queues - 1); 18452 return; 18453 } 18454 18455 single_offload = search_tx_offload(res->offload); 18456 if (single_offload == 0) { 18457 printf("Unknown offload name: %s\n", res->offload); 18458 return; 18459 } 18460 18461 if (!strcmp(res->on_off, "on")) 18462 port->tx_conf[queue_id].offloads |= single_offload; 18463 else 18464 port->tx_conf[queue_id].offloads &= ~single_offload; 18465 18466 cmd_reconfig_device_queue(port_id, 1, 1); 18467 } 18468 18469 cmdline_parse_inst_t cmd_config_per_queue_tx_offload = { 18470 .f = cmd_config_per_queue_tx_offload_parsed, 18471 .data = NULL, 18472 .help_str = "port <port_id> txq <queue_id> tx_offload " 18473 "vlan_insert|ipv4_cksum|udp_cksum|tcp_cksum|" 18474 "sctp_cksum|tcp_tso|udp_tso|outer_ipv4_cksum|" 18475 "qinq_insert|vxlan_tnl_tso|gre_tnl_tso|" 18476 "ipip_tnl_tso|geneve_tnl_tso|macsec_insert|" 18477 "mt_lockfree|multi_segs|mbuf_fast_free|security " 18478 "on|off", 18479 .tokens = { 18480 (void *)&cmd_config_per_queue_tx_offload_result_port, 18481 (void *)&cmd_config_per_queue_tx_offload_result_port_id, 18482 (void *)&cmd_config_per_queue_tx_offload_result_txq, 18483 (void *)&cmd_config_per_queue_tx_offload_result_queue_id, 18484 (void *)&cmd_config_per_queue_tx_offload_result_txoffload, 18485 (void *)&cmd_config_per_queue_tx_offload_result_offload, 18486 (void *)&cmd_config_per_queue_tx_offload_result_on_off, 18487 NULL, 18488 } 18489 }; 18490 18491 /* *** configure tx_metadata for specific port *** */ 18492 struct cmd_config_tx_metadata_specific_result { 18493 cmdline_fixed_string_t port; 18494 cmdline_fixed_string_t keyword; 18495 uint16_t port_id; 18496 cmdline_fixed_string_t item; 18497 uint32_t value; 18498 }; 18499 18500 static void 18501 cmd_config_tx_metadata_specific_parsed(void *parsed_result, 18502 __attribute__((unused)) struct cmdline *cl, 18503 __attribute__((unused)) void *data) 18504 { 18505 struct cmd_config_tx_metadata_specific_result *res = parsed_result; 18506 18507 if (port_id_is_invalid(res->port_id, ENABLED_WARN)) 18508 return; 18509 ports[res->port_id].tx_metadata = rte_cpu_to_be_32(res->value); 18510 /* Add/remove callback to insert valid metadata in every Tx packet. */ 18511 if (ports[res->port_id].tx_metadata) 18512 add_tx_md_callback(res->port_id); 18513 else 18514 remove_tx_md_callback(res->port_id); 18515 } 18516 18517 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_port = 18518 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18519 port, "port"); 18520 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_keyword = 18521 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18522 keyword, "config"); 18523 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_id = 18524 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18525 port_id, UINT16); 18526 cmdline_parse_token_string_t cmd_config_tx_metadata_specific_item = 18527 TOKEN_STRING_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18528 item, "tx_metadata"); 18529 cmdline_parse_token_num_t cmd_config_tx_metadata_specific_value = 18530 TOKEN_NUM_INITIALIZER(struct cmd_config_tx_metadata_specific_result, 18531 value, UINT32); 18532 18533 cmdline_parse_inst_t cmd_config_tx_metadata_specific = { 18534 .f = cmd_config_tx_metadata_specific_parsed, 18535 .data = NULL, 18536 .help_str = "port config <port_id> tx_metadata <value>", 18537 .tokens = { 18538 (void *)&cmd_config_tx_metadata_specific_port, 18539 (void *)&cmd_config_tx_metadata_specific_keyword, 18540 (void *)&cmd_config_tx_metadata_specific_id, 18541 (void *)&cmd_config_tx_metadata_specific_item, 18542 (void *)&cmd_config_tx_metadata_specific_value, 18543 NULL, 18544 }, 18545 }; 18546 18547 /* *** display tx_metadata per port configuration *** */ 18548 struct cmd_show_tx_metadata_result { 18549 cmdline_fixed_string_t cmd_show; 18550 cmdline_fixed_string_t cmd_port; 18551 cmdline_fixed_string_t cmd_keyword; 18552 portid_t cmd_pid; 18553 }; 18554 18555 static void 18556 cmd_show_tx_metadata_parsed(void *parsed_result, 18557 __attribute__((unused)) struct cmdline *cl, 18558 __attribute__((unused)) void *data) 18559 { 18560 struct cmd_show_tx_metadata_result *res = parsed_result; 18561 18562 if (!rte_eth_dev_is_valid_port(res->cmd_pid)) { 18563 printf("invalid port id %u\n", res->cmd_pid); 18564 return; 18565 } 18566 if (!strcmp(res->cmd_keyword, "tx_metadata")) { 18567 printf("Port %u tx_metadata: %u\n", res->cmd_pid, 18568 rte_be_to_cpu_32(ports[res->cmd_pid].tx_metadata)); 18569 } 18570 } 18571 18572 cmdline_parse_token_string_t cmd_show_tx_metadata_show = 18573 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18574 cmd_show, "show"); 18575 cmdline_parse_token_string_t cmd_show_tx_metadata_port = 18576 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18577 cmd_port, "port"); 18578 cmdline_parse_token_num_t cmd_show_tx_metadata_pid = 18579 TOKEN_NUM_INITIALIZER(struct cmd_show_tx_metadata_result, 18580 cmd_pid, UINT16); 18581 cmdline_parse_token_string_t cmd_show_tx_metadata_keyword = 18582 TOKEN_STRING_INITIALIZER(struct cmd_show_tx_metadata_result, 18583 cmd_keyword, "tx_metadata"); 18584 18585 cmdline_parse_inst_t cmd_show_tx_metadata = { 18586 .f = cmd_show_tx_metadata_parsed, 18587 .data = NULL, 18588 .help_str = "show port <port_id> tx_metadata", 18589 .tokens = { 18590 (void *)&cmd_show_tx_metadata_show, 18591 (void *)&cmd_show_tx_metadata_port, 18592 (void *)&cmd_show_tx_metadata_pid, 18593 (void *)&cmd_show_tx_metadata_keyword, 18594 NULL, 18595 }, 18596 }; 18597 18598 /* ******************************************************************************** */ 18599 18600 /* list of instructions */ 18601 cmdline_parse_ctx_t main_ctx[] = { 18602 (cmdline_parse_inst_t *)&cmd_help_brief, 18603 (cmdline_parse_inst_t *)&cmd_help_long, 18604 (cmdline_parse_inst_t *)&cmd_quit, 18605 (cmdline_parse_inst_t *)&cmd_load_from_file, 18606 (cmdline_parse_inst_t *)&cmd_showport, 18607 (cmdline_parse_inst_t *)&cmd_showqueue, 18608 (cmdline_parse_inst_t *)&cmd_showportall, 18609 (cmdline_parse_inst_t *)&cmd_showcfg, 18610 (cmdline_parse_inst_t *)&cmd_showfwdall, 18611 (cmdline_parse_inst_t *)&cmd_start, 18612 (cmdline_parse_inst_t *)&cmd_start_tx_first, 18613 (cmdline_parse_inst_t *)&cmd_start_tx_first_n, 18614 (cmdline_parse_inst_t *)&cmd_set_link_up, 18615 (cmdline_parse_inst_t *)&cmd_set_link_down, 18616 (cmdline_parse_inst_t *)&cmd_reset, 18617 (cmdline_parse_inst_t *)&cmd_set_numbers, 18618 (cmdline_parse_inst_t *)&cmd_set_log, 18619 (cmdline_parse_inst_t *)&cmd_set_txpkts, 18620 (cmdline_parse_inst_t *)&cmd_set_txsplit, 18621 (cmdline_parse_inst_t *)&cmd_set_fwd_list, 18622 (cmdline_parse_inst_t *)&cmd_set_fwd_mask, 18623 (cmdline_parse_inst_t *)&cmd_set_fwd_mode, 18624 (cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode, 18625 (cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, 18626 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_one, 18627 (cmdline_parse_inst_t *)&cmd_set_promisc_mode_all, 18628 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_one, 18629 (cmdline_parse_inst_t *)&cmd_set_allmulti_mode_all, 18630 (cmdline_parse_inst_t *)&cmd_set_flush_rx, 18631 (cmdline_parse_inst_t *)&cmd_set_link_check, 18632 (cmdline_parse_inst_t *)&cmd_set_bypass_mode, 18633 (cmdline_parse_inst_t *)&cmd_set_bypass_event, 18634 (cmdline_parse_inst_t *)&cmd_set_bypass_timeout, 18635 (cmdline_parse_inst_t *)&cmd_show_bypass_config, 18636 #ifdef RTE_LIBRTE_PMD_BOND 18637 (cmdline_parse_inst_t *) &cmd_set_bonding_mode, 18638 (cmdline_parse_inst_t *) &cmd_show_bonding_config, 18639 (cmdline_parse_inst_t *) &cmd_set_bonding_primary, 18640 (cmdline_parse_inst_t *) &cmd_add_bonding_slave, 18641 (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, 18642 (cmdline_parse_inst_t *) &cmd_create_bonded_device, 18643 (cmdline_parse_inst_t *) &cmd_set_bond_mac_addr, 18644 (cmdline_parse_inst_t *) &cmd_set_balance_xmit_policy, 18645 (cmdline_parse_inst_t *) &cmd_set_bond_mon_period, 18646 (cmdline_parse_inst_t *) &cmd_set_lacp_dedicated_queues, 18647 (cmdline_parse_inst_t *) &cmd_set_bonding_agg_mode_policy, 18648 #endif 18649 (cmdline_parse_inst_t *)&cmd_vlan_offload, 18650 (cmdline_parse_inst_t *)&cmd_vlan_tpid, 18651 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter_all, 18652 (cmdline_parse_inst_t *)&cmd_rx_vlan_filter, 18653 (cmdline_parse_inst_t *)&cmd_tx_vlan_set, 18654 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_qinq, 18655 (cmdline_parse_inst_t *)&cmd_tx_vlan_reset, 18656 (cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid, 18657 (cmdline_parse_inst_t *)&cmd_csum_set, 18658 (cmdline_parse_inst_t *)&cmd_csum_show, 18659 (cmdline_parse_inst_t *)&cmd_csum_tunnel, 18660 (cmdline_parse_inst_t *)&cmd_tso_set, 18661 (cmdline_parse_inst_t *)&cmd_tso_show, 18662 (cmdline_parse_inst_t *)&cmd_tunnel_tso_set, 18663 (cmdline_parse_inst_t *)&cmd_tunnel_tso_show, 18664 (cmdline_parse_inst_t *)&cmd_gro_enable, 18665 (cmdline_parse_inst_t *)&cmd_gro_flush, 18666 (cmdline_parse_inst_t *)&cmd_gro_show, 18667 (cmdline_parse_inst_t *)&cmd_gso_enable, 18668 (cmdline_parse_inst_t *)&cmd_gso_size, 18669 (cmdline_parse_inst_t *)&cmd_gso_show, 18670 (cmdline_parse_inst_t *)&cmd_link_flow_control_set, 18671 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx, 18672 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx, 18673 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw, 18674 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw, 18675 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt, 18676 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, 18677 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, 18678 (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, 18679 (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, 18680 (cmdline_parse_inst_t *)&cmd_config_dcb, 18681 (cmdline_parse_inst_t *)&cmd_read_reg, 18682 (cmdline_parse_inst_t *)&cmd_read_reg_bit_field, 18683 (cmdline_parse_inst_t *)&cmd_read_reg_bit, 18684 (cmdline_parse_inst_t *)&cmd_write_reg, 18685 (cmdline_parse_inst_t *)&cmd_write_reg_bit_field, 18686 (cmdline_parse_inst_t *)&cmd_write_reg_bit, 18687 (cmdline_parse_inst_t *)&cmd_read_rxd_txd, 18688 (cmdline_parse_inst_t *)&cmd_stop, 18689 (cmdline_parse_inst_t *)&cmd_mac_addr, 18690 (cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer, 18691 (cmdline_parse_inst_t *)&cmd_set_qmap, 18692 (cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero, 18693 (cmdline_parse_inst_t *)&cmd_operate_port, 18694 (cmdline_parse_inst_t *)&cmd_operate_specific_port, 18695 (cmdline_parse_inst_t *)&cmd_operate_attach_port, 18696 (cmdline_parse_inst_t *)&cmd_operate_detach_port, 18697 (cmdline_parse_inst_t *)&cmd_set_port_setup_on, 18698 (cmdline_parse_inst_t *)&cmd_config_speed_all, 18699 (cmdline_parse_inst_t *)&cmd_config_speed_specific, 18700 (cmdline_parse_inst_t *)&cmd_config_loopback_all, 18701 (cmdline_parse_inst_t *)&cmd_config_loopback_specific, 18702 (cmdline_parse_inst_t *)&cmd_config_rx_tx, 18703 (cmdline_parse_inst_t *)&cmd_config_mtu, 18704 (cmdline_parse_inst_t *)&cmd_config_max_pkt_len, 18705 (cmdline_parse_inst_t *)&cmd_config_rx_mode_flag, 18706 (cmdline_parse_inst_t *)&cmd_config_rss, 18707 (cmdline_parse_inst_t *)&cmd_config_rxtx_ring_size, 18708 (cmdline_parse_inst_t *)&cmd_config_rxtx_queue, 18709 (cmdline_parse_inst_t *)&cmd_config_deferred_start_rxtx_queue, 18710 (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue, 18711 (cmdline_parse_inst_t *)&cmd_config_rss_reta, 18712 (cmdline_parse_inst_t *)&cmd_showport_reta, 18713 (cmdline_parse_inst_t *)&cmd_config_burst, 18714 (cmdline_parse_inst_t *)&cmd_config_thresh, 18715 (cmdline_parse_inst_t *)&cmd_config_threshold, 18716 (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter, 18717 (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, 18718 (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, 18719 (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter, 18720 (cmdline_parse_inst_t *)&cmd_queue_rate_limit, 18721 (cmdline_parse_inst_t *)&cmd_tunnel_filter, 18722 (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, 18723 (cmdline_parse_inst_t *)&cmd_global_config, 18724 (cmdline_parse_inst_t *)&cmd_set_mirror_mask, 18725 (cmdline_parse_inst_t *)&cmd_set_mirror_link, 18726 (cmdline_parse_inst_t *)&cmd_reset_mirror_rule, 18727 (cmdline_parse_inst_t *)&cmd_showport_rss_hash, 18728 (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, 18729 (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, 18730 (cmdline_parse_inst_t *)&cmd_dump, 18731 (cmdline_parse_inst_t *)&cmd_dump_one, 18732 (cmdline_parse_inst_t *)&cmd_ethertype_filter, 18733 (cmdline_parse_inst_t *)&cmd_syn_filter, 18734 (cmdline_parse_inst_t *)&cmd_2tuple_filter, 18735 (cmdline_parse_inst_t *)&cmd_5tuple_filter, 18736 (cmdline_parse_inst_t *)&cmd_flex_filter, 18737 (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director, 18738 (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director, 18739 (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director, 18740 (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director, 18741 (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director, 18742 (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director, 18743 (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director, 18744 (cmdline_parse_inst_t *)&cmd_flush_flow_director, 18745 (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask, 18746 (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask, 18747 (cmdline_parse_inst_t *)&cmd_set_flow_director_tunnel_mask, 18748 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_mask, 18749 (cmdline_parse_inst_t *)&cmd_set_flow_director_flex_payload, 18750 (cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_port, 18751 (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port, 18752 (cmdline_parse_inst_t *)&cmd_get_hash_global_config, 18753 (cmdline_parse_inst_t *)&cmd_set_hash_global_config, 18754 (cmdline_parse_inst_t *)&cmd_set_hash_input_set, 18755 (cmdline_parse_inst_t *)&cmd_set_fdir_input_set, 18756 (cmdline_parse_inst_t *)&cmd_flow, 18757 (cmdline_parse_inst_t *)&cmd_show_port_meter_cap, 18758 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_srtcm, 18759 (cmdline_parse_inst_t *)&cmd_add_port_meter_profile_trtcm, 18760 (cmdline_parse_inst_t *)&cmd_del_port_meter_profile, 18761 (cmdline_parse_inst_t *)&cmd_create_port_meter, 18762 (cmdline_parse_inst_t *)&cmd_enable_port_meter, 18763 (cmdline_parse_inst_t *)&cmd_disable_port_meter, 18764 (cmdline_parse_inst_t *)&cmd_del_port_meter, 18765 (cmdline_parse_inst_t *)&cmd_set_port_meter_profile, 18766 (cmdline_parse_inst_t *)&cmd_set_port_meter_dscp_table, 18767 (cmdline_parse_inst_t *)&cmd_set_port_meter_policer_action, 18768 (cmdline_parse_inst_t *)&cmd_set_port_meter_stats_mask, 18769 (cmdline_parse_inst_t *)&cmd_show_port_meter_stats, 18770 (cmdline_parse_inst_t *)&cmd_mcast_addr, 18771 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all, 18772 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific, 18773 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all, 18774 (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific, 18775 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_en, 18776 (cmdline_parse_inst_t *)&cmd_config_e_tag_insertion_dis, 18777 (cmdline_parse_inst_t *)&cmd_config_e_tag_stripping_en_dis, 18778 (cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis, 18779 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add, 18780 (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del, 18781 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, 18782 (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, 18783 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, 18784 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, 18785 (cmdline_parse_inst_t *)&cmd_set_tx_loopback, 18786 (cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en, 18787 (cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en, 18788 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_on, 18789 (cmdline_parse_inst_t *)&cmd_set_macsec_offload_off, 18790 (cmdline_parse_inst_t *)&cmd_set_macsec_sc, 18791 (cmdline_parse_inst_t *)&cmd_set_macsec_sa, 18792 (cmdline_parse_inst_t *)&cmd_set_vf_traffic, 18793 (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, 18794 (cmdline_parse_inst_t *)&cmd_vf_rate_limit, 18795 (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, 18796 (cmdline_parse_inst_t *)&cmd_set_vf_mac_addr, 18797 (cmdline_parse_inst_t *)&cmd_set_vf_promisc, 18798 (cmdline_parse_inst_t *)&cmd_set_vf_allmulti, 18799 (cmdline_parse_inst_t *)&cmd_set_vf_broadcast, 18800 (cmdline_parse_inst_t *)&cmd_set_vf_vlan_tag, 18801 (cmdline_parse_inst_t *)&cmd_vf_max_bw, 18802 (cmdline_parse_inst_t *)&cmd_vf_tc_min_bw, 18803 (cmdline_parse_inst_t *)&cmd_vf_tc_max_bw, 18804 (cmdline_parse_inst_t *)&cmd_strict_link_prio, 18805 (cmdline_parse_inst_t *)&cmd_tc_min_bw, 18806 #if defined RTE_LIBRTE_PMD_SOFTNIC && defined RTE_LIBRTE_SCHED 18807 (cmdline_parse_inst_t *)&cmd_set_port_tm_hierarchy_default, 18808 #endif 18809 (cmdline_parse_inst_t *)&cmd_set_vxlan, 18810 (cmdline_parse_inst_t *)&cmd_set_vxlan_tos_ttl, 18811 (cmdline_parse_inst_t *)&cmd_set_vxlan_with_vlan, 18812 (cmdline_parse_inst_t *)&cmd_set_nvgre, 18813 (cmdline_parse_inst_t *)&cmd_set_nvgre_with_vlan, 18814 (cmdline_parse_inst_t *)&cmd_set_l2_encap, 18815 (cmdline_parse_inst_t *)&cmd_set_l2_encap_with_vlan, 18816 (cmdline_parse_inst_t *)&cmd_set_l2_decap, 18817 (cmdline_parse_inst_t *)&cmd_set_l2_decap_with_vlan, 18818 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap, 18819 (cmdline_parse_inst_t *)&cmd_set_mplsogre_encap_with_vlan, 18820 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap, 18821 (cmdline_parse_inst_t *)&cmd_set_mplsogre_decap_with_vlan, 18822 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap, 18823 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, 18824 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, 18825 (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, 18826 (cmdline_parse_inst_t *)&cmd_ddp_add, 18827 (cmdline_parse_inst_t *)&cmd_ddp_del, 18828 (cmdline_parse_inst_t *)&cmd_ddp_get_list, 18829 (cmdline_parse_inst_t *)&cmd_ddp_get_info, 18830 (cmdline_parse_inst_t *)&cmd_cfg_input_set, 18831 (cmdline_parse_inst_t *)&cmd_clear_input_set, 18832 (cmdline_parse_inst_t *)&cmd_show_vf_stats, 18833 (cmdline_parse_inst_t *)&cmd_clear_vf_stats, 18834 (cmdline_parse_inst_t *)&cmd_ptype_mapping_get, 18835 (cmdline_parse_inst_t *)&cmd_ptype_mapping_replace, 18836 (cmdline_parse_inst_t *)&cmd_ptype_mapping_reset, 18837 (cmdline_parse_inst_t *)&cmd_ptype_mapping_update, 18838 18839 (cmdline_parse_inst_t *)&cmd_pctype_mapping_get, 18840 (cmdline_parse_inst_t *)&cmd_pctype_mapping_reset, 18841 (cmdline_parse_inst_t *)&cmd_pctype_mapping_update, 18842 (cmdline_parse_inst_t *)&cmd_queue_region, 18843 (cmdline_parse_inst_t *)&cmd_region_flowtype, 18844 (cmdline_parse_inst_t *)&cmd_user_priority_region, 18845 (cmdline_parse_inst_t *)&cmd_flush_queue_region, 18846 (cmdline_parse_inst_t *)&cmd_show_queue_region_info_all, 18847 (cmdline_parse_inst_t *)&cmd_show_port_tm_cap, 18848 (cmdline_parse_inst_t *)&cmd_show_port_tm_level_cap, 18849 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_cap, 18850 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_type, 18851 (cmdline_parse_inst_t *)&cmd_show_port_tm_node_stats, 18852 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shaper_profile, 18853 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shaper_profile, 18854 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_shared_shaper, 18855 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_shared_shaper, 18856 (cmdline_parse_inst_t *)&cmd_add_port_tm_node_wred_profile, 18857 (cmdline_parse_inst_t *)&cmd_del_port_tm_node_wred_profile, 18858 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_shaper_profile, 18859 (cmdline_parse_inst_t *)&cmd_add_port_tm_nonleaf_node, 18860 (cmdline_parse_inst_t *)&cmd_add_port_tm_leaf_node, 18861 (cmdline_parse_inst_t *)&cmd_del_port_tm_node, 18862 (cmdline_parse_inst_t *)&cmd_set_port_tm_node_parent, 18863 (cmdline_parse_inst_t *)&cmd_suspend_port_tm_node, 18864 (cmdline_parse_inst_t *)&cmd_resume_port_tm_node, 18865 (cmdline_parse_inst_t *)&cmd_port_tm_hierarchy_commit, 18866 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_ecn, 18867 (cmdline_parse_inst_t *)&cmd_port_tm_mark_ip_dscp, 18868 (cmdline_parse_inst_t *)&cmd_port_tm_mark_vlan_dei, 18869 (cmdline_parse_inst_t *)&cmd_cfg_tunnel_udp_port, 18870 (cmdline_parse_inst_t *)&cmd_rx_offload_get_capa, 18871 (cmdline_parse_inst_t *)&cmd_rx_offload_get_configuration, 18872 (cmdline_parse_inst_t *)&cmd_config_per_port_rx_offload, 18873 (cmdline_parse_inst_t *)&cmd_config_per_queue_rx_offload, 18874 (cmdline_parse_inst_t *)&cmd_tx_offload_get_capa, 18875 (cmdline_parse_inst_t *)&cmd_tx_offload_get_configuration, 18876 (cmdline_parse_inst_t *)&cmd_config_per_port_tx_offload, 18877 (cmdline_parse_inst_t *)&cmd_config_per_queue_tx_offload, 18878 #ifdef RTE_LIBRTE_BPF 18879 (cmdline_parse_inst_t *)&cmd_operate_bpf_ld_parse, 18880 (cmdline_parse_inst_t *)&cmd_operate_bpf_unld_parse, 18881 #endif 18882 (cmdline_parse_inst_t *)&cmd_config_tx_metadata_specific, 18883 (cmdline_parse_inst_t *)&cmd_show_tx_metadata, 18884 NULL, 18885 }; 18886 18887 /* read cmdline commands from file */ 18888 void 18889 cmdline_read_from_file(const char *filename) 18890 { 18891 struct cmdline *cl; 18892 18893 cl = cmdline_file_new(main_ctx, "testpmd> ", filename); 18894 if (cl == NULL) { 18895 printf("Failed to create file based cmdline context: %s\n", 18896 filename); 18897 return; 18898 } 18899 18900 cmdline_interact(cl); 18901 cmdline_quit(cl); 18902 18903 cmdline_free(cl); 18904 18905 printf("Read CLI commands from %s\n", filename); 18906 } 18907 18908 /* prompt function, called from main on MASTER lcore */ 18909 void 18910 prompt(void) 18911 { 18912 /* initialize non-constant commands */ 18913 cmd_set_fwd_mode_init(); 18914 cmd_set_fwd_retry_mode_init(); 18915 18916 testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); 18917 if (testpmd_cl == NULL) 18918 return; 18919 cmdline_interact(testpmd_cl); 18920 cmdline_stdin_exit(testpmd_cl); 18921 } 18922 18923 void 18924 prompt_exit(void) 18925 { 18926 if (testpmd_cl != NULL) 18927 cmdline_quit(testpmd_cl); 18928 } 18929 18930 static void 18931 cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue) 18932 { 18933 if (id == (portid_t)RTE_PORT_ALL) { 18934 portid_t pid; 18935 18936 RTE_ETH_FOREACH_DEV(pid) { 18937 /* check if need_reconfig has been set to 1 */ 18938 if (ports[pid].need_reconfig == 0) 18939 ports[pid].need_reconfig = dev; 18940 /* check if need_reconfig_queues has been set to 1 */ 18941 if (ports[pid].need_reconfig_queues == 0) 18942 ports[pid].need_reconfig_queues = queue; 18943 } 18944 } else if (!port_id_is_invalid(id, DISABLED_WARN)) { 18945 /* check if need_reconfig has been set to 1 */ 18946 if (ports[id].need_reconfig == 0) 18947 ports[id].need_reconfig = dev; 18948 /* check if need_reconfig_queues has been set to 1 */ 18949 if (ports[id].need_reconfig_queues == 0) 18950 ports[id].need_reconfig_queues = queue; 18951 } 18952 } 18953