[v1,2/3] linux-gen: cls: fix single queue bugs

Message ID 1518703206-19713-3-git-send-email-odpbot@yandex.ru
State New
Headers show
Series
  • Add missing validation tests
Related show

Commit Message

Github ODP bot Feb. 15, 2018, 2 p.m.
From: Petri Savolainen <petri.savolainen@linaro.org>


odp_cls_cos_num_queue() and odp_cls_cos_queues() returned 0
for single queue CoS.

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

---
/** Email created from pull request 484 (psavol:master-missing-validation)
 ** https://github.com/Linaro/odp/pull/484
 ** Patch: https://github.com/Linaro/odp/pull/484.patch
 ** Base sha: 41b3fa2cd994a7ef68290a07dcde5564e4640847
 ** Merge commit sha: 595ea205e4c4680f6a9a674fbe637dcab24b038e
 **/
 platform/linux-generic/odp_classification.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

Patch

diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c
index f22dd091c..ceef1fc13 100644
--- a/platform/linux-generic/odp_classification.c
+++ b/platform/linux-generic/odp_classification.c
@@ -250,11 +250,12 @@  odp_cos_t odp_cls_cos_create(const char *name, odp_cls_cos_param_t *param)
 				cos->s.linked_cos[j] = NULL;
 			}
 
+			cos->s.num_queue = param->num_queue;
+
 			if (param->num_queue > 1) {
 				odp_queue_param_init(&cos->s.queue_param);
 				cos->s.queue_group = true;
 				cos->s.queue = ODP_QUEUE_INVALID;
-				cos->s.num_queue = param->num_queue;
 				_odp_cls_update_hash_proto(cos,
 							   param->hash_proto);
 				tbl_index = i * CLS_COS_QUEUE_MAX;
@@ -358,6 +359,12 @@  int odp_cos_queue_set(odp_cos_t cos_id, odp_queue_t queue_id)
 		ODP_ERR("Invalid odp_cos_t handle");
 		return -1;
 	}
+
+	if (cos->s.num_queue != 1) {
+		ODP_ERR("Hashing enabled, cannot set queue");
+		return -1;
+	}
+
 	/* Locking is not required as intermittent stale
 	data during CoS modification is acceptable*/
 	cos->s.queue = queue_id;
@@ -402,6 +409,14 @@  uint32_t odp_cls_cos_queues(odp_cos_t cos_id, odp_queue_t queue[],
 		return 0;
 	}
 
+	if (cos->s.num_queue == 1) {
+		if (num == 0)
+			return 1;
+
+		queue[0] = cos->s.queue;
+		return 1;
+	}
+
 	if (num < cos->s.num_queue)
 		num_queues = num;
 	else