app/testpmd: add command for single flow dump
[dpdk.git] / app / test-pmd / config.c
index a6a5baa..d4b0e85 100644 (file)
@@ -87,7 +87,7 @@ const struct rss_type_info rss_type_table[] = {
        { "all", ETH_RSS_ETH | ETH_RSS_VLAN | ETH_RSS_IP | ETH_RSS_TCP |
                ETH_RSS_UDP | ETH_RSS_SCTP | ETH_RSS_L2_PAYLOAD |
                ETH_RSS_L2TPV3 | ETH_RSS_ESP | ETH_RSS_AH | ETH_RSS_PFCP |
-               ETH_RSS_GTPU | ETH_RSS_ECPRI},
+               ETH_RSS_GTPU | ETH_RSS_ECPRI | ETH_RSS_MPLS},
        { "none", 0 },
        { "eth", ETH_RSS_ETH },
        { "l2-src-only", ETH_RSS_L2_SRC_ONLY },
@@ -137,6 +137,7 @@ const struct rss_type_info rss_type_table[] = {
        { "pppoe", ETH_RSS_PPPOE },
        { "gtpu", ETH_RSS_GTPU },
        { "ecpri", ETH_RSS_ECPRI },
+       { "mpls", ETH_RSS_MPLS },
        { NULL, 0 },
 };
 
@@ -509,8 +510,6 @@ device_infos_display(const char *identifier)
 
        if (rte_devargs_parsef(&da, "%s", identifier)) {
                printf("cannot parse identifier\n");
-               if (da.args)
-                       free(da.args);
                return;
        }
 
@@ -558,6 +557,7 @@ skip_parse:
                        }
                }
        };
+       rte_devargs_reset(&da);
 }
 
 void
@@ -884,295 +884,6 @@ port_module_eeprom_display(portid_t port_id)
        printf("Finish -- Port: %d MODULE EEPROM length: %d bytes\n", port_id, einfo.length);
 }
 
-void
-port_offload_cap_display(portid_t port_id)
-{
-       struct rte_eth_dev_info dev_info;
-       static const char *info_border = "************";
-       int ret;
-
-       if (port_id_is_invalid(port_id, ENABLED_WARN))
-               return;
-
-       ret = eth_dev_info_get_print_err(port_id, &dev_info);
-       if (ret != 0)
-               return;
-
-       printf("\n%s Port %d supported offload features: %s\n",
-               info_border, port_id, info_border);
-
-       if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_VLAN_STRIP) {
-               printf("VLAN stripped:                 ");
-               if (ports[port_id].dev_conf.rxmode.offloads &
-                   DEV_RX_OFFLOAD_VLAN_STRIP)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_QINQ_STRIP) {
-               printf("Double VLANs stripped:         ");
-               if (ports[port_id].dev_conf.rxmode.offloads &
-                   DEV_RX_OFFLOAD_QINQ_STRIP)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_IPV4_CKSUM) {
-               printf("RX IPv4 checksum:              ");
-               if (ports[port_id].dev_conf.rxmode.offloads &
-                   DEV_RX_OFFLOAD_IPV4_CKSUM)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_UDP_CKSUM) {
-               printf("RX UDP checksum:               ");
-               if (ports[port_id].dev_conf.rxmode.offloads &
-                   DEV_RX_OFFLOAD_UDP_CKSUM)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_TCP_CKSUM) {
-               printf("RX TCP checksum:               ");
-               if (ports[port_id].dev_conf.rxmode.offloads &
-                   DEV_RX_OFFLOAD_TCP_CKSUM)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_SCTP_CKSUM) {
-               printf("RX SCTP checksum:              ");
-               if (ports[port_id].dev_conf.rxmode.offloads &
-                   DEV_RX_OFFLOAD_SCTP_CKSUM)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM) {
-               printf("RX Outer IPv4 checksum:        ");
-               if (ports[port_id].dev_conf.rxmode.offloads &
-                   DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_OUTER_UDP_CKSUM) {
-               printf("RX Outer UDP checksum:         ");
-               if (ports[port_id].dev_conf.rxmode.offloads &
-                   DEV_RX_OFFLOAD_OUTER_UDP_CKSUM)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_TCP_LRO) {
-               printf("Large receive offload:         ");
-               if (ports[port_id].dev_conf.rxmode.offloads &
-                   DEV_RX_OFFLOAD_TCP_LRO)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_TIMESTAMP) {
-               printf("HW timestamp:                  ");
-               if (ports[port_id].dev_conf.rxmode.offloads &
-                   DEV_RX_OFFLOAD_TIMESTAMP)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_KEEP_CRC) {
-               printf("Rx Keep CRC:                   ");
-               if (ports[port_id].dev_conf.rxmode.offloads &
-                   DEV_RX_OFFLOAD_KEEP_CRC)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_SECURITY) {
-               printf("RX offload security:           ");
-               if (ports[port_id].dev_conf.rxmode.offloads &
-                   DEV_RX_OFFLOAD_SECURITY)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.rx_offload_capa & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) {
-               printf("RX offload buffer split:       ");
-               if (ports[port_id].dev_conf.rxmode.offloads &
-                   RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VLAN_INSERT) {
-               printf("VLAN insert:                   ");
-               if (ports[port_id].dev_conf.txmode.offloads &
-                   DEV_TX_OFFLOAD_VLAN_INSERT)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_QINQ_INSERT) {
-               printf("Double VLANs insert:           ");
-               if (ports[port_id].dev_conf.txmode.offloads &
-                   DEV_TX_OFFLOAD_QINQ_INSERT)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) {
-               printf("TX IPv4 checksum:              ");
-               if (ports[port_id].dev_conf.txmode.offloads &
-                   DEV_TX_OFFLOAD_IPV4_CKSUM)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) {
-               printf("TX UDP checksum:               ");
-               if (ports[port_id].dev_conf.txmode.offloads &
-                   DEV_TX_OFFLOAD_UDP_CKSUM)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) {
-               printf("TX TCP checksum:               ");
-               if (ports[port_id].dev_conf.txmode.offloads &
-                   DEV_TX_OFFLOAD_TCP_CKSUM)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SCTP_CKSUM) {
-               printf("TX SCTP checksum:              ");
-               if (ports[port_id].dev_conf.txmode.offloads &
-                   DEV_TX_OFFLOAD_SCTP_CKSUM)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) {
-               printf("TX Outer IPv4 checksum:        ");
-               if (ports[port_id].dev_conf.txmode.offloads &
-                   DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) {
-               printf("TX TCP segmentation:           ");
-               if (ports[port_id].dev_conf.txmode.offloads &
-                   DEV_TX_OFFLOAD_TCP_TSO)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TSO) {
-               printf("TX UDP segmentation:           ");
-               if (ports[port_id].dev_conf.txmode.offloads &
-                   DEV_TX_OFFLOAD_UDP_TSO)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VXLAN_TNL_TSO) {
-               printf("TSO for VXLAN tunnel packet:   ");
-               if (ports[port_id].dev_conf.txmode.offloads &
-                   DEV_TX_OFFLOAD_VXLAN_TNL_TSO)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GRE_TNL_TSO) {
-               printf("TSO for GRE tunnel packet:     ");
-               if (ports[port_id].dev_conf.txmode.offloads &
-                   DEV_TX_OFFLOAD_GRE_TNL_TSO)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IPIP_TNL_TSO) {
-               printf("TSO for IPIP tunnel packet:    ");
-               if (ports[port_id].dev_conf.txmode.offloads &
-                   DEV_TX_OFFLOAD_IPIP_TNL_TSO)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_GENEVE_TNL_TSO) {
-               printf("TSO for GENEVE tunnel packet:  ");
-               if (ports[port_id].dev_conf.txmode.offloads &
-                   DEV_TX_OFFLOAD_GENEVE_TNL_TSO)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_IP_TNL_TSO) {
-               printf("IP tunnel TSO:  ");
-               if (ports[port_id].dev_conf.txmode.offloads &
-                   DEV_TX_OFFLOAD_IP_TNL_TSO)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_UDP_TNL_TSO) {
-               printf("UDP tunnel TSO:  ");
-               if (ports[port_id].dev_conf.txmode.offloads &
-                   DEV_TX_OFFLOAD_UDP_TNL_TSO)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_OUTER_UDP_CKSUM) {
-               printf("TX Outer UDP checksum:         ");
-               if (ports[port_id].dev_conf.txmode.offloads &
-                   DEV_TX_OFFLOAD_OUTER_UDP_CKSUM)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-       if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP) {
-               printf("Tx scheduling on timestamp:    ");
-               if (ports[port_id].dev_conf.txmode.offloads &
-                   DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP)
-                       printf("on\n");
-               else
-                       printf("off\n");
-       }
-
-}
-
 int
 port_id_is_invalid(portid_t port_id, enum print_warning warning)
 {
@@ -1434,7 +1145,7 @@ port_mtu_set(portid_t port_id, uint16_t mtu)
                 * device supports jumbo frame.
                 */
                eth_overhead = dev_info.max_rx_pktlen - dev_info.max_mtu;
-               if (mtu > RTE_ETHER_MAX_LEN - eth_overhead) {
+               if (mtu > RTE_ETHER_MTU) {
                        rte_port->dev_conf.rxmode.offloads |=
                                                DEV_RX_OFFLOAD_JUMBO_FRAME;
                        rte_port->dev_conf.rxmode.max_rx_pkt_len =
@@ -1879,6 +1590,7 @@ port_shared_action_query(portid_t port_id, uint32_t id)
                return -EINVAL;
        switch (psa->type) {
        case RTE_FLOW_ACTION_TYPE_RSS:
+       case RTE_FLOW_ACTION_TYPE_AGE:
                data = &default_data;
                break;
        default:
@@ -1895,6 +1607,20 @@ port_shared_action_query(portid_t port_id, uint32_t id)
                               *((uint32_t *)data));
                data = NULL;
                break;
+       case RTE_FLOW_ACTION_TYPE_AGE:
+               if (!ret) {
+                       struct rte_flow_query_age *resp = data;
+
+                       printf("AGE:\n"
+                              " aged: %u\n"
+                              " sec_since_last_hit_valid: %u\n"
+                              " sec_since_last_hit: %" PRIu32 "\n",
+                              resp->aged,
+                              resp->sec_since_last_hit_valid,
+                              resp->sec_since_last_hit);
+               }
+               data = NULL;
+               break;
        default:
                printf("Shared action %u (type: %d) on port %u doesn't support"
                       " query\n", id, psa->type, port_id);
@@ -1902,6 +1628,7 @@ port_shared_action_query(portid_t port_id, uint32_t id)
        }
        return ret;
 }
+
 static struct port_flow_tunnel *
 port_flow_tunnel_offload_cmd_prep(portid_t port_id,
                                  const struct rte_flow_item *pattern,
@@ -2188,13 +1915,41 @@ port_flow_flush(portid_t port_id)
        return ret;
 }
 
-/** Dump all flow rules. */
+/** Dump flow rules. */
 int
-port_flow_dump(portid_t port_id, const char *file_name)
+port_flow_dump(portid_t port_id, bool dump_all, uint32_t rule_id,
+               const char *file_name)
 {
        int ret = 0;
        FILE *file = stdout;
        struct rte_flow_error error;
+       struct rte_port *port;
+       struct port_flow *pflow;
+       struct rte_flow *tmpFlow = NULL;
+       bool found = false;
+
+       if (port_id_is_invalid(port_id, ENABLED_WARN) ||
+               port_id == (portid_t)RTE_PORT_ALL)
+               return -EINVAL;
+
+       if (!dump_all) {
+               port = &ports[port_id];
+               pflow = port->flow_list;
+               while (pflow) {
+                       if (rule_id != pflow->id) {
+                               pflow = pflow->next;
+                       } else {
+                               tmpFlow = pflow->flow;
+                               if (tmpFlow)
+                                       found = true;
+                               break;
+                       }
+               }
+               if (found == false) {
+                       printf("Failed to dump to flow %d\n", rule_id);
+                       return -EINVAL;
+               }
+       }
 
        if (file_name && strlen(file_name)) {
                file = fopen(file_name, "w");
@@ -2204,7 +1959,11 @@ port_flow_dump(portid_t port_id, const char *file_name)
                        return -errno;
                }
        }
-       ret = rte_flow_dev_dump(port_id, file, &error);
+
+       if (!dump_all)
+               ret = rte_flow_dev_dump(port_id, tmpFlow, file, &error);
+       else
+               ret = rte_flow_dev_dump(port_id, NULL, file, &error);
        if (ret) {
                port_flow_complain(&error);
                printf("Failed to dump flow: %s\n", strerror(-ret));
@@ -2947,7 +2706,7 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key)
 
 void
 port_rss_hash_key_update(portid_t port_id, char rss_type[], uint8_t *hash_key,
-                        uint hash_key_len)
+                        uint8_t hash_key_len)
 {
        struct rte_eth_rss_conf rss_conf;
        int diag;
@@ -5203,7 +4962,8 @@ show_macs(portid_t port_id)
 
        dev = &rte_eth_devices[port_id];
 
-       rte_eth_dev_info_get(port_id, &dev_info);
+       if (eth_dev_info_get_print_err(port_id, &dev_info))
+               return;
 
        for (i = 0; i < dev_info.max_mac_addrs; i++) {
                addr = &dev->data->mac_addrs[i];