net/sfc: make flow list engine-agnostic
[dpdk.git] / drivers / net / sfc / sfc_flow.c
index 01a81ea..0826032 100644 (file)
@@ -11,7 +11,6 @@
 #include <rte_tailq.h>
 #include <rte_common.h>
 #include <rte_ethdev_driver.h>
-#include <rte_eth_ctrl.h>
 #include <rte_ether.h>
 #include <rte_flow.h>
 #include <rte_flow_driver.h>
@@ -278,7 +277,7 @@ sfc_flow_parse_eth(const struct rte_flow_item *item,
        if (spec == NULL)
                return 0;
 
-       if (is_same_ether_addr(&mask->dst, &supp_mask.dst)) {
+       if (rte_is_same_ether_addr(&mask->dst, &supp_mask.dst)) {
                efx_spec->efs_match_flags |= is_ifrm ?
                        EFX_FILTER_MATCH_IFRM_LOC_MAC :
                        EFX_FILTER_MATCH_LOC_MAC;
@@ -286,7 +285,7 @@ sfc_flow_parse_eth(const struct rte_flow_item *item,
                           EFX_MAC_ADDR_LEN);
        } else if (memcmp(mask->dst.addr_bytes, ig_mask,
                          EFX_MAC_ADDR_LEN) == 0) {
-               if (is_unicast_ether_addr(&spec->dst))
+               if (rte_is_unicast_ether_addr(&spec->dst))
                        efx_spec->efs_match_flags |= is_ifrm ?
                                EFX_FILTER_MATCH_IFRM_UNKNOWN_UCAST_DST :
                                EFX_FILTER_MATCH_UNKNOWN_UCAST_DST;
@@ -294,7 +293,7 @@ sfc_flow_parse_eth(const struct rte_flow_item *item,
                        efx_spec->efs_match_flags |= is_ifrm ?
                                EFX_FILTER_MATCH_IFRM_UNKNOWN_MCAST_DST :
                                EFX_FILTER_MATCH_UNKNOWN_MCAST_DST;
-       } else if (!is_zero_ether_addr(&mask->dst)) {
+       } else if (!rte_is_zero_ether_addr(&mask->dst)) {
                goto fail_bad_mask;
        }
 
@@ -303,11 +302,11 @@ sfc_flow_parse_eth(const struct rte_flow_item *item,
         * ethertype masks are equal to zero in inner frame,
         * so these fields are filled in only for the outer frame
         */
-       if (is_same_ether_addr(&mask->src, &supp_mask.src)) {
+       if (rte_is_same_ether_addr(&mask->src, &supp_mask.src)) {
                efx_spec->efs_match_flags |= EFX_FILTER_MATCH_REM_MAC;
                rte_memcpy(efx_spec->efs_rem_mac, spec->src.addr_bytes,
                           EFX_MAC_ADDR_LEN);
-       } else if (!is_zero_ether_addr(&mask->src)) {
+       } else if (!rte_is_zero_ether_addr(&mask->src)) {
                goto fail_bad_mask;
        }
 
@@ -952,7 +951,7 @@ sfc_flow_parse_geneve(const struct rte_flow_item *item,
                return 0;
 
        if (mask->protocol == supp_mask.protocol) {
-               if (spec->protocol != rte_cpu_to_be_16(ETHER_TYPE_TEB)) {
+               if (spec->protocol != rte_cpu_to_be_16(RTE_ETHER_TYPE_TEB)) {
                        rte_flow_error_set(error, EINVAL,
                                RTE_FLOW_ERROR_TYPE_ITEM, item,
                                "GENEVE encap. protocol must be Ethernet "
@@ -1263,7 +1262,7 @@ sfc_flow_parse_rss(struct sfc_adapter *sa,
        unsigned int rxq_hw_index_max;
        efx_rx_hash_type_t efx_hash_types;
        const uint8_t *rss_key;
-       struct sfc_flow_rss *sfc_rss_conf = &flow->rss_conf;
+       struct sfc_flow_rss *sfc_rss_conf = &flow->spec.rss_conf;
        unsigned int i;
 
        if (action_rss->queue_num == 0)
@@ -1335,7 +1334,7 @@ sfc_flow_parse_rss(struct sfc_adapter *sa,
                rss_key = rss->key;
        }
 
-       flow->rss = B_TRUE;
+       flow->spec.rss = B_TRUE;
 
        sfc_rss_conf->rxq_hw_index_min = rxq_hw_index_min;
        sfc_rss_conf->rxq_hw_index_max = rxq_hw_index_max;
@@ -1403,12 +1402,12 @@ sfc_flow_filter_insert(struct sfc_adapter *sa,
 {
        struct sfc_adapter_shared * const sas = sfc_sa2shared(sa);
        struct sfc_rss *rss = &sas->rss;
-       struct sfc_flow_rss *flow_rss = &flow->rss_conf;
+       struct sfc_flow_rss *flow_rss = &flow->spec.rss_conf;
        uint32_t efs_rss_context = EFX_RSS_CONTEXT_DEFAULT;
        unsigned int i;
        int rc = 0;
 
-       if (flow->rss) {
+       if (flow->spec.rss) {
                unsigned int rss_spread = MIN(flow_rss->rxq_hw_index_max -
                                              flow_rss->rxq_hw_index_min + 1,
                                              EFX_MAXRSS);
@@ -1451,7 +1450,7 @@ sfc_flow_filter_insert(struct sfc_adapter *sa,
        if (rc != 0)
                goto fail_filter_insert;
 
-       if (flow->rss) {
+       if (flow->spec.rss) {
                /*
                 * Scale table is set after filter insertion because
                 * the table entries are relative to the base RxQ ID
@@ -1492,7 +1491,7 @@ sfc_flow_filter_remove(struct sfc_adapter *sa,
        if (rc != 0)
                return rc;
 
-       if (flow->rss) {
+       if (flow->spec.rss) {
                /*
                 * All specifications for a given flow rule have the same RSS
                 * context, so that RSS context value is taken from the first
@@ -2254,7 +2253,7 @@ sfc_flow_parse(struct rte_eth_dev *dev,
               struct rte_flow *flow,
               struct rte_flow_error *error)
 {
-       struct sfc_adapter *sa = dev->data->dev_private;
+       struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
        int rc;
 
        rc = sfc_flow_parse_attr(attr, flow, error);
@@ -2300,7 +2299,7 @@ sfc_flow_create(struct rte_eth_dev *dev,
                const struct rte_flow_action actions[],
                struct rte_flow_error *error)
 {
-       struct sfc_adapter *sa = dev->data->dev_private;
+       struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
        struct rte_flow *flow = NULL;
        int rc;
 
@@ -2316,10 +2315,10 @@ sfc_flow_create(struct rte_eth_dev *dev,
        if (rc != 0)
                goto fail_bad_value;
 
-       TAILQ_INSERT_TAIL(&sa->filter.flow_list, flow, entries);
-
        sfc_adapter_lock(sa);
 
+       TAILQ_INSERT_TAIL(&sa->flow_list, flow, entries);
+
        if (sa->state == SFC_ADAPTER_STARTED) {
                rc = sfc_flow_filter_insert(sa, flow);
                if (rc != 0) {
@@ -2335,7 +2334,7 @@ sfc_flow_create(struct rte_eth_dev *dev,
        return flow;
 
 fail_filter_insert:
-       TAILQ_REMOVE(&sa->filter.flow_list, flow, entries);
+       TAILQ_REMOVE(&sa->flow_list, flow, entries);
 
 fail_bad_value:
        rte_free(flow);
@@ -2362,7 +2361,7 @@ sfc_flow_remove(struct sfc_adapter *sa,
                                "Failed to destroy flow rule");
        }
 
-       TAILQ_REMOVE(&sa->filter.flow_list, flow, entries);
+       TAILQ_REMOVE(&sa->flow_list, flow, entries);
        rte_free(flow);
 
        return rc;
@@ -2373,13 +2372,13 @@ sfc_flow_destroy(struct rte_eth_dev *dev,
                 struct rte_flow *flow,
                 struct rte_flow_error *error)
 {
-       struct sfc_adapter *sa = dev->data->dev_private;
+       struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
        struct rte_flow *flow_ptr;
        int rc = EINVAL;
 
        sfc_adapter_lock(sa);
 
-       TAILQ_FOREACH(flow_ptr, &sa->filter.flow_list, entries) {
+       TAILQ_FOREACH(flow_ptr, &sa->flow_list, entries) {
                if (flow_ptr == flow)
                        rc = 0;
        }
@@ -2402,14 +2401,14 @@ static int
 sfc_flow_flush(struct rte_eth_dev *dev,
               struct rte_flow_error *error)
 {
-       struct sfc_adapter *sa = dev->data->dev_private;
+       struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
        struct rte_flow *flow;
        int rc = 0;
        int ret = 0;
 
        sfc_adapter_lock(sa);
 
-       while ((flow = TAILQ_FIRST(&sa->filter.flow_list)) != NULL) {
+       while ((flow = TAILQ_FIRST(&sa->flow_list)) != NULL) {
                rc = sfc_flow_remove(sa, flow, error);
                if (rc != 0)
                        ret = rc;
@@ -2424,7 +2423,7 @@ static int
 sfc_flow_isolate(struct rte_eth_dev *dev, int enable,
                 struct rte_flow_error *error)
 {
-       struct sfc_adapter *sa = dev->data->dev_private;
+       struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
        int ret = 0;
 
        sfc_adapter_lock(sa);
@@ -2455,7 +2454,7 @@ sfc_flow_init(struct sfc_adapter *sa)
 {
        SFC_ASSERT(sfc_adapter_is_locked(sa));
 
-       TAILQ_INIT(&sa->filter.flow_list);
+       TAILQ_INIT(&sa->flow_list);
 }
 
 void
@@ -2465,8 +2464,8 @@ sfc_flow_fini(struct sfc_adapter *sa)
 
        SFC_ASSERT(sfc_adapter_is_locked(sa));
 
-       while ((flow = TAILQ_FIRST(&sa->filter.flow_list)) != NULL) {
-               TAILQ_REMOVE(&sa->filter.flow_list, flow, entries);
+       while ((flow = TAILQ_FIRST(&sa->flow_list)) != NULL) {
+               TAILQ_REMOVE(&sa->flow_list, flow, entries);
                rte_free(flow);
        }
 }
@@ -2478,7 +2477,7 @@ sfc_flow_stop(struct sfc_adapter *sa)
 
        SFC_ASSERT(sfc_adapter_is_locked(sa));
 
-       TAILQ_FOREACH(flow, &sa->filter.flow_list, entries)
+       TAILQ_FOREACH(flow, &sa->flow_list, entries)
                sfc_flow_filter_remove(sa, flow);
 }
 
@@ -2492,7 +2491,7 @@ sfc_flow_start(struct sfc_adapter *sa)
 
        SFC_ASSERT(sfc_adapter_is_locked(sa));
 
-       TAILQ_FOREACH(flow, &sa->filter.flow_list, entries) {
+       TAILQ_FOREACH(flow, &sa->flow_list, entries) {
                rc = sfc_flow_filter_insert(sa, flow);
                if (rc != 0)
                        goto fail_bad_flow;