net/igc: remove use of uint type
[dpdk.git] / drivers / net / ixgbe / ixgbe_flow.c
index 2b8529f..0b10e91 100644 (file)
@@ -25,7 +25,7 @@
 #include <rte_eal.h>
 #include <rte_alarm.h>
 #include <rte_ether.h>
-#include <rte_ethdev_driver.h>
+#include <ethdev_driver.h>
 #include <rte_malloc.h>
 #include <rte_random.h>
 #include <rte_dev.h>
@@ -72,7 +72,7 @@ struct ixgbe_fdir_rule_ele {
 /* l2_tunnel filter list structure */
 struct ixgbe_eth_l2_tunnel_conf_ele {
        TAILQ_ENTRY(ixgbe_eth_l2_tunnel_conf_ele) entries;
-       struct rte_eth_l2_tunnel_conf filter_info;
+       struct ixgbe_l2_tunnel_conf filter_info;
 };
 /* rss filter list structure */
 struct ixgbe_rss_conf_ele {
@@ -215,7 +215,7 @@ cons_parse_ntuple_filter(const struct rte_flow_attr *attr,
        memset(&eth_null, 0, sizeof(struct rte_flow_item_eth));
        memset(&vlan_null, 0, sizeof(struct rte_flow_item_vlan));
 
-#ifdef RTE_LIBRTE_SECURITY
+#ifdef RTE_LIB_SECURITY
        /**
         *  Special case for flow action type RTE_FLOW_ACTION_TYPE_SECURITY
         */
@@ -629,7 +629,7 @@ ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,
        if (ret)
                return ret;
 
-#ifdef RTE_LIBRTE_SECURITY
+#ifdef RTE_LIB_SECURITY
        /* ESP flow not really a flow*/
        if (filter->proto == IPPROTO_ESP)
                return 0;
@@ -870,15 +870,6 @@ ixgbe_parse_ethertype_filter(struct rte_eth_dev *dev,
        if (ret)
                return ret;
 
-       /* Ixgbe doesn't support MAC address. */
-       if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
-               memset(filter, 0, sizeof(struct rte_eth_ethertype_filter));
-               rte_flow_error_set(error, EINVAL,
-                       RTE_FLOW_ERROR_TYPE_ITEM,
-                       NULL, "Not supported by ethertype filter");
-               return -rte_errno;
-       }
-
        if (filter->queue >= dev->data->nb_rx_queues) {
                memset(filter, 0, sizeof(struct rte_eth_ethertype_filter));
                rte_flow_error_set(error, EINVAL,
@@ -1048,13 +1039,13 @@ cons_parse_syn_filter(const struct rte_flow_attr *attr,
 
        tcp_spec = item->spec;
        tcp_mask = item->mask;
-       if (!(tcp_spec->hdr.tcp_flags & TCP_SYN_FLAG) ||
+       if (!(tcp_spec->hdr.tcp_flags & RTE_TCP_SYN_FLAG) ||
            tcp_mask->hdr.src_port ||
            tcp_mask->hdr.dst_port ||
            tcp_mask->hdr.sent_seq ||
            tcp_mask->hdr.recv_ack ||
            tcp_mask->hdr.data_off ||
-           tcp_mask->hdr.tcp_flags != TCP_SYN_FLAG ||
+           tcp_mask->hdr.tcp_flags != RTE_TCP_SYN_FLAG ||
            tcp_mask->hdr.rx_win ||
            tcp_mask->hdr.cksum ||
            tcp_mask->hdr.tcp_urp) {
@@ -1197,7 +1188,7 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev,
                        const struct rte_flow_attr *attr,
                        const struct rte_flow_item pattern[],
                        const struct rte_flow_action actions[],
-                       struct rte_eth_l2_tunnel_conf *filter,
+                       struct ixgbe_l2_tunnel_conf *filter,
                        struct rte_flow_error *error)
 {
        const struct rte_flow_item *item;
@@ -1231,7 +1222,7 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev,
        /* The first not void item should be e-tag. */
        item = next_no_void_pattern(pattern, NULL);
        if (item->type != RTE_FLOW_ITEM_TYPE_E_TAG) {
-               memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf));
+               memset(filter, 0, sizeof(struct ixgbe_l2_tunnel_conf));
                rte_flow_error_set(error, EINVAL,
                        RTE_FLOW_ERROR_TYPE_ITEM,
                        item, "Not supported by L2 tunnel filter");
@@ -1239,7 +1230,7 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev,
        }
 
        if (!item->spec || !item->mask) {
-               memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf));
+               memset(filter, 0, sizeof(struct ixgbe_l2_tunnel_conf));
                rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
                        item, "Not supported by L2 tunnel filter");
                return -rte_errno;
@@ -1261,7 +1252,7 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev,
            e_tag_mask->in_ecid_e ||
            e_tag_mask->ecid_e ||
            e_tag_mask->rsvd_grp_ecid_b != rte_cpu_to_be_16(0x3FFF)) {
-               memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf));
+               memset(filter, 0, sizeof(struct ixgbe_l2_tunnel_conf));
                rte_flow_error_set(error, EINVAL,
                        RTE_FLOW_ERROR_TYPE_ITEM,
                        item, "Not supported by L2 tunnel filter");
@@ -1278,7 +1269,7 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev,
        /* check if the next not void item is END */
        item = next_no_void_pattern(pattern, item);
        if (item->type != RTE_FLOW_ITEM_TYPE_END) {
-               memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf));
+               memset(filter, 0, sizeof(struct ixgbe_l2_tunnel_conf));
                rte_flow_error_set(error, EINVAL,
                        RTE_FLOW_ERROR_TYPE_ITEM,
                        item, "Not supported by L2 tunnel filter");
@@ -1288,7 +1279,7 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev,
        /* parse attr */
        /* must be input direction */
        if (!attr->ingress) {
-               memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf));
+               memset(filter, 0, sizeof(struct ixgbe_l2_tunnel_conf));
                rte_flow_error_set(error, EINVAL,
                        RTE_FLOW_ERROR_TYPE_ATTR_INGRESS,
                        attr, "Only support ingress.");
@@ -1297,7 +1288,7 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev,
 
        /* not supported */
        if (attr->egress) {
-               memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf));
+               memset(filter, 0, sizeof(struct ixgbe_l2_tunnel_conf));
                rte_flow_error_set(error, EINVAL,
                        RTE_FLOW_ERROR_TYPE_ATTR_EGRESS,
                        attr, "Not support egress.");
@@ -1306,7 +1297,7 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev,
 
        /* not supported */
        if (attr->transfer) {
-               memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf));
+               memset(filter, 0, sizeof(struct ixgbe_l2_tunnel_conf));
                rte_flow_error_set(error, EINVAL,
                        RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER,
                        attr, "No support for transfer.");
@@ -1315,7 +1306,7 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev,
 
        /* not supported */
        if (attr->priority) {
-               memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf));
+               memset(filter, 0, sizeof(struct ixgbe_l2_tunnel_conf));
                rte_flow_error_set(error, EINVAL,
                        RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY,
                        attr, "Not support priority.");
@@ -1326,7 +1317,7 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev,
        act = next_no_void_action(actions, NULL);
        if (act->type != RTE_FLOW_ACTION_TYPE_VF &&
                        act->type != RTE_FLOW_ACTION_TYPE_PF) {
-               memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf));
+               memset(filter, 0, sizeof(struct ixgbe_l2_tunnel_conf));
                rte_flow_error_set(error, EINVAL,
                        RTE_FLOW_ERROR_TYPE_ACTION,
                        act, "Not supported action.");
@@ -1343,7 +1334,7 @@ cons_parse_l2_tn_filter(struct rte_eth_dev *dev,
        /* check if the next not void item is END */
        act = next_no_void_action(actions, act);
        if (act->type != RTE_FLOW_ACTION_TYPE_END) {
-               memset(filter, 0, sizeof(struct rte_eth_l2_tunnel_conf));
+               memset(filter, 0, sizeof(struct ixgbe_l2_tunnel_conf));
                rte_flow_error_set(error, EINVAL,
                        RTE_FLOW_ERROR_TYPE_ACTION,
                        act, "Not supported action.");
@@ -1358,7 +1349,7 @@ ixgbe_parse_l2_tn_filter(struct rte_eth_dev *dev,
                        const struct rte_flow_attr *attr,
                        const struct rte_flow_item pattern[],
                        const struct rte_flow_action actions[],
-                       struct rte_eth_l2_tunnel_conf *l2_tn_filter,
+                       struct ixgbe_l2_tunnel_conf *l2_tn_filter,
                        struct rte_flow_error *error)
 {
        int ret = 0;
@@ -1372,7 +1363,7 @@ ixgbe_parse_l2_tn_filter(struct rte_eth_dev *dev,
        if (hw->mac.type != ixgbe_mac_X550 &&
                hw->mac.type != ixgbe_mac_X550EM_x &&
                hw->mac.type != ixgbe_mac_X550EM_a) {
-               memset(l2_tn_filter, 0, sizeof(struct rte_eth_l2_tunnel_conf));
+               memset(l2_tn_filter, 0, sizeof(struct ixgbe_l2_tunnel_conf));
                rte_flow_error_set(error, EINVAL,
                        RTE_FLOW_ERROR_TYPE_ITEM,
                        NULL, "Not supported by L2 tunnel filter");
@@ -2874,7 +2865,7 @@ ixgbe_parse_rss_filter(struct rte_eth_dev *dev,
        /* check if the next not void item is END */
        act = next_no_void_action(actions, act);
        if (act->type != RTE_FLOW_ACTION_TYPE_END) {
-               memset(rss_conf, 0, sizeof(struct rte_eth_rss_conf));
+               memset(rss_conf, 0, sizeof(struct ixgbe_rte_flow_rss_conf));
                rte_flow_error_set(error, EINVAL,
                        RTE_FLOW_ERROR_TYPE_ACTION,
                        act, "Not supported action.");
@@ -3023,7 +3014,7 @@ ixgbe_flow_create(struct rte_eth_dev *dev,
        struct rte_eth_ethertype_filter ethertype_filter;
        struct rte_eth_syn_filter syn_filter;
        struct ixgbe_fdir_rule fdir_rule;
-       struct rte_eth_l2_tunnel_conf l2_tn_filter;
+       struct ixgbe_l2_tunnel_conf l2_tn_filter;
        struct ixgbe_hw_fdir_info *fdir_info =
                IXGBE_DEV_PRIVATE_TO_FDIR_INFO(dev->data->dev_private);
        struct ixgbe_rte_flow_rss_conf rss_conf;
@@ -3057,7 +3048,7 @@ ixgbe_flow_create(struct rte_eth_dev *dev,
        ret = ixgbe_parse_ntuple_filter(dev, attr, pattern,
                        actions, &ntuple_filter, error);
 
-#ifdef RTE_LIBRTE_SECURITY
+#ifdef RTE_LIB_SECURITY
        /* ESP flow not really a flow*/
        if (ntuple_filter.proto == IPPROTO_ESP)
                return flow;
@@ -3146,13 +3137,13 @@ ixgbe_flow_create(struct rte_eth_dev *dev,
                                rte_memcpy(&fdir_info->mask,
                                        &fdir_rule.mask,
                                        sizeof(struct ixgbe_hw_fdir_mask));
-                               fdir_info->flex_bytes_offset =
-                                       fdir_rule.flex_bytes_offset;
 
-                               if (fdir_rule.mask.flex_bytes_mask)
-                                       ixgbe_fdir_set_flexbytes_offset(dev,
+                               if (fdir_rule.mask.flex_bytes_mask) {
+                                       ret = ixgbe_fdir_set_flexbytes_offset(dev,
                                                fdir_rule.flex_bytes_offset);
-
+                                       if (ret)
+                                               goto out;
+                               }
                                ret = ixgbe_fdir_set_input_mask(dev);
                                if (ret)
                                        goto out;
@@ -3170,8 +3161,9 @@ ixgbe_flow_create(struct rte_eth_dev *dev,
                                if (ret)
                                        goto out;
 
-                               if (fdir_info->flex_bytes_offset !=
-                                               fdir_rule.flex_bytes_offset)
+                               if (fdir_rule.mask.flex_bytes_mask &&
+                                   fdir_info->flex_bytes_offset !=
+                                   fdir_rule.flex_bytes_offset)
                                        goto out;
                        }
                }
@@ -3211,7 +3203,7 @@ ixgbe_flow_create(struct rte_eth_dev *dev,
                goto out;
        }
 
-       memset(&l2_tn_filter, 0, sizeof(struct rte_eth_l2_tunnel_conf));
+       memset(&l2_tn_filter, 0, sizeof(struct ixgbe_l2_tunnel_conf));
        ret = ixgbe_parse_l2_tn_filter(dev, attr, pattern,
                                        actions, &l2_tn_filter, error);
        if (!ret) {
@@ -3225,7 +3217,7 @@ ixgbe_flow_create(struct rte_eth_dev *dev,
                        }
                        rte_memcpy(&l2_tn_filter_ptr->filter_info,
                                &l2_tn_filter,
-                               sizeof(struct rte_eth_l2_tunnel_conf));
+                               sizeof(struct ixgbe_l2_tunnel_conf));
                        TAILQ_INSERT_TAIL(&filter_l2_tunnel_list,
                                l2_tn_filter_ptr, entries);
                        flow->rule = l2_tn_filter_ptr;
@@ -3282,7 +3274,7 @@ ixgbe_flow_validate(struct rte_eth_dev *dev,
        struct rte_eth_ntuple_filter ntuple_filter;
        struct rte_eth_ethertype_filter ethertype_filter;
        struct rte_eth_syn_filter syn_filter;
-       struct rte_eth_l2_tunnel_conf l2_tn_filter;
+       struct ixgbe_l2_tunnel_conf l2_tn_filter;
        struct ixgbe_fdir_rule fdir_rule;
        struct ixgbe_rte_flow_rss_conf rss_conf;
        int ret;
@@ -3311,7 +3303,7 @@ ixgbe_flow_validate(struct rte_eth_dev *dev,
        if (!ret)
                return 0;
 
-       memset(&l2_tn_filter, 0, sizeof(struct rte_eth_l2_tunnel_conf));
+       memset(&l2_tn_filter, 0, sizeof(struct ixgbe_l2_tunnel_conf));
        ret = ixgbe_parse_l2_tn_filter(dev, attr, pattern,
                                actions, &l2_tn_filter, error);
        if (!ret)
@@ -3337,7 +3329,7 @@ ixgbe_flow_destroy(struct rte_eth_dev *dev,
        struct rte_eth_ethertype_filter ethertype_filter;
        struct rte_eth_syn_filter syn_filter;
        struct ixgbe_fdir_rule fdir_rule;
-       struct rte_eth_l2_tunnel_conf l2_tn_filter;
+       struct ixgbe_l2_tunnel_conf l2_tn_filter;
        struct ixgbe_ntuple_filter_ele *ntuple_filter_ptr;
        struct ixgbe_ethertype_filter_ele *ethertype_filter_ptr;
        struct ixgbe_eth_syn_filter_ele *syn_filter_ptr;
@@ -3407,7 +3399,7 @@ ixgbe_flow_destroy(struct rte_eth_dev *dev,
                l2_tn_filter_ptr = (struct ixgbe_eth_l2_tunnel_conf_ele *)
                                pmd_flow->rule;
                rte_memcpy(&l2_tn_filter, &l2_tn_filter_ptr->filter_info,
-                       sizeof(struct rte_eth_l2_tunnel_conf));
+                       sizeof(struct ixgbe_l2_tunnel_conf));
                ret = ixgbe_dev_l2_tunnel_filter_del(dev, &l2_tn_filter);
                if (!ret) {
                        TAILQ_REMOVE(&filter_l2_tunnel_list,