- return ip6 ? mrvl_parse_ip6(item, flow, error) :
- mrvl_parse_ip4(item, flow, error);
-}
-
-/**
- * Parse flow pattern composed of the eth and ipv4 items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static inline int
-mrvl_parse_pattern_eth_ip4(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- return mrvl_parse_pattern_eth_ip4_ip6(pattern, flow, error, 0);
-}
-
-/**
- * Parse flow pattern composed of the eth and ipv6 items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static inline int
-mrvl_parse_pattern_eth_ip6(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- return mrvl_parse_pattern_eth_ip4_ip6(pattern, flow, error, 1);
-}
-
-/**
- * Parse flow pattern composed of the eth, ip4 and tcp/udp items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @param tcp 1 to parse tcp item, 0 to parse udp item.
- * @returns 0 in case of success, negative value otherwise.
- */
-static int
-mrvl_parse_pattern_eth_ip4_tcp_udp(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error, int tcp)
-{
- const struct rte_flow_item *item = mrvl_next_item(pattern);
- int ret;
-
- ret = mrvl_parse_pattern_eth_ip4_ip6(pattern, flow, error, 0);
- if (ret)
- return ret;
-
- item = mrvl_next_item(item + 1);
- item = mrvl_next_item(item + 1);
-
- if (tcp)
- return mrvl_parse_tcp(item, flow, error);
-
- return mrvl_parse_udp(item, flow, error);
-}
-
-/**
- * Parse flow pattern composed of the eth, ipv4 and tcp items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static inline int
-mrvl_parse_pattern_eth_ip4_tcp(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- return mrvl_parse_pattern_eth_ip4_tcp_udp(pattern, flow, error, 1);
-}
-
-/**
- * Parse flow pattern composed of the eth, ipv4 and udp items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static inline int
-mrvl_parse_pattern_eth_ip4_udp(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- return mrvl_parse_pattern_eth_ip4_tcp_udp(pattern, flow, error, 0);
-}
-
-/**
- * Parse flow pattern composed of the eth, ipv6 and tcp/udp items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @param tcp 1 to parse tcp item, 0 to parse udp item.
- * @returns 0 in case of success, negative value otherwise.
- */
-static int
-mrvl_parse_pattern_eth_ip6_tcp_udp(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error, int tcp)
-{
- const struct rte_flow_item *item = mrvl_next_item(pattern);
- int ret;
-
- ret = mrvl_parse_pattern_eth_ip4_ip6(pattern, flow, error, 1);
- if (ret)
- return ret;
-
- item = mrvl_next_item(item + 1);
- item = mrvl_next_item(item + 1);
-
- if (tcp)
- return mrvl_parse_tcp(item, flow, error);
-
- return mrvl_parse_udp(item, flow, error);
-}
-
-/**
- * Parse flow pattern composed of the eth, ipv6 and tcp items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static inline int
-mrvl_parse_pattern_eth_ip6_tcp(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- return mrvl_parse_pattern_eth_ip6_tcp_udp(pattern, flow, error, 1);
-}
-
-/**
- * Parse flow pattern composed of the eth, ipv6 and udp items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static inline int
-mrvl_parse_pattern_eth_ip6_udp(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- return mrvl_parse_pattern_eth_ip6_tcp_udp(pattern, flow, error, 0);
-}
-
-/**
- * Parse flow pattern composed of the vlan item.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static int
-mrvl_parse_pattern_vlan(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- const struct rte_flow_item *item = mrvl_next_item(pattern);
-
- return mrvl_parse_vlan(item, flow, error);
-}
-
-/**
- * Parse flow pattern composed of the vlan and ip4/ip6 items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @param ip6 1 to parse ip6 item, 0 to parse ip4 item.
- * @returns 0 in case of success, negative value otherwise.
- */
-static int
-mrvl_parse_pattern_vlan_ip4_ip6(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error, int ip6)
-{
- const struct rte_flow_item *item = mrvl_next_item(pattern);
- int ret;
-
- ret = mrvl_parse_vlan(item, flow, error);
- if (ret)
- return ret;
-
- item = mrvl_next_item(item + 1);
-
- return ip6 ? mrvl_parse_ip6(item, flow, error) :
- mrvl_parse_ip4(item, flow, error);
-}
-
-/**
- * Parse flow pattern composed of the vlan and ipv4 items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static inline int
-mrvl_parse_pattern_vlan_ip4(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- return mrvl_parse_pattern_vlan_ip4_ip6(pattern, flow, error, 0);
-}
-
-/**
- * Parse flow pattern composed of the vlan, ipv4 and tcp/udp items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static int
-mrvl_parse_pattern_vlan_ip_tcp_udp(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error, int tcp)
-{
- const struct rte_flow_item *item = mrvl_next_item(pattern);
- int ret;
-
- ret = mrvl_parse_pattern_vlan_ip4_ip6(pattern, flow, error, 0);
- if (ret)
- return ret;
-
- item = mrvl_next_item(item + 1);
- item = mrvl_next_item(item + 1);
-
- if (tcp)
- return mrvl_parse_tcp(item, flow, error);
-
- return mrvl_parse_udp(item, flow, error);
-}
-
-/**
- * Parse flow pattern composed of the vlan, ipv4 and tcp items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static inline int
-mrvl_parse_pattern_vlan_ip_tcp(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- return mrvl_parse_pattern_vlan_ip_tcp_udp(pattern, flow, error, 1);
-}
-
-/**
- * Parse flow pattern composed of the vlan, ipv4 and udp items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static inline int
-mrvl_parse_pattern_vlan_ip_udp(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- return mrvl_parse_pattern_vlan_ip_tcp_udp(pattern, flow, error, 0);
-}
-
-/**
- * Parse flow pattern composed of the vlan and ipv6 items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static inline int
-mrvl_parse_pattern_vlan_ip6(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- return mrvl_parse_pattern_vlan_ip4_ip6(pattern, flow, error, 1);
-}
-
-/**
- * Parse flow pattern composed of the vlan, ipv6 and tcp/udp items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static int
-mrvl_parse_pattern_vlan_ip6_tcp_udp(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error, int tcp)
-{
- const struct rte_flow_item *item = mrvl_next_item(pattern);
- int ret;
-
- ret = mrvl_parse_pattern_vlan_ip4_ip6(pattern, flow, error, 1);
- if (ret)
- return ret;
-
- item = mrvl_next_item(item + 1);
- item = mrvl_next_item(item + 1);
-
- if (tcp)
- return mrvl_parse_tcp(item, flow, error);
-
- return mrvl_parse_udp(item, flow, error);
-}
-
-/**
- * Parse flow pattern composed of the vlan, ipv6 and tcp items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static inline int
-mrvl_parse_pattern_vlan_ip6_tcp(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- return mrvl_parse_pattern_vlan_ip6_tcp_udp(pattern, flow, error, 1);
-}
-
-/**
- * Parse flow pattern composed of the vlan, ipv6 and udp items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static inline int
-mrvl_parse_pattern_vlan_ip6_udp(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- return mrvl_parse_pattern_vlan_ip6_tcp_udp(pattern, flow, error, 0);
-}
-
-/**
- * Parse flow pattern composed of the ip4/ip6 item.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @param ip6 1 to parse ip6 item, 0 to parse ip4 item.
- * @returns 0 in case of success, negative value otherwise.
- */
-static int
-mrvl_parse_pattern_ip4_ip6(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error, int ip6)
-{
- const struct rte_flow_item *item = mrvl_next_item(pattern);
-
- return ip6 ? mrvl_parse_ip6(item, flow, error) :
- mrvl_parse_ip4(item, flow, error);
-}
-
-/**
- * Parse flow pattern composed of the ipv4 item.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static inline int
-mrvl_parse_pattern_ip4(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- return mrvl_parse_pattern_ip4_ip6(pattern, flow, error, 0);
-}
-
-/**
- * Parse flow pattern composed of the ipv6 item.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static inline int
-mrvl_parse_pattern_ip6(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- return mrvl_parse_pattern_ip4_ip6(pattern, flow, error, 1);
-}
-
-/**
- * Parse flow pattern composed of the ip4/ip6 and tcp items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @param ip6 1 to parse ip6 item, 0 to parse ip4 item.
- * @returns 0 in case of success, negative value otherwise.
- */
-static int
-mrvl_parse_pattern_ip4_ip6_tcp(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error, int ip6)
-{
- const struct rte_flow_item *item = mrvl_next_item(pattern);
- int ret;
-
- ret = ip6 ? mrvl_parse_ip6(item, flow, error) :
- mrvl_parse_ip4(item, flow, error);
- if (ret)
- return ret;
-
- item = mrvl_next_item(item + 1);
-
- return mrvl_parse_tcp(item, flow, error);
-}
-
-/**
- * Parse flow pattern composed of the ipv4 and tcp items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static inline int
-mrvl_parse_pattern_ip4_tcp(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- return mrvl_parse_pattern_ip4_ip6_tcp(pattern, flow, error, 0);
-}
-
-/**
- * Parse flow pattern composed of the ipv6 and tcp items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static inline int
-mrvl_parse_pattern_ip6_tcp(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- return mrvl_parse_pattern_ip4_ip6_tcp(pattern, flow, error, 1);
-}
-
-/**
- * Parse flow pattern composed of the ipv4/ipv6 and udp items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @param ip6 1 to parse ip6 item, 0 to parse ip4 item.
- * @returns 0 in case of success, negative value otherwise.
- */
-static int
-mrvl_parse_pattern_ip4_ip6_udp(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error, int ip6)
-{
- const struct rte_flow_item *item = mrvl_next_item(pattern);
- int ret;
-
- ret = ip6 ? mrvl_parse_ip6(item, flow, error) :
- mrvl_parse_ip4(item, flow, error);
- if (ret)
- return ret;
-
- item = mrvl_next_item(item + 1);
-
- return mrvl_parse_udp(item, flow, error);
-}
-
-/**
- * Parse flow pattern composed of the ipv4 and udp items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static inline int
-mrvl_parse_pattern_ip4_udp(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- return mrvl_parse_pattern_ip4_ip6_udp(pattern, flow, error, 0);
-}
-
-/**
- * Parse flow pattern composed of the ipv6 and udp items.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static inline int
-mrvl_parse_pattern_ip6_udp(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- return mrvl_parse_pattern_ip4_ip6_udp(pattern, flow, error, 1);
-}
-
-/**
- * Parse flow pattern composed of the tcp item.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static int
-mrvl_parse_pattern_tcp(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- const struct rte_flow_item *item = mrvl_next_item(pattern);
-
- return mrvl_parse_tcp(item, flow, error);
-}
-
-/**
- * Parse flow pattern composed of the udp item.
- *
- * @param pattern Pointer to the flow pattern table.
- * @param flow Pointer to the flow.
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static int
-mrvl_parse_pattern_udp(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error)
-{
- const struct rte_flow_item *item = mrvl_next_item(pattern);
-
- return mrvl_parse_udp(item, flow, error);
-}
-
-/**
- * Structure used to map specific flow pattern to the pattern parse callback
- * which will iterate over each pattern item and extract relevant data.
- */
-static const struct {
- const enum rte_flow_item_type *pattern;
- int (*parse)(const struct rte_flow_item pattern[],
- struct rte_flow *flow,
- struct rte_flow_error *error);
-} mrvl_patterns[] = {
- { pattern_eth, mrvl_parse_pattern_eth },
- { pattern_eth_vlan, mrvl_parse_pattern_eth_vlan },
- { pattern_eth_vlan_ip, mrvl_parse_pattern_eth_vlan_ip4 },
- { pattern_eth_vlan_ip6, mrvl_parse_pattern_eth_vlan_ip6 },
- { pattern_eth_ip4, mrvl_parse_pattern_eth_ip4 },
- { pattern_eth_ip4_tcp, mrvl_parse_pattern_eth_ip4_tcp },
- { pattern_eth_ip4_udp, mrvl_parse_pattern_eth_ip4_udp },
- { pattern_eth_ip6, mrvl_parse_pattern_eth_ip6 },
- { pattern_eth_ip6_tcp, mrvl_parse_pattern_eth_ip6_tcp },
- { pattern_eth_ip6_udp, mrvl_parse_pattern_eth_ip6_udp },
- { pattern_vlan, mrvl_parse_pattern_vlan },
- { pattern_vlan_ip, mrvl_parse_pattern_vlan_ip4 },
- { pattern_vlan_ip_tcp, mrvl_parse_pattern_vlan_ip_tcp },
- { pattern_vlan_ip_udp, mrvl_parse_pattern_vlan_ip_udp },
- { pattern_vlan_ip6, mrvl_parse_pattern_vlan_ip6 },
- { pattern_vlan_ip6_tcp, mrvl_parse_pattern_vlan_ip6_tcp },
- { pattern_vlan_ip6_udp, mrvl_parse_pattern_vlan_ip6_udp },
- { pattern_ip, mrvl_parse_pattern_ip4 },
- { pattern_ip_tcp, mrvl_parse_pattern_ip4_tcp },
- { pattern_ip_udp, mrvl_parse_pattern_ip4_udp },
- { pattern_ip6, mrvl_parse_pattern_ip6 },
- { pattern_ip6_tcp, mrvl_parse_pattern_ip6_tcp },
- { pattern_ip6_udp, mrvl_parse_pattern_ip6_udp },
- { pattern_tcp, mrvl_parse_pattern_tcp },
- { pattern_udp, mrvl_parse_pattern_udp }
-};
-
-/**
- * Check whether provided pattern matches any of the supported ones.
- *
- * @param type_pattern Pointer to the pattern type.
- * @param item_pattern Pointer to the flow pattern.
- * @returns 1 in case of success, 0 value otherwise.
- */
-static int
-mrvl_patterns_match(const enum rte_flow_item_type *type_pattern,
- const struct rte_flow_item *item_pattern)
-{
- const enum rte_flow_item_type *type = type_pattern;
- const struct rte_flow_item *item = item_pattern;
-
- for (;;) {
- if (item->type == RTE_FLOW_ITEM_TYPE_VOID) {
- item++;
- continue;
- }
-
- if (*type == RTE_FLOW_ITEM_TYPE_END ||
- item->type == RTE_FLOW_ITEM_TYPE_END)
- break;
-
- if (*type != item->type)
- break;
-
- item++;
- type++;
- }
-
- return *type == item->type;
-}
-
-/**
- * Parse flow attribute.
- *
- * This will check whether the provided attribute's flags are supported.
- *
- * @param priv Unused
- * @param attr Pointer to the flow attribute.
- * @param flow Unused
- * @param error Pointer to the flow error.
- * @returns 0 in case of success, negative value otherwise.
- */
-static int
-mrvl_flow_parse_attr(struct mrvl_priv *priv __rte_unused,
- const struct rte_flow_attr *attr,
- struct rte_flow *flow __rte_unused,
- struct rte_flow_error *error)
-{
- if (!attr) {
- rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ATTR,
- NULL, "NULL attribute");
- return -rte_errno;
- }
-
- if (attr->group) {
- rte_flow_error_set(error, ENOTSUP,
- RTE_FLOW_ERROR_TYPE_ATTR_GROUP, NULL,
- "Groups are not supported");
- return -rte_errno;
- }
- if (attr->priority) {
- rte_flow_error_set(error, ENOTSUP,
- RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, NULL,
- "Priorities are not supported");
- return -rte_errno;
- }
- if (!attr->ingress) {
- rte_flow_error_set(error, ENOTSUP,
- RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, NULL,
- "Only ingress is supported");
- return -rte_errno;
- }
- if (attr->egress) {
- rte_flow_error_set(error, ENOTSUP,
- RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL,
- "Egress is not supported");
- return -rte_errno;
- }
- if (attr->transfer) {
- rte_flow_error_set(error, ENOTSUP,
- RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, NULL,
- "Transfer is not supported");
- return -rte_errno;
- }