app/testpmd: use ethdev iterator to list devices
[dpdk.git] / app / test-pmd / cmdline_flow.c
index 7760c2d..4e99f0f 100644 (file)
@@ -39,6 +39,7 @@
 #include <ctype.h>
 #include <string.h>
 #include <arpa/inet.h>
+#include <sys/socket.h>
 
 #include <rte_common.h>
 #include <rte_ethdev.h>
@@ -158,6 +159,10 @@ enum index {
        ITEM_SCTP_CKSUM,
        ITEM_VXLAN,
        ITEM_VXLAN_VNI,
+       ITEM_MPLS,
+       ITEM_MPLS_LABEL,
+       ITEM_GRE,
+       ITEM_GRE_PROTO,
 
        /* Validate/create actions. */
        ACTIONS,
@@ -431,6 +436,8 @@ static const enum index next_item[] = {
        ITEM_TCP,
        ITEM_SCTP,
        ITEM_VXLAN,
+       ITEM_MPLS,
+       ITEM_GRE,
        ZERO,
 };
 
@@ -537,6 +544,18 @@ static const enum index item_vxlan[] = {
        ZERO,
 };
 
+static const enum index item_mpls[] = {
+       ITEM_MPLS_LABEL,
+       ITEM_NEXT,
+       ZERO,
+};
+
+static const enum index item_gre[] = {
+       ITEM_GRE_PROTO,
+       ITEM_NEXT,
+       ZERO,
+};
+
 static const enum index next_action[] = {
        ACTION_END,
        ACTION_VOID,
@@ -1278,6 +1297,35 @@ static const struct token token_list[] = {
                .next = NEXT(item_vxlan, NEXT_ENTRY(UNSIGNED), item_param),
                .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
        },
+       [ITEM_MPLS] = {
+               .name = "mpls",
+               .help = "match MPLS header",
+               .priv = PRIV_ITEM(MPLS, sizeof(struct rte_flow_item_mpls)),
+               .next = NEXT(item_mpls),
+               .call = parse_vc,
+       },
+       [ITEM_MPLS_LABEL] = {
+               .name = "label",
+               .help = "MPLS label",
+               .next = NEXT(item_mpls, NEXT_ENTRY(UNSIGNED), item_param),
+               .args = ARGS(ARGS_ENTRY_MASK_HTON(struct rte_flow_item_mpls,
+                                                 label_tc_s,
+                                                 "\xff\xff\xf0")),
+       },
+       [ITEM_GRE] = {
+               .name = "gre",
+               .help = "match GRE header",
+               .priv = PRIV_ITEM(GRE, sizeof(struct rte_flow_item_gre)),
+               .next = NEXT(item_gre),
+               .call = parse_vc,
+       },
+       [ITEM_GRE_PROTO] = {
+               .name = "protocol",
+               .help = "GRE protocol type",
+               .next = NEXT(item_gre, NEXT_ENTRY(UNSIGNED), item_param),
+               .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gre,
+                                            protocol)),
+       },
        /* Validate/create actions. */
        [ACTIONS] = {
                .name = "actions",
@@ -2368,7 +2416,7 @@ comp_port(struct context *ctx, const struct token *token,
 
        (void)ctx;
        (void)token;
-       FOREACH_PORT(p, ports) {
+       RTE_ETH_FOREACH_DEV(p) {
                if (buf && i == ent)
                        return snprintf(buf, size, "%u", p);
                ++i;