diff mbox series

[API-NEXT,v2,1/6] linux-gen: cls: avoid queue conversions

Message ID 20170704095343.4266-2-petri.savolainen@linaro.org
State Accepted
Commit 1239cc0c12ad2be11d329eebbe4df7fad05b03d7
Headers show
Series Queue interface clean up | expand

Commit Message

Petri Savolainen July 4, 2017, 9:53 a.m. UTC
Use internal queue type instead of API handle. This way per
packet queue conversions are avoided.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
 platform/linux-generic/include/odp_packet_internal.h |  3 ++-
 platform/linux-generic/include/odp_queue_if.h        |  2 ++
 platform/linux-generic/odp_classification.c          | 10 +++++-----
 platform/linux-generic/odp_packet_io.c               |  4 +---
 4 files changed, 10 insertions(+), 9 deletions(-)

-- 
2.13.0
diff mbox series

Patch

diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h
index cdd139bb..d513f05e 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -27,6 +27,7 @@  extern "C" {
 #include <odp/api/crypto.h>
 #include <odp_crypto_internal.h>
 #include <odp/api/plat/packet_types.h>
+#include <odp_queue_if.h>
 
 /** Minimum segment length expected by packet_parse_common() */
 #define PACKET_PARSE_SEG_LEN 96
@@ -126,7 +127,7 @@  typedef struct {
 	odp_time_t timestamp;
 
 	/* Classifier destination queue */
-	odp_queue_t dst_queue;
+	queue_t dst_queue;
 
 	/* Result for crypto */
 	odp_crypto_generic_op_result_t op_result;
diff --git a/platform/linux-generic/include/odp_queue_if.h b/platform/linux-generic/include/odp_queue_if.h
index 168d0e9e..b5cbd515 100644
--- a/platform/linux-generic/include/odp_queue_if.h
+++ b/platform/linux-generic/include/odp_queue_if.h
@@ -48,6 +48,8 @@  typedef struct {
 typedef struct { char dummy; } _queue_t;
 typedef _queue_t *queue_t;
 
+#define QUEUE_NULL ((queue_t)NULL)
+
 typedef int (*queue_init_global_fn_t)(void);
 typedef int (*queue_term_global_fn_t)(void);
 typedef int (*queue_init_local_fn_t)(void);
diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c
index 5f153e73..cc08b9f4 100644
--- a/platform/linux-generic/odp_classification.c
+++ b/platform/linux-generic/odp_classification.c
@@ -162,7 +162,7 @@  odp_cos_t odp_cls_cos_create(const char *name, odp_cls_cos_param_t *param)
 
 	/* Packets are dropped if Queue or Pool is invalid*/
 	if (param->queue == ODP_QUEUE_INVALID)
-		queue = NULL;
+		queue = QUEUE_NULL;
 	else
 		queue = queue_fn->from_ext(param->queue);
 
@@ -264,7 +264,7 @@  int odp_cos_queue_set(odp_cos_t cos_id, odp_queue_t queue_id)
 	/* Locking is not required as intermittent stale
 	data during CoS modification is acceptable*/
 	if (queue_id == ODP_QUEUE_INVALID)
-		cos->s.queue = NULL;
+		cos->s.queue = QUEUE_NULL;
 	else
 		cos->s.queue = queue_fn->from_ext(queue_id);
 	return 0;
@@ -279,7 +279,7 @@  odp_queue_t odp_cos_queue(odp_cos_t cos_id)
 		return ODP_QUEUE_INVALID;
 	}
 
-	if (!cos->s.queue)
+	if (cos->s.queue == QUEUE_NULL)
 		return ODP_QUEUE_INVALID;
 
 	return queue_fn->to_ext(cos->s.queue);
@@ -841,12 +841,12 @@  int cls_classify_packet(pktio_entry_t *entry, const uint8_t *base,
 	if (cos == NULL)
 		return -EINVAL;
 
-	if (cos->s.queue == NULL || cos->s.pool == ODP_POOL_INVALID)
+	if (cos->s.queue == QUEUE_NULL || cos->s.pool == ODP_POOL_INVALID)
 		return -EFAULT;
 
 	*pool = cos->s.pool;
 	pkt_hdr->p.input_flags.dst_queue = 1;
-	pkt_hdr->dst_queue = queue_fn->to_ext(cos->s.queue);
+	pkt_hdr->dst_queue = cos->s.queue;
 
 	return 0;
 }
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index 4dd28549..6ff35046 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -566,11 +566,9 @@  static inline int pktin_recv_buf(odp_pktin_queue_t queue,
 		buf_hdr = packet_to_buf_hdr(pkt);
 
 		if (pkt_hdr->p.input_flags.dst_queue) {
-			queue_t dst_queue;
 			int ret;
 
-			dst_queue = queue_fn->from_ext(pkt_hdr->dst_queue);
-			ret = queue_fn->enq(dst_queue, buf_hdr);
+			ret = queue_fn->enq(pkt_hdr->dst_queue, buf_hdr);
 			if (ret < 0)
 				odp_packet_free(pkt);
 			continue;