[dpdk-dev] [PATCH 4/5] ip_pipeline: update due to api changes in librte_table

Cristian Dumitrescu cristian.dumitrescu at intel.com
Thu Aug 24 15:53:08 CEST 2017


Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu at intel.com>
---
 .../pipeline/pipeline_flow_classification.c        |  9 ++--
 .../pipeline/pipeline_flow_classification_be.c     | 54 ++++------------------
 .../ip_pipeline/pipeline/pipeline_passthrough_be.c | 18 ++++----
 .../ip_pipeline/pipeline/pipeline_routing_be.c     | 18 ++++----
 4 files changed, 33 insertions(+), 66 deletions(-)

diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_classification.c b/examples/ip_pipeline/pipeline/pipeline_flow_classification.c
index 9ef50cc..a8fae1e 100644
--- a/examples/ip_pipeline/pipeline/pipeline_flow_classification.c
+++ b/examples/ip_pipeline/pipeline/pipeline_flow_classification.c
@@ -88,8 +88,11 @@ app_pipeline_fc_key_convert(struct pipeline_fc_key *key_in,
 	uint32_t *signature)
 {
 	uint8_t buffer[PIPELINE_FC_FLOW_KEY_MAX_SIZE];
+	uint8_t m[PIPELINE_FC_FLOW_KEY_MAX_SIZE]; /* key mask */
 	void *key_buffer = (key_out) ? key_out : buffer;
 
+	memset(m, 0xFF, sizeof(m));
+
 	switch (key_in->type) {
 	case FLOW_KEY_QINQ:
 	{
@@ -101,7 +104,7 @@ app_pipeline_fc_key_convert(struct pipeline_fc_key *key_in,
 		qinq->cvlan = rte_cpu_to_be_16(key_in->key.qinq.cvlan);
 
 		if (signature)
-			*signature = (uint32_t) hash_default_key8(qinq, 8, 0);
+			*signature = (uint32_t) hash_default_key8(qinq, m, 8, 0);
 		return 0;
 	}
 
@@ -118,7 +121,7 @@ app_pipeline_fc_key_convert(struct pipeline_fc_key *key_in,
 		ipv4->port_dst = rte_cpu_to_be_16(key_in->key.ipv4_5tuple.port_dst);
 
 		if (signature)
-			*signature = (uint32_t) hash_default_key16(ipv4, 16, 0);
+			*signature = (uint32_t) hash_default_key16(ipv4, m, 16, 0);
 		return 0;
 	}
 
@@ -136,7 +139,7 @@ app_pipeline_fc_key_convert(struct pipeline_fc_key *key_in,
 		ipv6->port_dst = rte_cpu_to_be_16(key_in->key.ipv6_5tuple.port_dst);
 
 		if (signature)
-			*signature = (uint32_t) hash_default_key64(ipv6, 64, 0);
+			*signature = (uint32_t) hash_default_key64(ipv6, m, 64, 0);
 		return 0;
 	}
 
diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c b/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c
index 026f00c..e489957 100644
--- a/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c
+++ b/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c
@@ -492,40 +492,15 @@ static void *pipeline_fc_init(struct pipeline_params *params,
 	/* Tables */
 	p->n_tables = 1;
 	{
-		struct rte_table_hash_key8_ext_params
-			table_hash_key8_params = {
-			.n_entries = p_fc->n_flows,
-			.n_entries_ext = p_fc->n_flows,
-			.signature_offset = p_fc->hash_offset,
-			.key_offset = p_fc->key_offset,
-			.f_hash = hash_func[(p_fc->key_size / 8) - 1],
-			.key_mask = (p_fc->key_mask_present) ?
-				p_fc->key_mask : NULL,
-			.seed = 0,
-		};
-
-		struct rte_table_hash_key16_ext_params
-			table_hash_key16_params = {
-			.n_entries = p_fc->n_flows,
-			.n_entries_ext = p_fc->n_flows,
-			.signature_offset = p_fc->hash_offset,
-			.key_offset = p_fc->key_offset,
-			.f_hash = hash_func[(p_fc->key_size / 8) - 1],
-			.key_mask = (p_fc->key_mask_present) ?
-				p_fc->key_mask : NULL,
-			.seed = 0,
-		};
-
-		struct rte_table_hash_ext_params
-			table_hash_params = {
+		struct rte_table_hash_params table_hash_params = {
+			.name = p->name,
 			.key_size = p_fc->key_size,
+			.key_offset = p_fc->key_offset,
+			.key_mask = (p_fc->key_mask_present)? p_fc->key_mask : NULL,
 			.n_keys = p_fc->n_flows,
 			.n_buckets = p_fc->n_flows / 4,
-			.n_buckets_ext = p_fc->n_flows / 4,
 			.f_hash = hash_func[(p_fc->key_size / 8) - 1],
 			.seed = 0,
-			.signature_offset = p_fc->hash_offset,
-			.key_offset = p_fc->key_offset,
 		};
 
 		struct rte_pipeline_table_params table_params = {
@@ -542,32 +517,19 @@ static void *pipeline_fc_init(struct pipeline_params *params,
 
 		switch (p_fc->key_size) {
 		case 8:
-			if (p_fc->hash_offset != 0) {
-				table_params.ops =
-					&rte_table_hash_key8_ext_ops;
-			} else {
-				table_params.ops =
-					&rte_table_hash_key8_ext_dosig_ops;
-			}
-			table_params.arg_create = &table_hash_key8_params;
+			table_params.ops = &rte_table_hash_key8_ext_ops;
 			break;
 
 		case 16:
-			if (p_fc->hash_offset != 0) {
-				table_params.ops =
-					&rte_table_hash_key16_ext_ops;
-			} else {
-				table_params.ops =
-					&rte_table_hash_key16_ext_dosig_ops;
-			}
-			table_params.arg_create = &table_hash_key16_params;
+			table_params.ops = &rte_table_hash_key16_ext_ops;
 			break;
 
 		default:
 			table_params.ops = &rte_table_hash_ext_ops;
-			table_params.arg_create = &table_hash_params;
 		}
 
+		table_params.arg_create = &table_hash_params;
+
 		status = rte_pipeline_table_create(p->p,
 			&table_params,
 			&p->table_id[0]);
diff --git a/examples/ip_pipeline/pipeline/pipeline_passthrough_be.c b/examples/ip_pipeline/pipeline/pipeline_passthrough_be.c
index 8cb2f0c..2500332 100644
--- a/examples/ip_pipeline/pipeline/pipeline_passthrough_be.c
+++ b/examples/ip_pipeline/pipeline/pipeline_passthrough_be.c
@@ -76,7 +76,7 @@ static pipeline_msg_req_handler handlers[] = {
 		pipeline_msg_req_invalid_handler,
 };
 
-static __rte_always_inline void
+static inline __attribute__((always_inline)) void
 pkt_work_dma(
 	struct rte_mbuf *pkt,
 	void *arg,
@@ -102,7 +102,7 @@ pkt_work_dma(
 
 	/* Read (dma_dst), compute (hash), write (hash) */
 	if (hash_enabled) {
-		uint32_t hash = p->f_hash(dma_dst, dma_size, 0);
+		uint32_t hash = p->f_hash(dma_src, dma_mask, dma_size, 0);
 		*dma_hash = hash;
 
 		if (lb_hash) {
@@ -121,7 +121,7 @@ pkt_work_dma(
 	}
 }
 
-static __rte_always_inline void
+static inline __attribute__((always_inline)) void
 pkt4_work_dma(
 	struct rte_mbuf **pkts,
 	void *arg,
@@ -173,10 +173,10 @@ pkt4_work_dma(
 
 	/* Read (dma_dst), compute (hash), write (hash) */
 	if (hash_enabled) {
-		uint32_t hash0 = p->f_hash(dma_dst0, dma_size, 0);
-		uint32_t hash1 = p->f_hash(dma_dst1, dma_size, 0);
-		uint32_t hash2 = p->f_hash(dma_dst2, dma_size, 0);
-		uint32_t hash3 = p->f_hash(dma_dst3, dma_size, 0);
+		uint32_t hash0 = p->f_hash(dma_src0, dma_mask, dma_size, 0);
+		uint32_t hash1 = p->f_hash(dma_src1, dma_mask, dma_size, 0);
+		uint32_t hash2 = p->f_hash(dma_src2, dma_mask, dma_size, 0);
+		uint32_t hash3 = p->f_hash(dma_src3, dma_mask, dma_size, 0);
 
 		*dma_hash0 = hash0;
 		*dma_hash1 = hash1;
@@ -217,7 +217,7 @@ pkt4_work_dma(
 	}
 }
 
-static __rte_always_inline void
+static inline __attribute__((always_inline)) void
 pkt_work_swap(
 	struct rte_mbuf *pkt,
 	void *arg)
@@ -241,7 +241,7 @@ pkt_work_swap(
 	}
 }
 
-static __rte_always_inline void
+static inline __attribute__((always_inline)) void
 pkt4_work_swap(
 	struct rte_mbuf **pkts,
 	void *arg)
diff --git a/examples/ip_pipeline/pipeline/pipeline_routing_be.c b/examples/ip_pipeline/pipeline/pipeline_routing_be.c
index 7831716..d281e65 100644
--- a/examples/ip_pipeline/pipeline/pipeline_routing_be.c
+++ b/examples/ip_pipeline/pipeline/pipeline_routing_be.c
@@ -191,7 +191,7 @@ struct layout {
 	dst->c = src->c;					\
 }
 
-static __rte_always_inline void
+static inline __attribute__((always_inline)) void
 pkt_work_routing(
 	struct rte_mbuf *pkt,
 	struct rte_pipeline_table_entry *table_entry,
@@ -317,7 +317,7 @@ pkt_work_routing(
 	}
 }
 
-static __rte_always_inline void
+static inline __attribute__((always_inline)) void
 pkt4_work_routing(
 	struct rte_mbuf **pkts,
 	struct rte_pipeline_table_entry **table_entries,
@@ -1349,17 +1349,19 @@ pipeline_routing_init(struct pipeline_params *params,
 
 	/* ARP table configuration */
 	if (p_rt->params.n_arp_entries) {
-		struct rte_table_hash_key8_ext_params table_arp_params = {
-			.n_entries = p_rt->params.n_arp_entries,
-			.n_entries_ext = p_rt->params.n_arp_entries,
+		struct rte_table_hash_params table_arp_params = {
+			.name = p->name,
+			.key_size = 8,
+			.key_offset = p_rt->params.arp_key_offset,
+			.key_mask = NULL,
+			.n_keys = p_rt->params.n_arp_entries,
+			.n_buckets = p_rt->params.n_arp_entries / 4,
 			.f_hash = hash_default_key8,
 			.seed = 0,
-			.signature_offset = 0, /* Unused */
-			.key_offset = p_rt->params.arp_key_offset,
 		};
 
 		struct rte_pipeline_table_params table_params = {
-			.ops = &rte_table_hash_key8_ext_dosig_ops,
+			.ops = &rte_table_hash_key8_ext_ops,
 			.arg_create = &table_arp_params,
 			.f_action_hit = get_arp_table_ah_hit(p_rt),
 			.f_action_miss = NULL,
-- 
2.7.4



More information about the dev mailing list