diff mbox series

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

Message ID 1510164037-14458-10-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [API-NEXT,v7,1/16] linux-gen: ipsec: use counter instead of random IV for GCM | expand

Commit Message

Github ODP bot Nov. 8, 2017, 6 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: d22c949cc466bf28de559855a1cb525740578137
 ** Merge commit sha: b87a669d1d701c336b19a9dd4f07b920a87132ed
 **/
 .../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,