[dpdk-dev] [PATCH 3/5] net/mlx5: switch encap rules to use container

Viacheslav Ovsiienko viacheslavo at mellanox.com
Sat Dec 29 20:55:38 CET 2018


The VXLAN encapsulation neigh/local rules will use
the new introduced structure, which keeps the
rules lists, related to specified outer interface,
instead of attached VTEP structure. It allows us to
unbind VTEP structure from keeping the rules for
interface.

Signed-off-by: Viacheslav Ovsiienko <viacheslavo at mellanox.com>
---
 drivers/net/mlx5/mlx5_flow_tcf.c | 42 ++++++++++++++++++++--------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_tcf.c b/drivers/net/mlx5/mlx5_flow_tcf.c
index a6dca08..b99e322 100644
--- a/drivers/net/mlx5/mlx5_flow_tcf.c
+++ b/drivers/net/mlx5/mlx5_flow_tcf.c
@@ -4771,8 +4771,8 @@ struct tcf_nlcb_context {
  *
  * @param[in] tcf
  *   Libmnl socket context object.
- * @param[in] vtep
- *   VTEP object, contains rule database and ifouter index.
+ * @param[in] iface
+ *   Object, contains rule database and ifouter index.
  * @param[in] dev_flow
  *   Flow object, contains the tunnel parameters (for encap only).
  * @param[in] enable
@@ -4785,7 +4785,7 @@ struct tcf_nlcb_context {
  */
 static int
 flow_tcf_encap_local(struct mlx5_flow_tcf_context *tcf,
-		     struct tcf_vtep *vtep,
+		     struct tcf_irule *iface,
 		     struct mlx5_flow *dev_flow,
 		     bool enable,
 		     struct rte_flow_error *error)
@@ -4798,7 +4798,7 @@ struct tcf_nlcb_context {
 	assert(encap->hdr.type == FLOW_TCF_TUNACT_VXLAN_ENCAP);
 	if (encap->mask & FLOW_TCF_ENCAP_IPV4_SRC) {
 		assert(encap->mask & FLOW_TCF_ENCAP_IPV4_DST);
-		LIST_FOREACH(rule, &vtep->local, next) {
+		LIST_FOREACH(rule, &iface->local, next) {
 			if (rule->mask & FLOW_TCF_ENCAP_IPV4_SRC &&
 			    encap->ipv4.src == rule->ipv4.src &&
 			    encap->ipv4.dst == rule->ipv4.dst) {
@@ -4808,7 +4808,7 @@ struct tcf_nlcb_context {
 	} else {
 		assert(encap->mask & FLOW_TCF_ENCAP_IPV6_SRC);
 		assert(encap->mask & FLOW_TCF_ENCAP_IPV6_DST);
-		LIST_FOREACH(rule, &vtep->local, next) {
+		LIST_FOREACH(rule, &iface->local, next) {
 			if (rule->mask & FLOW_TCF_ENCAP_IPV6_SRC &&
 			    !memcmp(&encap->ipv6.src, &rule->ipv6.src,
 					    sizeof(encap->ipv6.src)) &&
@@ -4826,7 +4826,7 @@ struct tcf_nlcb_context {
 		if (!rule->refcnt || !--rule->refcnt) {
 			LIST_REMOVE(rule, next);
 			return flow_tcf_rule_local(tcf, encap,
-					vtep->ifouter, false, error);
+					iface->ifouter, false, error);
 		}
 		return 0;
 	}
@@ -4859,13 +4859,13 @@ struct tcf_nlcb_context {
 		memcpy(&rule->ipv6.src, &encap->ipv6.src, IPV6_ADDR_LEN);
 		memcpy(&rule->ipv6.dst, &encap->ipv6.dst, IPV6_ADDR_LEN);
 	}
-	ret = flow_tcf_rule_local(tcf, encap, vtep->ifouter, true, error);
+	ret = flow_tcf_rule_local(tcf, encap, iface->ifouter, true, error);
 	if (ret) {
 		rte_free(rule);
 		return ret;
 	}
 	rule->refcnt++;
-	LIST_INSERT_HEAD(&vtep->local, rule, next);
+	LIST_INSERT_HEAD(&iface->local, rule, next);
 	return 0;
 }
 
@@ -4877,8 +4877,8 @@ struct tcf_nlcb_context {
  *
  * @param[in] tcf
  *   Libmnl socket context object.
- * @param[in] vtep
- *   VTEP object, contains rule database and ifouter index.
+ * @param[in] iface
+ *   Object, contains rule database and ifouter index.
  * @param[in] dev_flow
  *   Flow object, contains the tunnel parameters (for encap only).
  * @param[in] enable
@@ -4891,7 +4891,7 @@ struct tcf_nlcb_context {
  */
 static int
 flow_tcf_encap_neigh(struct mlx5_flow_tcf_context *tcf,
-		     struct tcf_vtep *vtep,
+		     struct tcf_irule *iface,
 		     struct mlx5_flow *dev_flow,
 		     bool enable,
 		     struct rte_flow_error *error)
@@ -4904,7 +4904,7 @@ struct tcf_nlcb_context {
 	assert(encap->hdr.type == FLOW_TCF_TUNACT_VXLAN_ENCAP);
 	if (encap->mask & FLOW_TCF_ENCAP_IPV4_DST) {
 		assert(encap->mask & FLOW_TCF_ENCAP_IPV4_SRC);
-		LIST_FOREACH(rule, &vtep->neigh, next) {
+		LIST_FOREACH(rule, &iface->neigh, next) {
 			if (rule->mask & FLOW_TCF_ENCAP_IPV4_DST &&
 			    encap->ipv4.dst == rule->ipv4.dst) {
 				break;
@@ -4913,7 +4913,7 @@ struct tcf_nlcb_context {
 	} else {
 		assert(encap->mask & FLOW_TCF_ENCAP_IPV6_SRC);
 		assert(encap->mask & FLOW_TCF_ENCAP_IPV6_DST);
-		LIST_FOREACH(rule, &vtep->neigh, next) {
+		LIST_FOREACH(rule, &iface->neigh, next) {
 			if (rule->mask & FLOW_TCF_ENCAP_IPV6_DST &&
 			    !memcmp(&encap->ipv6.dst, &rule->ipv6.dst,
 						sizeof(encap->ipv6.dst))) {
@@ -4940,7 +4940,7 @@ struct tcf_nlcb_context {
 		if (!rule->refcnt || !--rule->refcnt) {
 			LIST_REMOVE(rule, next);
 			return flow_tcf_rule_neigh(tcf, encap,
-						   vtep->ifouter,
+						   iface->ifouter,
 						   false, error);
 		}
 		return 0;
@@ -4971,13 +4971,13 @@ struct tcf_nlcb_context {
 		memcpy(&rule->ipv6.dst, &encap->ipv6.dst, IPV6_ADDR_LEN);
 	}
 	memcpy(&rule->eth, &encap->eth.dst, sizeof(rule->eth));
-	ret = flow_tcf_rule_neigh(tcf, encap, vtep->ifouter, true, error);
+	ret = flow_tcf_rule_neigh(tcf, encap, iface->ifouter, true, error);
 	if (ret) {
 		rte_free(rule);
 		return ret;
 	}
 	rule->refcnt++;
-	LIST_INSERT_HEAD(&vtep->neigh, rule, next);
+	LIST_INSERT_HEAD(&iface->neigh, rule, next);
 	return 0;
 }
 
@@ -5394,12 +5394,12 @@ struct tcf_nlcb_context {
 	}
 	dev_flow->tcf.vxlan_encap->iface = iface;
 	/* Create local ipaddr with peer to specify the outer IPs. */
-	ret = flow_tcf_encap_local(tcf, vtep, dev_flow, true, error);
+	ret = flow_tcf_encap_local(tcf, iface, dev_flow, true, error);
 	if (!ret) {
 		/* Create neigh rule to specify outer destination MAC. */
-		ret = flow_tcf_encap_neigh(tcf, vtep, dev_flow, true, error);
+		ret = flow_tcf_encap_neigh(tcf, iface, dev_flow, true, error);
 		if (ret)
-			flow_tcf_encap_local(tcf, vtep,
+			flow_tcf_encap_local(tcf, iface,
 					     dev_flow, false, error);
 	}
 	if (ret) {
@@ -5483,8 +5483,8 @@ struct tcf_nlcb_context {
 		/* Remove the encap ancillary rules first. */
 		iface = dev_flow->tcf.vxlan_encap->iface;
 		assert(iface);
-		flow_tcf_encap_neigh(tcf, vtep, dev_flow, false, NULL);
-		flow_tcf_encap_local(tcf, vtep, dev_flow, false, NULL);
+		flow_tcf_encap_neigh(tcf, iface, dev_flow, false, NULL);
+		flow_tcf_encap_local(tcf, iface, dev_flow, false, NULL);
 		flow_tcf_encap_irule_release(iface);
 		dev_flow->tcf.vxlan_encap->iface = NULL;
 		break;
-- 
1.8.3.1



More information about the dev mailing list