COMMON_PRIORITY_LEVEL,
COMMON_INDIRECT_ACTION_ID,
COMMON_POLICY_ID,
+ COMMON_FLEX_HANDLE,
+ COMMON_FLEX_TOKEN,
/* TOP-level command. */
ADD,
AGED,
ISOLATE,
TUNNEL,
+ FLEX,
+
+ /* Flex arguments */
+ FLEX_ITEM_INIT,
+ FLEX_ITEM_CREATE,
+ FLEX_ITEM_DESTROY,
/* Tunnel arguments. */
TUNNEL_CREATE,
ITEM_VLAN_INNER_TYPE,
ITEM_VLAN_HAS_MORE_VLAN,
ITEM_IPV4,
+ ITEM_IPV4_VER_IHL,
ITEM_IPV4_TOS,
ITEM_IPV4_ID,
ITEM_IPV4_FRAGMENT_OFFSET,
ITEM_SCTP_CKSUM,
ITEM_VXLAN,
ITEM_VXLAN_VNI,
+ ITEM_VXLAN_LAST_RSVD,
ITEM_E_TAG,
ITEM_E_TAG_GRP_ECID_B,
ITEM_NVGRE,
ITEM_POL_PORT,
ITEM_POL_METER,
ITEM_POL_POLICY,
+ ITEM_PORT_REPRESENTOR,
+ ITEM_PORT_REPRESENTOR_PORT_ID,
+ ITEM_REPRESENTED_PORT,
+ ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID,
+ ITEM_FLEX,
+ ITEM_FLEX_ITEM_HANDLE,
+ ITEM_FLEX_PATTERN_HANDLE,
+ ITEM_L2TPV2,
+ ITEM_L2TPV2_COMMON,
+ ITEM_L2TPV2_COMMON_TYPE,
+ ITEM_L2TPV2_COMMON_TYPE_DATA_L,
+ ITEM_L2TPV2_COMMON_TYPE_CTRL,
+ ITEM_L2TPV2_MSG_DATA_L_LENGTH,
+ ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
+ ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
+ ITEM_L2TPV2_MSG_CTRL_LENGTH,
+ ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
+ ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
+ ITEM_L2TPV2_MSG_CTRL_NS,
+ ITEM_L2TPV2_MSG_CTRL_NR,
+ ITEM_PPP,
+ ITEM_PPP_ADDR,
+ ITEM_PPP_CTRL,
+ ITEM_PPP_PROTO_ID,
/* Validate/create actions. */
ACTIONS,
ACTION_QUEUE_INDEX,
ACTION_DROP,
ACTION_COUNT,
- ACTION_COUNT_SHARED,
ACTION_COUNT_ID,
ACTION_RSS,
ACTION_RSS_FUNC,
ACTION_MODIFY_FIELD_SRC_LEVEL,
ACTION_MODIFY_FIELD_SRC_OFFSET,
ACTION_MODIFY_FIELD_SRC_VALUE,
+ ACTION_MODIFY_FIELD_SRC_POINTER,
ACTION_MODIFY_FIELD_WIDTH,
ACTION_CONNTRACK,
ACTION_CONNTRACK_UPDATE,
ACTION_POL_G,
ACTION_POL_Y,
ACTION_POL_R,
+ ACTION_PORT_REPRESENTOR,
+ ACTION_PORT_REPRESENTOR_PORT_ID,
+ ACTION_REPRESENTED_PORT,
+ ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
};
/** Maximum size for pattern in struct rte_flow_item_raw. */
#define ITEM_RAW_SIZE \
(sizeof(struct rte_flow_item_raw) + ITEM_RAW_PATTERN_SIZE)
+/** Maximum size for external pattern in struct rte_flow_action_modify_data. */
+#define ACTION_MODIFY_PATTERN_SIZE 32
+
+/** Storage size for struct rte_flow_action_modify_field including pattern. */
+#define ACTION_MODIFY_SIZE \
+ (sizeof(struct rte_flow_action_modify_field) + \
+ ACTION_MODIFY_PATTERN_SIZE)
+
/** Maximum number of queue indices in struct rte_flow_action_rss. */
#define ACTION_RSS_QUEUE_NUM 128
struct {
uint32_t policy_id;
} policy;/**< Policy arguments. */
+ struct {
+ uint16_t token;
+ uintptr_t uintptr;
+ char filename[128];
+ } flex; /**< Flex arguments*/
} args; /**< Command arguments. */
};
.size = s, \
})
+static const enum index next_flex_item[] = {
+ FLEX_ITEM_INIT,
+ FLEX_ITEM_CREATE,
+ FLEX_ITEM_DESTROY,
+ ZERO,
+};
+
static const enum index next_ia_create_attr[] = {
INDIRECT_ACTION_CREATE_ID,
INDIRECT_ACTION_INGRESS,
ITEM_GENEVE_OPT,
ITEM_INTEGRITY,
ITEM_CONNTRACK,
+ ITEM_PORT_REPRESENTOR,
+ ITEM_REPRESENTED_PORT,
+ ITEM_FLEX,
+ ITEM_L2TPV2,
+ ITEM_PPP,
END_SET,
ZERO,
};
};
static const enum index item_ipv4[] = {
+ ITEM_IPV4_VER_IHL,
ITEM_IPV4_TOS,
ITEM_IPV4_ID,
ITEM_IPV4_FRAGMENT_OFFSET,
static const enum index item_vxlan[] = {
ITEM_VXLAN_VNI,
+ ITEM_VXLAN_LAST_RSVD,
ITEM_NEXT,
ZERO,
};
ZERO,
};
+static const enum index item_port_representor[] = {
+ ITEM_PORT_REPRESENTOR_PORT_ID,
+ ITEM_NEXT,
+ ZERO,
+};
+
+static const enum index item_represented_port[] = {
+ ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID,
+ ITEM_NEXT,
+ ZERO,
+};
+
+static const enum index item_flex[] = {
+ ITEM_FLEX_PATTERN_HANDLE,
+ ITEM_FLEX_ITEM_HANDLE,
+ ITEM_NEXT,
+ ZERO,
+};
+
+static const enum index item_l2tpv2[] = {
+ ITEM_L2TPV2_COMMON,
+ ITEM_NEXT,
+ ZERO,
+};
+
+static const enum index item_l2tpv2_common[] = {
+ ITEM_L2TPV2_COMMON_TYPE,
+ ZERO,
+};
+
+static const enum index item_l2tpv2_common_type[] = {
+ ITEM_L2TPV2_COMMON_TYPE_DATA_L,
+ ITEM_L2TPV2_COMMON_TYPE_CTRL,
+ ZERO,
+};
+
+static const enum index item_ppp[] = {
+ ITEM_PPP_ADDR,
+ ITEM_PPP_CTRL,
+ ITEM_PPP_PROTO_ID,
+ ITEM_NEXT,
+ ZERO,
+};
+
static const enum index next_action[] = {
ACTION_END,
ACTION_VOID,
ACTION_MODIFY_FIELD,
ACTION_CONNTRACK,
ACTION_CONNTRACK_UPDATE,
+ ACTION_PORT_REPRESENTOR,
+ ACTION_REPRESENTED_PORT,
ZERO,
};
static const enum index action_count[] = {
ACTION_COUNT_ID,
- ACTION_COUNT_SHARED,
ACTION_NEXT,
ZERO,
};
ACTION_MODIFY_FIELD_SRC_LEVEL,
ACTION_MODIFY_FIELD_SRC_OFFSET,
ACTION_MODIFY_FIELD_SRC_VALUE,
+ ACTION_MODIFY_FIELD_SRC_POINTER,
ACTION_MODIFY_FIELD_WIDTH,
ZERO,
};
ZERO,
};
+static const enum index action_port_representor[] = {
+ ACTION_PORT_REPRESENTOR_PORT_ID,
+ ACTION_NEXT,
+ ZERO,
+};
+
+static const enum index action_represented_port[] = {
+ ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID,
+ ACTION_NEXT,
+ ZERO,
+};
+
static int parse_set_raw_encap_decap(struct context *, const struct token *,
const char *, unsigned int,
void *, unsigned int);
static int parse_set_init(struct context *, const struct token *,
const char *, unsigned int,
void *, unsigned int);
+static int
+parse_flex_handle(struct context *, const struct token *,
+ const char *, unsigned int, void *, unsigned int);
static int parse_init(struct context *, const struct token *,
const char *, unsigned int,
void *, unsigned int);
static int parse_vc_item_ecpri_type(struct context *, const struct token *,
const char *, unsigned int,
void *, unsigned int);
+static int parse_vc_item_l2tpv2_type(struct context *, const struct token *,
+ const char *, unsigned int,
+ void *, unsigned int);
static int parse_vc_action_meter_color_type(struct context *,
const struct token *,
const char *, unsigned int, void *,
static int parse_tunnel(struct context *, const struct token *,
const char *, unsigned int,
void *, unsigned int);
+static int parse_flex(struct context *, const struct token *,
+ const char *, unsigned int, void *, unsigned int);
static int parse_int(struct context *, const struct token *,
const char *, unsigned int,
void *, unsigned int);
.call = parse_int,
.comp = comp_none,
},
+ [COMMON_FLEX_TOKEN] = {
+ .name = "{flex token}",
+ .type = "flex token",
+ .help = "flex token",
+ .call = parse_int,
+ .comp = comp_none,
+ },
+ [COMMON_FLEX_HANDLE] = {
+ .name = "{flex handle}",
+ .type = "FLEX HANDLE",
+ .help = "fill flex item data",
+ .call = parse_flex_handle,
+ .comp = comp_none,
+ },
/* Top-level command. */
[FLOW] = {
.name = "flow",
AGED,
QUERY,
ISOLATE,
- TUNNEL)),
+ TUNNEL,
+ FLEX)),
.call = parse_init,
},
/* Top-level command. */
ARGS_ENTRY(struct buffer, port)),
.call = parse_isolate,
},
+ [FLEX] = {
+ .name = "flex_item",
+ .help = "flex item API",
+ .next = NEXT(next_flex_item),
+ .call = parse_flex,
+ },
+ [FLEX_ITEM_INIT] = {
+ .name = "init",
+ .help = "flex item init",
+ .args = ARGS(ARGS_ENTRY(struct buffer, args.flex.token),
+ ARGS_ENTRY(struct buffer, port)),
+ .next = NEXT(NEXT_ENTRY(COMMON_FLEX_TOKEN),
+ NEXT_ENTRY(COMMON_PORT_ID)),
+ .call = parse_flex
+ },
+ [FLEX_ITEM_CREATE] = {
+ .name = "create",
+ .help = "flex item create",
+ .args = ARGS(ARGS_ENTRY(struct buffer, args.flex.filename),
+ ARGS_ENTRY(struct buffer, args.flex.token),
+ ARGS_ENTRY(struct buffer, port)),
+ .next = NEXT(NEXT_ENTRY(COMMON_FILE_PATH),
+ NEXT_ENTRY(COMMON_FLEX_TOKEN),
+ NEXT_ENTRY(COMMON_PORT_ID)),
+ .call = parse_flex
+ },
+ [FLEX_ITEM_DESTROY] = {
+ .name = "destroy",
+ .help = "flex item destroy",
+ .args = ARGS(ARGS_ENTRY(struct buffer, args.flex.token),
+ ARGS_ENTRY(struct buffer, port)),
+ .next = NEXT(NEXT_ENTRY(COMMON_FLEX_TOKEN),
+ NEXT_ENTRY(COMMON_PORT_ID)),
+ .call = parse_flex
+ },
[TUNNEL] = {
.name = "tunnel",
.help = "new tunnel API",
.next = NEXT(item_ipv4),
.call = parse_vc,
},
+ [ITEM_IPV4_VER_IHL] = {
+ .name = "version_ihl",
+ .help = "match header length",
+ .next = NEXT(item_ipv4, NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ipv4,
+ hdr.version_ihl)),
+ },
[ITEM_IPV4_TOS] = {
.name = "tos",
.help = "type of service",
item_param),
.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan, vni)),
},
+ [ITEM_VXLAN_LAST_RSVD] = {
+ .name = "last_rsvd",
+ .help = "VXLAN last reserved bits",
+ .next = NEXT(item_vxlan, NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_vxlan,
+ rsvd1)),
+ },
[ITEM_E_TAG] = {
.name = "e_tag",
.help = "match E-Tag header",
.help = "QoS flow identifier",
.next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
item_param),
- .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
- qfi)),
+ .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_gtp_psc,
+ hdr.qfi, 6)),
},
[ITEM_GTP_PSC_PDU_T] = {
.name = "pdu_t",
.help = "PDU type",
.next = NEXT(item_gtp_psc, NEXT_ENTRY(COMMON_UNSIGNED),
item_param),
- .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_gtp_psc,
- pdu_type)),
+ .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_item_gtp_psc,
+ hdr.type, 4)),
},
[ITEM_PPPOES] = {
.name = "pppoes",
item_param),
.args = ARGS(ARGS_ENTRY(struct rte_flow_item_conntrack, flags)),
},
+ [ITEM_PORT_REPRESENTOR] = {
+ .name = "port_representor",
+ .help = "match traffic entering the embedded switch from the given ethdev",
+ .priv = PRIV_ITEM(PORT_REPRESENTOR,
+ sizeof(struct rte_flow_item_ethdev)),
+ .next = NEXT(item_port_representor),
+ .call = parse_vc,
+ },
+ [ITEM_PORT_REPRESENTOR_PORT_ID] = {
+ .name = "port_id",
+ .help = "ethdev port ID",
+ .next = NEXT(item_port_representor, NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
+ },
+ [ITEM_REPRESENTED_PORT] = {
+ .name = "represented_port",
+ .help = "match traffic entering the embedded switch from the entity represented by the given ethdev",
+ .priv = PRIV_ITEM(REPRESENTED_PORT,
+ sizeof(struct rte_flow_item_ethdev)),
+ .next = NEXT(item_represented_port),
+ .call = parse_vc,
+ },
+ [ITEM_REPRESENTED_PORT_ETHDEV_PORT_ID] = {
+ .name = "ethdev_port_id",
+ .help = "ethdev port ID",
+ .next = NEXT(item_represented_port, NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ethdev, port_id)),
+ },
+ [ITEM_FLEX] = {
+ .name = "flex",
+ .help = "match flex header",
+ .priv = PRIV_ITEM(FLEX, sizeof(struct rte_flow_item_flex)),
+ .next = NEXT(item_flex),
+ .call = parse_vc,
+ },
+ [ITEM_FLEX_ITEM_HANDLE] = {
+ .name = "item",
+ .help = "flex item handle",
+ .next = NEXT(item_flex, NEXT_ENTRY(COMMON_FLEX_HANDLE),
+ NEXT_ENTRY(ITEM_PARAM_IS)),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_item_flex, handle)),
+ },
+ [ITEM_FLEX_PATTERN_HANDLE] = {
+ .name = "pattern",
+ .help = "flex pattern handle",
+ .next = NEXT(item_flex, NEXT_ENTRY(COMMON_FLEX_HANDLE),
+ NEXT_ENTRY(ITEM_PARAM_IS)),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_item_flex, pattern)),
+ },
+ [ITEM_L2TPV2] = {
+ .name = "l2tpv2",
+ .help = "match L2TPv2 header",
+ .priv = PRIV_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)),
+ .next = NEXT(item_l2tpv2),
+ .call = parse_vc,
+ },
+ [ITEM_L2TPV2_COMMON] = {
+ .name = "common",
+ .help = "L2TPv2 common header",
+ .next = NEXT(item_l2tpv2_common),
+ },
+ [ITEM_L2TPV2_COMMON_TYPE] = {
+ .name = "type",
+ .help = "type of common header",
+ .next = NEXT(item_l2tpv2_common_type),
+ .args = ARGS(ARG_ENTRY_HTON(struct rte_flow_item_l2tpv2)),
+ },
+ [ITEM_L2TPV2_COMMON_TYPE_DATA_L] = {
+ .name = "data_l",
+ .help = "Type #6: data message with length option",
+ .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_DATA_L_LENGTH,
+ ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
+ ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
+ ITEM_NEXT)),
+ .call = parse_vc_item_l2tpv2_type,
+ },
+ [ITEM_L2TPV2_MSG_DATA_L_LENGTH] = {
+ .name = "length",
+ .help = "message length",
+ .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_DATA_L_LENGTH,
+ ITEM_L2TPV2_COMMON, ITEM_NEXT),
+ NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
+ hdr.type6.length)),
+ },
+ [ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID] = {
+ .name = "tunnel_id",
+ .help = "tunnel identifier",
+ .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_DATA_L_TUNNEL_ID,
+ ITEM_L2TPV2_COMMON, ITEM_NEXT),
+ NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
+ hdr.type6.tunnel_id)),
+ },
+ [ITEM_L2TPV2_MSG_DATA_L_SESSION_ID] = {
+ .name = "session_id",
+ .help = "session identifier",
+ .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_DATA_L_SESSION_ID,
+ ITEM_L2TPV2_COMMON, ITEM_NEXT),
+ NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
+ hdr.type6.session_id)),
+ },
+ [ITEM_L2TPV2_COMMON_TYPE_CTRL] = {
+ .name = "control",
+ .help = "Type #3: conrtol message contains length, ns, nr options",
+ .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_LENGTH,
+ ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
+ ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
+ ITEM_L2TPV2_MSG_CTRL_NS,
+ ITEM_L2TPV2_MSG_CTRL_NR,
+ ITEM_NEXT)),
+ .call = parse_vc_item_l2tpv2_type,
+ },
+ [ITEM_L2TPV2_MSG_CTRL_LENGTH] = {
+ .name = "length",
+ .help = "message length",
+ .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_LENGTH,
+ ITEM_L2TPV2_COMMON, ITEM_NEXT),
+ NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
+ hdr.type3.length)),
+ },
+ [ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID] = {
+ .name = "tunnel_id",
+ .help = "tunnel identifier",
+ .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_TUNNEL_ID,
+ ITEM_L2TPV2_COMMON, ITEM_NEXT),
+ NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
+ hdr.type3.tunnel_id)),
+ },
+ [ITEM_L2TPV2_MSG_CTRL_SESSION_ID] = {
+ .name = "session_id",
+ .help = "session identifier",
+ .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_SESSION_ID,
+ ITEM_L2TPV2_COMMON, ITEM_NEXT),
+ NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
+ hdr.type3.session_id)),
+ },
+ [ITEM_L2TPV2_MSG_CTRL_NS] = {
+ .name = "ns",
+ .help = "sequence number for message",
+ .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_NS,
+ ITEM_L2TPV2_COMMON, ITEM_NEXT),
+ NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
+ hdr.type3.ns)),
+ },
+ [ITEM_L2TPV2_MSG_CTRL_NR] = {
+ .name = "nr",
+ .help = "sequence number for next receive message",
+ .next = NEXT(NEXT_ENTRY(ITEM_L2TPV2_MSG_CTRL_NS,
+ ITEM_L2TPV2_COMMON, ITEM_NEXT),
+ NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_l2tpv2,
+ hdr.type3.nr)),
+ },
+ [ITEM_PPP] = {
+ .name = "ppp",
+ .help = "match PPP header",
+ .priv = PRIV_ITEM(PPP, sizeof(struct rte_flow_item_ppp)),
+ .next = NEXT(item_ppp),
+ .call = parse_vc,
+ },
+ [ITEM_PPP_ADDR] = {
+ .name = "addr",
+ .help = "PPP address",
+ .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp, hdr.addr)),
+ },
+ [ITEM_PPP_CTRL] = {
+ .name = "ctrl",
+ .help = "PPP control",
+ .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp, hdr.ctrl)),
+ },
+ [ITEM_PPP_PROTO_ID] = {
+ .name = "proto_id",
+ .help = "PPP protocol identifier",
+ .next = NEXT(item_ppp, NEXT_ENTRY(COMMON_UNSIGNED),
+ item_param),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp,
+ hdr.proto_id)),
+ },
/* Validate/create actions. */
[ACTIONS] = {
.name = "actions",
.args = ARGS(ARGS_ENTRY(struct rte_flow_action_count, id)),
.call = parse_vc_conf,
},
- [ACTION_COUNT_SHARED] = {
- .name = "shared",
- .help = "shared counter",
- .next = NEXT(action_count, NEXT_ENTRY(COMMON_BOOLEAN)),
- .args = ARGS(ARGS_ENTRY_BF(struct rte_flow_action_count,
- shared, 1)),
- .call = parse_vc_conf,
- },
[ACTION_RSS] = {
.name = "rss",
.help = "spread packets among several queues",
[ACTION_MODIFY_FIELD] = {
.name = "modify_field",
.help = "modify destination field with data from source field",
- .priv = PRIV_ACTION(MODIFY_FIELD,
- sizeof(struct rte_flow_action_modify_field)),
+ .priv = PRIV_ACTION(MODIFY_FIELD, ACTION_MODIFY_SIZE),
.next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_OP)),
.call = parse_vc,
},
.name = "src_value",
.help = "source immediate value",
.next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
- NEXT_ENTRY(COMMON_UNSIGNED)),
- .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
+ NEXT_ENTRY(COMMON_HEX)),
+ .args = ARGS(ARGS_ENTRY_ARB(0, 0),
+ ARGS_ENTRY_ARB(0, 0),
+ ARGS_ENTRY(struct rte_flow_action_modify_field,
src.value)),
.call = parse_vc_conf,
},
+ [ACTION_MODIFY_FIELD_SRC_POINTER] = {
+ .name = "src_ptr",
+ .help = "pointer to source immediate value",
+ .next = NEXT(NEXT_ENTRY(ACTION_MODIFY_FIELD_WIDTH),
+ NEXT_ENTRY(COMMON_HEX)),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_action_modify_field,
+ src.pvalue),
+ ARGS_ENTRY_ARB(0, 0),
+ ARGS_ENTRY_ARB
+ (sizeof(struct rte_flow_action_modify_field),
+ ACTION_MODIFY_PATTERN_SIZE)),
+ .call = parse_vc_conf,
+ },
[ACTION_MODIFY_FIELD_WIDTH] = {
.name = "width",
.help = "number of bits to copy",
.next = NEXT(action_update_conntrack),
.call = parse_vc_action_conntrack_update,
},
+ [ACTION_PORT_REPRESENTOR] = {
+ .name = "port_representor",
+ .help = "at embedded switch level, send matching traffic to the given ethdev",
+ .priv = PRIV_ACTION(PORT_REPRESENTOR,
+ sizeof(struct rte_flow_action_ethdev)),
+ .next = NEXT(action_port_representor),
+ .call = parse_vc,
+ },
+ [ACTION_PORT_REPRESENTOR_PORT_ID] = {
+ .name = "port_id",
+ .help = "ethdev port ID",
+ .next = NEXT(action_port_representor,
+ NEXT_ENTRY(COMMON_UNSIGNED)),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev,
+ port_id)),
+ .call = parse_vc_conf,
+ },
+ [ACTION_REPRESENTED_PORT] = {
+ .name = "represented_port",
+ .help = "at embedded switch level, send matching traffic to the entity represented by the given ethdev",
+ .priv = PRIV_ACTION(REPRESENTED_PORT,
+ sizeof(struct rte_flow_action_ethdev)),
+ .next = NEXT(action_represented_port),
+ .call = parse_vc,
+ },
+ [ACTION_REPRESENTED_PORT_ETHDEV_PORT_ID] = {
+ .name = "ethdev_port_id",
+ .help = "ethdev port ID",
+ .next = NEXT(action_represented_port,
+ NEXT_ENTRY(COMMON_UNSIGNED)),
+ .args = ARGS(ARGS_ENTRY(struct rte_flow_action_ethdev,
+ port_id)),
+ .call = parse_vc_conf,
+ },
/* Indirect action destroy arguments. */
[INDIRECT_ACTION_DESTROY_ID] = {
.name = "action_id",
return len;
}
+/** Parse L2TPv2 common header type field. */
+static int
+parse_vc_item_l2tpv2_type(struct context *ctx, const struct token *token,
+ const char *str, unsigned int len,
+ void *buf, unsigned int size)
+{
+ struct rte_flow_item_l2tpv2 *l2tpv2;
+ struct rte_flow_item_l2tpv2 *l2tpv2_mask;
+ struct rte_flow_item *item;
+ uint32_t data_size;
+ uint8_t msg_type = 0;
+ struct buffer *out = buf;
+ const struct arg *arg;
+
+ (void)size;
+ /* Token name must match. */
+ if (parse_default(ctx, token, str, len, NULL, 0) < 0)
+ return -1;
+ switch (ctx->curr) {
+ case ITEM_L2TPV2_COMMON_TYPE_DATA_L:
+ msg_type |= 0x4000;
+ break;
+ case ITEM_L2TPV2_COMMON_TYPE_CTRL:
+ msg_type |= 0xC800;
+ break;
+ default:
+ return -1;
+ }
+ if (!ctx->object)
+ return len;
+ arg = pop_args(ctx);
+ if (!arg)
+ return -1;
+ l2tpv2 = (struct rte_flow_item_l2tpv2 *)out->args.vc.data;
+ l2tpv2->hdr.common.flags_version |= msg_type;
+ data_size = ctx->objdata / 3; /* spec, last, mask */
+ l2tpv2_mask = (struct rte_flow_item_l2tpv2 *)(out->args.vc.data +
+ (data_size * 2));
+ l2tpv2_mask->hdr.common.flags_version = 0xFFFF;
+ if (arg->hton) {
+ l2tpv2->hdr.common.flags_version =
+ rte_cpu_to_be_16(l2tpv2->hdr.common.flags_version);
+ l2tpv2_mask->hdr.common.flags_version =
+ rte_cpu_to_be_16(l2tpv2_mask->hdr.common.flags_version);
+ }
+ item = &out->args.vc.pattern[out->args.vc.pattern_n - 1];
+ item->spec = l2tpv2;
+ item->mask = l2tpv2_mask;
+ return len;
+}
+
/** Parse meter color action type. */
static int
parse_vc_action_meter_color_type(struct context *ctx, const struct token *token,
return len;
}
+static int
+parse_flex(struct context *ctx, const struct token *token,
+ const char *str, unsigned int len,
+ void *buf, unsigned int size)
+{
+ struct buffer *out = buf;
+
+ /* Token name must match. */
+ if (parse_default(ctx, token, str, len, NULL, 0) < 0)
+ return -1;
+ /* Nothing else to do if there is no buffer. */
+ if (!out)
+ return len;
+ if (out->command == ZERO) {
+ if (ctx->curr != FLEX)
+ return -1;
+ if (sizeof(*out) > size)
+ return -1;
+ out->command = ctx->curr;
+ ctx->objdata = 0;
+ ctx->object = out;
+ ctx->objmask = NULL;
+ } else {
+ switch (ctx->curr) {
+ default:
+ break;
+ case FLEX_ITEM_INIT:
+ case FLEX_ITEM_CREATE:
+ case FLEX_ITEM_DESTROY:
+ out->command = ctx->curr;
+ break;
+ }
+ }
+
+ return len;
+}
+
static int
parse_tunnel(struct context *ctx, const struct token *token,
const char *str, unsigned int len,
hexlen -= 2;
}
if (hexlen > length)
- return -1;
+ goto error;
ret = parse_hex_string(str, hex_tmp, &hexlen);
if (ret < 0)
goto error;
+ /* Check the converted binary fits into data buffer. */
+ if (hexlen > size)
+ goto error;
/* Let parse_int() fill length information first. */
ret = snprintf(tmp, sizeof(tmp), "%u", hexlen);
if (ret < 0)
return len;
}
+/*
+ * Replace testpmd handles in a flex flow item with real values.
+ */
+static int
+parse_flex_handle(struct context *ctx, const struct token *token,
+ const char *str, unsigned int len,
+ void *buf, unsigned int size)
+{
+ struct rte_flow_item_flex *spec, *mask;
+ const struct rte_flow_item_flex *src_spec, *src_mask;
+ const struct arg *arg = pop_args(ctx);
+ uint32_t offset;
+ uint16_t handle;
+ int ret;
+
+ if (!arg) {
+ printf("Bad environment\n");
+ return -1;
+ }
+ offset = arg->offset;
+ push_args(ctx, arg);
+ ret = parse_int(ctx, token, str, len, buf, size);
+ if (ret <= 0 || !ctx->object)
+ return ret;
+ if (ctx->port >= RTE_MAX_ETHPORTS) {
+ printf("Bad port\n");
+ return -1;
+ }
+ if (offset == offsetof(struct rte_flow_item_flex, handle)) {
+ const struct flex_item *fp;
+ struct rte_flow_item_flex *item_flex = ctx->object;
+ handle = (uint16_t)(uintptr_t)item_flex->handle;
+ if (handle >= FLEX_MAX_PARSERS_NUM) {
+ printf("Bad flex item handle\n");
+ return -1;
+ }
+ fp = flex_items[ctx->port][handle];
+ if (!fp) {
+ printf("Bad flex item handle\n");
+ return -1;
+ }
+ item_flex->handle = fp->flex_handle;
+ } else if (offset == offsetof(struct rte_flow_item_flex, pattern)) {
+ handle = (uint16_t)(uintptr_t)
+ ((struct rte_flow_item_flex *)ctx->object)->pattern;
+ if (handle >= FLEX_MAX_PATTERNS_NUM) {
+ printf("Bad pattern handle\n");
+ return -1;
+ }
+ src_spec = &flex_patterns[handle].spec;
+ src_mask = &flex_patterns[handle].mask;
+ spec = ctx->object;
+ mask = spec + 2; /* spec, last, mask */
+ /* fill flow rule spec and mask parameters */
+ spec->length = src_spec->length;
+ spec->pattern = src_spec->pattern;
+ mask->length = src_mask->length;
+ mask->pattern = src_mask->pattern;
+ } else {
+ printf("Bad arguments - unknown flex item offset\n");
+ return -1;
+ }
+ return ret;
+}
+
/** No completion. */
static int
comp_none(struct context *ctx, const struct token *token,
comp_set_modify_field_op(struct context *ctx, const struct token *token,
unsigned int ent, char *buf, unsigned int size)
{
- uint16_t idx = 0;
-
RTE_SET_USED(ctx);
RTE_SET_USED(token);
- for (idx = 0; modify_field_ops[idx]; ++idx)
- ;
if (!buf)
- return idx + 1;
- if (ent < idx)
+ return RTE_DIM(modify_field_ops);
+ if (ent < RTE_DIM(modify_field_ops) - 1)
return strlcpy(buf, modify_field_ops[ent], size);
return -1;
}
comp_set_modify_field_id(struct context *ctx, const struct token *token,
unsigned int ent, char *buf, unsigned int size)
{
- uint16_t idx = 0;
+ const char *name;
- RTE_SET_USED(ctx);
RTE_SET_USED(token);
- for (idx = 0; modify_field_ids[idx]; ++idx)
- ;
if (!buf)
- return idx + 1;
- if (ent < idx)
- return strlcpy(buf, modify_field_ids[ent], size);
+ return RTE_DIM(modify_field_ids);
+ if (ent >= RTE_DIM(modify_field_ids) - 1)
+ return -1;
+ name = modify_field_ids[ent];
+ if (ctx->curr == ACTION_MODIFY_FIELD_SRC_TYPE ||
+ (strcmp(name, "pointer") && strcmp(name, "value")))
+ return strlcpy(buf, name, size);
return -1;
}
return len;
}
+int
+flow_parse(const char *src, void *result, unsigned int size,
+ struct rte_flow_attr **attr,
+ struct rte_flow_item **pattern, struct rte_flow_action **actions)
+{
+ int ret;
+ struct context saved_flow_ctx = cmd_flow_context;
+
+ cmd_flow_context_init(&cmd_flow_context);
+ do {
+ ret = cmd_flow_parse(NULL, src, result, size);
+ if (ret > 0) {
+ src += ret;
+ while (isspace(*src))
+ src++;
+ }
+ } while (ret > 0 && strlen(src));
+ cmd_flow_context = saved_flow_ctx;
+ *attr = &((struct buffer *)result)->args.vc.attr;
+ *pattern = ((struct buffer *)result)->args.vc.pattern;
+ *actions = ((struct buffer *)result)->args.vc.actions;
+ return (ret >= 0 && !strlen(src)) ? 0 : -1;
+}
+
/** Return number of completion entries (cmdline API). */
static int
cmd_flow_complete_get_nb(cmdline_parse_token_hdr_t *hdr)
port_meter_policy_add(in->port, in->args.policy.policy_id,
in->args.vc.actions);
break;
+ case FLEX_ITEM_CREATE:
+ flex_item_create(in->port, in->args.flex.token,
+ in->args.flex.filename);
+ break;
+ case FLEX_ITEM_DESTROY:
+ flex_item_destroy(in->port, in->args.flex.token);
+ break;
default:
break;
}
break;
case RTE_FLOW_ITEM_TYPE_IPV4:
ipv4 = (struct rte_ipv4_hdr *)buf;
- ipv4->version_ihl = 0x45;
+ if (!ipv4->version_ihl)
+ ipv4->version_ihl = RTE_IPV4_VHL_DEF;
if (next_proto && ipv4->next_proto_id == 0)
ipv4->next_proto_id = (uint8_t)next_proto;
break;
case RTE_FLOW_ITEM_TYPE_PFCP:
mask = &rte_flow_item_pfcp_mask;
break;
+ case RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR:
+ case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT:
+ mask = &rte_flow_item_ethdev_mask;
+ break;
+ case RTE_FLOW_ITEM_TYPE_L2TPV2:
+ mask = &rte_flow_item_l2tpv2_mask;
+ break;
+ case RTE_FLOW_ITEM_TYPE_PPP:
+ mask = &rte_flow_item_ppp_mask;
+ break;
default:
break;
}
action->conf = &sample_nvgre_encap[idx];
break;
default:
- printf("Error - Not supported action\n");
+ fprintf(stderr, "Error - Not supported action\n");
return;
}
rte_memcpy(data, action, sizeof(struct rte_flow_action));
break;
}
if (gtp_psc != i + 1) {
- printf("Error - GTP PSC does not follow GTP\n");
+ fprintf(stderr,
+ "Error - GTP PSC does not follow GTP\n");
goto error;
}
gtp = item->spec;
if ((gtp->v_pt_rsv_flags & 0x07) != 0x04) {
/* Only E flag should be set. */
- printf("Error - GTP unsupported flags\n");
+ fprintf(stderr,
+ "Error - GTP unsupported flags\n");
goto error;
} else {
struct rte_gtp_hdr_ext_word ext_word = {
break;
case RTE_FLOW_ITEM_TYPE_GTP_PSC:
if (gtp_psc >= 0) {
- printf("Error - Multiple GTP PSC items\n");
+ fprintf(stderr,
+ "Error - Multiple GTP PSC items\n");
goto error;
} else {
const struct rte_flow_item_gtp_psc
*opt = item->spec;
struct {
uint8_t len;
- uint8_t pdu_type;
- uint8_t qfi;
+ uint8_t pdu_type:4;
+ uint8_t qfi:6;
uint8_t next;
} psc;
-
- if (opt->pdu_type & 0x0F) {
- /* Support the minimal option only. */
- printf("Error - GTP PSC option with "
- "extra fields not supported\n");
- goto error;
- }
psc.len = sizeof(psc);
- psc.pdu_type = opt->pdu_type;
- psc.qfi = opt->qfi;
+ psc.pdu_type = opt->hdr.type;
+ psc.qfi = opt->hdr.qfi;
psc.next = 0;
*total_size += sizeof(psc);
rte_memcpy(data_tail - (*total_size),
case RTE_FLOW_ITEM_TYPE_PFCP:
size = sizeof(struct rte_flow_item_pfcp);
break;
+ case RTE_FLOW_ITEM_TYPE_FLEX:
+ size = item->spec ?
+ ((const struct rte_flow_item_flex *)
+ item->spec)->length : 0;
+ break;
default:
- printf("Error - Not supported item\n");
+ fprintf(stderr, "Error - Not supported item\n");
goto error;
}
*total_size += size;
all = 1;
index = 0;
} else if (index >= RAW_ENCAP_CONFS_MAX_NUM) {
- printf("index should be 0-%u\n", RAW_ENCAP_CONFS_MAX_NUM - 1);
+ fprintf(stderr, "index should be 0-%u\n",
+ RAW_ENCAP_CONFS_MAX_NUM - 1);
return;
}
do {