diff mbox

[dpdk-dev,v3,08/18] librte_acl: make scalar RT code to be more similar to vector one.

Message ID 1421779267-18492-9-git-send-email-konstantin.ananyev@intel.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Ananyev, Konstantin Jan. 20, 2015, 6:40 p.m. UTC
Make classify_scalar to behave in the same way as it's vector counterpart:
move match check out of the inner loop, etc.
That makes scalar and vector code look more identical.
Plus it improves scalar code performance.

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
 lib/librte_acl/acl_run_scalar.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)
diff mbox

Patch

diff --git a/lib/librte_acl/acl_run_scalar.c b/lib/librte_acl/acl_run_scalar.c
index 40691ce..9935125 100644
--- a/lib/librte_acl/acl_run_scalar.c
+++ b/lib/librte_acl/acl_run_scalar.c
@@ -162,31 +162,34 @@  rte_acl_classify_scalar(const struct rte_acl_ctx *ctx, const uint8_t **data,
 	transition0 = index_array[0];
 	transition1 = index_array[1];
 
+	while ((transition0 | transition1) & RTE_ACL_NODE_MATCH) {
+		transition0 = acl_match_check(transition0,
+			0, ctx, parms, &flows, resolve_priority_scalar);
+		transition1 = acl_match_check(transition1,
+			1, ctx, parms, &flows, resolve_priority_scalar);
+	}
+
 	while (flows.started > 0) {
 
 		input0 = GET_NEXT_4BYTES(parms, 0);
 		input1 = GET_NEXT_4BYTES(parms, 1);
 
 		for (n = 0; n < 4; n++) {
-			if (likely((transition0 & RTE_ACL_NODE_MATCH) == 0))
-				transition0 = scalar_transition(flows.trans,
-					transition0, (uint8_t)input0);
 
+			transition0 = scalar_transition(flows.trans,
+				transition0, (uint8_t)input0);
 			input0 >>= CHAR_BIT;
 
-			if (likely((transition1 & RTE_ACL_NODE_MATCH) == 0))
-				transition1 = scalar_transition(flows.trans,
-					transition1, (uint8_t)input1);
-
+			transition1 = scalar_transition(flows.trans,
+				transition1, (uint8_t)input1);
 			input1 >>= CHAR_BIT;
-
 		}
-		if ((transition0 | transition1) & RTE_ACL_NODE_MATCH) {
+
+		while ((transition0 | transition1) & RTE_ACL_NODE_MATCH) {
 			transition0 = acl_match_check(transition0,
 				0, ctx, parms, &flows, resolve_priority_scalar);
 			transition1 = acl_match_check(transition1,
 				1, ctx, parms, &flows, resolve_priority_scalar);
-
 		}
 	}
 	return 0;