diff mbox series

[API-NEXT,v13,9/18] linux-gen: classification: split cls_pkt_get_queue() function

Message ID 1510527615-30536-10-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v13,1/18] linux-gen: ipsec: use counter instead of random IV for GCM | expand

Commit Message

Github ODP bot Nov. 12, 2017, 11 p.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Separate function returning destination queue from cos_t instance.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 243 (lumag:ipsec-packet-impl-3)
 ** https://github.com/Linaro/odp/pull/243
 ** Patch: https://github.com/Linaro/odp/pull/243.patch
 ** Base sha: a908a4dead95321e84d6a8a23de060051dcd8969
 ** Merge commit sha: 7261a0ce35cc31342937cb57dcc287aea0c59ede
 **/
 .../include/odp_classification_internal.h          |  7 +++++
 platform/linux-generic/odp_classification.c        | 34 ++++++++++++++++------
 2 files changed, 32 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/platform/linux-generic/include/odp_classification_internal.h b/platform/linux-generic/include/odp_classification_internal.h
index 8882a7177..4cadb9bdb 100644
--- a/platform/linux-generic/include/odp_classification_internal.h
+++ b/platform/linux-generic/include/odp_classification_internal.h
@@ -42,6 +42,13 @@  int cls_classify_packet(pktio_entry_t *entry, const uint8_t *base,
 			odp_packet_hdr_t *pkt_hdr);
 
 /**
+ * @internal
+ * Select packet destination queue basing on provided cos entry
+ */
+odp_queue_t cls_pkt_get_queue(odp_packet_hdr_t *pkt_hdr, cos_t *cos,
+			      const uint8_t *base);
+
+/**
 Packet IO classifier init
 
 This function does initialization of classifier object associated with pktio.
diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c
index 6ece74fca..317caefbf 100644
--- a/platform/linux-generic/odp_classification.c
+++ b/platform/linux-generic/odp_classification.c
@@ -961,8 +961,7 @@  int cls_classify_packet(pktio_entry_t *entry, const uint8_t *base,
 			odp_packet_hdr_t *pkt_hdr)
 {
 	cos_t *cos;
-	uint32_t tbl_index;
-	uint32_t hash;
+	odp_queue_t queue;
 
 	packet_parse_reset(pkt_hdr);
 	packet_set_len(pkt_hdr, pkt_len);
@@ -979,20 +978,37 @@  int cls_classify_packet(pktio_entry_t *entry, const uint8_t *base,
 		return -EFAULT;
 
 	*pool = cos->s.pool;
+
 	pkt_hdr->p.input_flags.dst_queue = 1;
 
-	if (!cos->s.queue_group) {
-		pkt_hdr->dst_queue = queue_fn->from_ext(cos->s.queue);
-		return 0;
-	}
+	queue = cls_pkt_get_queue(pkt_hdr, cos, base);
+	pkt_hdr->dst_queue = queue_fn->from_ext(queue);
+
+	return 0;
+}
+
+/**
+ * Set packet destination queue basing on the cos
+ *
+ * @param cos
+ * @param pkt_hdr	Packet header
+ * @param base		Packet data
+ */
+odp_queue_t cls_pkt_get_queue(odp_packet_hdr_t *pkt_hdr, cos_t *cos,
+			      const uint8_t *base)
+{
+	uint32_t tbl_index;
+	uint32_t hash;
+
+	if (!cos->s.queue_group)
+		return cos->s.queue;
 
 	hash = packet_rss_hash(pkt_hdr, cos->s.hash_proto, base);
 	/* CLS_COS_QUEUE_MAX is a power of 2 */
 	hash = hash & (CLS_COS_QUEUE_MAX - 1);
 	tbl_index = (cos->s.index * CLS_COS_QUEUE_MAX) + hash;
-	pkt_hdr->dst_queue = queue_fn->from_ext(queue_grp_tbl->
-						s.queue[tbl_index]);
-	return 0;
+
+	return queue_grp_tbl->s.queue[tbl_index];
 }
 
 static uint32_t packet_rss_hash(odp_packet_hdr_t *pkt_hdr,