From 19621712924d4585ac53df66681b3da30b23b272 Mon Sep 17 00:00:00 2001 From: Ivan Malov Date: Thu, 5 Mar 2020 10:47:48 +0000 Subject: [PATCH] net/sfc: make flow list engine-agnostic A backend which a driver employs to handle flow rules of a given type depends on the underlying NIC flow engine. The driver in question in its current state is tailored to support the only flow engine, VNIC filtering. As the need arises to add support for transfer rules, the driver has to be reworked so that it becomes possible to introduce yet another backend. As a preparation step, make the flow list shared between different engines. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/sfc.h | 2 ++ drivers/net/sfc/sfc_filter.h | 2 -- drivers/net/sfc/sfc_flow.c | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index cc52228771..2520cf2b7c 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -242,6 +242,8 @@ struct sfc_adapter { struct sfc_port port; struct sfc_filter filter; + struct sfc_flow_list flow_list; + unsigned int rxq_max; unsigned int txq_max; diff --git a/drivers/net/sfc/sfc_filter.h b/drivers/net/sfc/sfc_filter.h index 64ab114e06..6a02548139 100644 --- a/drivers/net/sfc/sfc_filter.h +++ b/drivers/net/sfc/sfc_filter.h @@ -23,8 +23,6 @@ struct sfc_filter { size_t supported_match_num; /** Driver cache of supported filter match masks */ uint32_t *supported_match; - /** List of flow rules */ - struct sfc_flow_list flow_list; /** * Supports any of ip_proto, remote host or local host * filters. This flag is used for filter match exceptions diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c index f285ba5525..0826032e01 100644 --- a/drivers/net/sfc/sfc_flow.c +++ b/drivers/net/sfc/sfc_flow.c @@ -2317,7 +2317,7 @@ sfc_flow_create(struct rte_eth_dev *dev, sfc_adapter_lock(sa); - TAILQ_INSERT_TAIL(&sa->filter.flow_list, flow, entries); + TAILQ_INSERT_TAIL(&sa->flow_list, flow, entries); if (sa->state == SFC_ADAPTER_STARTED) { rc = sfc_flow_filter_insert(sa, flow); @@ -2334,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); @@ -2361,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; @@ -2378,7 +2378,7 @@ sfc_flow_destroy(struct rte_eth_dev *dev, 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; } @@ -2408,7 +2408,7 @@ sfc_flow_flush(struct rte_eth_dev *dev, 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; @@ -2454,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 @@ -2464,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); } } @@ -2477,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); } @@ -2491,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; -- 2.20.1