From: Vivian Kong <vivkong@gmail.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [RFC 03/12] acl: add support for s390x architecture
Date: Tue, 9 Apr 2019 15:06:21 -0400 [thread overview]
Message-ID: <20190409190630.31975-4-vivkong@ca.ibm.com> (raw)
Message-ID: <20190409190621.dIm4Euk1tfbRIXR-bPw_nKVA87qC0VIGutDfdPtnBGc@z> (raw)
In-Reply-To: <20190409190630.31975-1-vivkong@ca.ibm.com>
Add big endian support for s390x architecture.
Signed-off-by: Vivian Kong <vivkong@ca.ibm.com>
---
app/test-acl/main.c | 4 ++
lib/librte_acl/Makefile | 2 +
lib/librte_acl/acl_bld.c | 69 +++++++++++++++++++++++++++------
lib/librte_acl/acl_gen.c | 9 +++++
lib/librte_acl/acl_run_scalar.c | 8 ++++
lib/librte_acl/rte_acl.c | 4 ++
lib/librte_acl/rte_acl.h | 1 +
7 files changed, 85 insertions(+), 12 deletions(-)
diff --git a/app/test-acl/main.c b/app/test-acl/main.c
index b80179417..b6c5c9abd 100644
--- a/app/test-acl/main.c
+++ b/app/test-acl/main.c
@@ -81,6 +81,10 @@ static const struct acl_alg acl_alg[] = {
.name = "altivec",
.alg = RTE_ACL_CLASSIFY_ALTIVEC,
},
+ {
+ .name = "s390x",
+ .alg = RTE_ACL_CLASSIFY_S390X,
+ },
};
static struct {
diff --git a/lib/librte_acl/Makefile b/lib/librte_acl/Makefile
index ea5edf00a..f87693d1e 100644
--- a/lib/librte_acl/Makefile
+++ b/lib/librte_acl/Makefile
@@ -30,6 +30,8 @@ CFLAGS_acl_run_neon.o += -Wno-maybe-uninitialized
endif
else ifeq ($(CONFIG_RTE_ARCH_PPC_64),y)
SRCS-$(CONFIG_RTE_LIBRTE_ACL) += acl_run_altivec.c
+else ifeq ($(CONFIG_RTE_ARCH_S390X),y)
+SRCS-$(CONFIG_RTE_LIBRTE_ACL) +=
else
SRCS-$(CONFIG_RTE_LIBRTE_ACL) += acl_run_sse.c
endif
diff --git a/lib/librte_acl/acl_bld.c b/lib/librte_acl/acl_bld.c
index b82191f42..16bf09304 100644
--- a/lib/librte_acl/acl_bld.c
+++ b/lib/librte_acl/acl_bld.c
@@ -777,6 +777,16 @@ acl_build_reset(struct rte_acl_ctx *ctx)
sizeof(*ctx) - offsetof(struct rte_acl_ctx, num_categories));
}
+static uint32_t get_le_byte_index(uint32_t index, int size)
+{
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+ (void) size;
+ return index;
+#else
+ return size - 1 - index;
+#endif
+}
+
static void
acl_gen_range(struct acl_build_context *context,
const uint8_t *hi, const uint8_t *lo, int size, int level,
@@ -786,12 +796,19 @@ acl_gen_range(struct acl_build_context *context,
uint32_t n;
prev = root;
+
+ /* On big endian min and max point to highest byte.
+ * Therefore iterate in opposite direction as on
+ * little endian with helper function.
+ */
for (n = size - 1; n > 0; n--) {
+ uint32_t le_idx = get_le_byte_index(n, size);
node = acl_alloc_node(context, level++);
- acl_add_ptr_range(context, prev, node, lo[n], hi[n]);
+ acl_add_ptr_range(context, prev, node, lo[le_idx], hi[le_idx]);
prev = node;
}
- acl_add_ptr_range(context, prev, end, lo[0], hi[0]);
+ const uint32_t first_idx = get_le_byte_index(0, size);
+ acl_add_ptr_range(context, prev, end, lo[first_idx], hi[first_idx]);
}
static struct rte_acl_node *
@@ -804,10 +821,16 @@ acl_gen_range_trie(struct acl_build_context *context,
const uint8_t *lo = min;
const uint8_t *hi = max;
+ /* On big endian min and max point to highest byte.
+ * Therefore iterate in opposite direction as on
+ * little endian.
+ */
+ const int byte_index = get_le_byte_index(size-1, size);
+
*pend = acl_alloc_node(context, level+size);
root = acl_alloc_node(context, level++);
- if (lo[size - 1] == hi[size - 1]) {
+ if (lo[byte_index] == hi[byte_index]) {
acl_gen_range(context, hi, lo, size, level, root, *pend);
} else {
uint8_t limit_lo[64];
@@ -819,27 +842,29 @@ acl_gen_range_trie(struct acl_build_context *context,
memset(limit_hi, UINT8_MAX, RTE_DIM(limit_hi));
for (n = size - 2; n >= 0; n--) {
- hi_ff = (uint8_t)(hi_ff & hi[n]);
- lo_00 = (uint8_t)(lo_00 | lo[n]);
+ const uint32_t le_idx = get_le_byte_index(n, size);
+ hi_ff = (uint8_t)(hi_ff & hi[le_idx]);
+ lo_00 = (uint8_t)(lo_00 | lo[le_idx]);
}
if (hi_ff != UINT8_MAX) {
- limit_lo[size - 1] = hi[size - 1];
+ limit_lo[byte_index] = hi[byte_index];
acl_gen_range(context, hi, limit_lo, size, level,
root, *pend);
}
if (lo_00 != 0) {
- limit_hi[size - 1] = lo[size - 1];
+ limit_hi[byte_index] = lo[byte_index];
acl_gen_range(context, limit_hi, lo, size, level,
root, *pend);
}
- if (hi[size - 1] - lo[size - 1] > 1 ||
+ if (hi[byte_index] - lo[byte_index] > 1 ||
lo_00 == 0 ||
hi_ff == UINT8_MAX) {
- limit_lo[size-1] = (uint8_t)(lo[size-1] + (lo_00 != 0));
- limit_hi[size-1] = (uint8_t)(hi[size-1] -
+ limit_lo[byte_index] = (uint8_t)(lo[byte_index] +
+ (lo_00 != 0));
+ limit_hi[byte_index] = (uint8_t)(hi[byte_index] -
(hi_ff != UINT8_MAX));
acl_gen_range(context, limit_hi, limit_lo, size,
level, root, *pend);
@@ -863,13 +888,17 @@ acl_gen_mask_trie(struct acl_build_context *context,
root = acl_alloc_node(context, level++);
prev = root;
+ /* On big endian val and msk point to highest byte.
+ * Therefore iterate in opposite direction as on
+ * little endian with helper function
+ */
for (n = size - 1; n >= 0; n--) {
+ uint32_t le_idx = get_le_byte_index(n, size);
node = acl_alloc_node(context, level++);
- acl_gen_mask(&bits, val[n] & msk[n], msk[n]);
+ acl_gen_mask(&bits, val[le_idx] & msk[le_idx], msk[le_idx]);
acl_add_ptr(context, prev, node, &bits);
prev = node;
}
-
*pend = prev;
return root;
}
@@ -927,6 +956,14 @@ build_trie(struct acl_build_context *context, struct rte_acl_build_rule *head,
fld->mask_range.u32,
rule->config->defs[n].size);
+ /* Fields are aligned highest to lowest bit.
+ * Masked needs to be shifted to follow same
+ * convention
+ */
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ mask = mask << 32;
+#endif
+
/* gen a mini-trie for this field */
merge = acl_gen_mask_trie(context,
&fld->value,
@@ -1017,6 +1054,14 @@ acl_calc_wildness(struct rte_acl_build_rule *head,
uint32_t bit_len = CHAR_BIT * config->defs[n].size;
uint64_t msk_val = RTE_LEN2MASK(bit_len,
typeof(msk_val));
+
+ /* Fields are aligned highest to lowest bit.
+ * Masked needs to be shifted to follow same
+ * convention
+ */
+ if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
+ msk_val <<= 32;
+
double size = bit_len;
int field_index = config->defs[n].field_index;
const struct rte_acl_field *fld = rule->f->field +
diff --git a/lib/librte_acl/acl_gen.c b/lib/librte_acl/acl_gen.c
index 35a0140b4..b4e8df0ce 100644
--- a/lib/librte_acl/acl_gen.c
+++ b/lib/librte_acl/acl_gen.c
@@ -360,7 +360,16 @@ acl_gen_node(struct rte_acl_node *node, uint64_t *node_array,
array_ptr = &node_array[index->quad_index];
acl_add_ptrs(node, array_ptr, no_match, 0);
qtrp = (uint32_t *)node->transitions;
+
+ /* Swap qtrp on big endian that transitions[0]
+ * is at least signifcant byte.
+ */
+#if __BYTE_ORDER == __ORDER_BIG_ENDIAN__
+ node->node_index = __bswap_32(qtrp[0]);
+#else
node->node_index = qtrp[0];
+#endif
+
node->node_index <<= sizeof(index->quad_index) * CHAR_BIT;
node->node_index |= index->quad_index | node->node_type;
index->quad_index += node->fanout;
diff --git a/lib/librte_acl/acl_run_scalar.c b/lib/librte_acl/acl_run_scalar.c
index 3d61e7940..9f01ef8d8 100644
--- a/lib/librte_acl/acl_run_scalar.c
+++ b/lib/librte_acl/acl_run_scalar.c
@@ -141,6 +141,14 @@ rte_acl_classify_scalar(const struct rte_acl_ctx *ctx, const uint8_t **data,
input0 = GET_NEXT_4BYTES(parms, 0);
input1 = GET_NEXT_4BYTES(parms, 1);
+ /* input needs to be swapped because the rules get
+ * swapped while building the trie.
+ */
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ input0 = __bswap_32(input0);
+ input1 = __bswap_32(input1);
+#endif
+
for (n = 0; n < 4; n++) {
transition0 = scalar_transition(flows.trans,
diff --git a/lib/librte_acl/rte_acl.c b/lib/librte_acl/rte_acl.c
index c436a9bfd..6d4d3f239 100644
--- a/lib/librte_acl/rte_acl.c
+++ b/lib/librte_acl/rte_acl.c
@@ -64,6 +64,8 @@ static const rte_acl_classify_t classify_fns[] = {
[RTE_ACL_CLASSIFY_AVX2] = rte_acl_classify_avx2,
[RTE_ACL_CLASSIFY_NEON] = rte_acl_classify_neon,
[RTE_ACL_CLASSIFY_ALTIVEC] = rte_acl_classify_altivec,
+ /* use scalar for s390x for now */
+ [RTE_ACL_CLASSIFY_S390X] = rte_acl_classify_scalar,
};
/* by default, use always available scalar code path. */
@@ -103,6 +105,8 @@ RTE_INIT(rte_acl_init)
alg = RTE_ACL_CLASSIFY_NEON;
#elif defined(RTE_ARCH_PPC_64)
alg = RTE_ACL_CLASSIFY_ALTIVEC;
+#elif defined(RTE_ARCH_S390X)
+ alg = RTE_ACL_CLASSIFY_S390X;
#else
#ifdef CC_AVX2_SUPPORT
if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2))
diff --git a/lib/librte_acl/rte_acl.h b/lib/librte_acl/rte_acl.h
index aa22e70c6..9537196db 100644
--- a/lib/librte_acl/rte_acl.h
+++ b/lib/librte_acl/rte_acl.h
@@ -241,6 +241,7 @@ enum rte_acl_classify_alg {
RTE_ACL_CLASSIFY_AVX2 = 3, /**< requires AVX2 support. */
RTE_ACL_CLASSIFY_NEON = 4, /**< requires NEON support. */
RTE_ACL_CLASSIFY_ALTIVEC = 5, /**< requires ALTIVEC support. */
+ RTE_ACL_CLASSIFY_S390X = 6, /**< requires s390x z13 support. */
RTE_ACL_CLASSIFY_NUM /* should always be the last one. */
};
--
2.17.1
next prev parent reply other threads:[~2019-04-09 19:07 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-09 19:06 [dpdk-dev] [RFC 00/12] introduce " Vivian Kong
2019-04-09 19:06 ` Vivian Kong
2019-04-09 19:06 ` [dpdk-dev] [RFC 01/12] mk: " Vivian Kong
2019-04-09 19:06 ` Vivian Kong
2019-04-09 19:38 ` Luca Boccassi
2019-04-09 19:38 ` Luca Boccassi
2019-04-10 16:50 ` Vivian Kong
2019-04-10 16:50 ` Vivian Kong
2019-04-09 19:06 ` [dpdk-dev] [RFC 02/12] eal: add support for " Vivian Kong
2019-04-09 19:06 ` Vivian Kong
2019-04-09 19:06 ` Vivian Kong [this message]
2019-04-09 19:06 ` [dpdk-dev] [RFC 03/12] acl: " Vivian Kong
2019-04-09 19:06 ` [dpdk-dev] [RFC 04/12] lpm: " Vivian Kong
2019-04-09 19:06 ` Vivian Kong
2019-04-09 19:06 ` [dpdk-dev] [RFC 05/12] examples/l3fwd: " Vivian Kong
2019-04-09 19:06 ` Vivian Kong
2019-04-09 19:06 ` [dpdk-dev] [RFC 06/12] net/i40e: " Vivian Kong
2019-04-09 19:06 ` Vivian Kong
2019-04-09 19:06 ` [dpdk-dev] [RFC 07/12] test: " Vivian Kong
2019-04-09 19:06 ` Vivian Kong
2019-04-09 19:06 ` [dpdk-dev] [RFC 08/12] hash: " Vivian Kong
2019-04-09 19:06 ` Vivian Kong
2019-04-15 20:43 ` Dharmik Thakkar
2019-04-15 20:43 ` Dharmik Thakkar
2019-04-09 19:06 ` [dpdk-dev] [RFC 09/12] doc: introduce " Vivian Kong
2019-04-09 19:06 ` Vivian Kong
2019-04-09 20:12 ` Thomas Monjalon
2019-04-09 20:12 ` Thomas Monjalon
2019-04-10 16:52 ` Vivian Kong
2019-04-10 16:52 ` Vivian Kong
2019-04-09 19:06 ` [dpdk-dev] [RFC 10/12] ethdev: add cast for bus_device Vivian Kong
2019-04-09 19:06 ` Vivian Kong
2019-04-09 20:14 ` Thomas Monjalon
2019-04-09 20:14 ` Thomas Monjalon
2019-04-10 2:41 ` Stephen Hemminger
2019-04-10 2:41 ` Stephen Hemminger
2019-04-10 17:10 ` Vivian Kong
2019-04-10 17:10 ` Vivian Kong
2019-04-09 19:06 ` [dpdk-dev] [RFC 11/12] mbuf: trivial fix Vivian Kong
2019-04-09 19:06 ` Vivian Kong
2019-04-09 20:13 ` Thomas Monjalon
2019-04-09 20:13 ` Thomas Monjalon
2019-04-09 19:06 ` [dpdk-dev] [RFC 12/12] test: miscellaneous test fixes Vivian Kong
2019-04-09 19:06 ` Vivian Kong
2019-04-09 20:25 ` [dpdk-dev] [RFC 00/12] introduce s390x architecture Thomas Monjalon
2019-04-09 20:25 ` Thomas Monjalon
2019-04-10 17:09 ` Vivian Kong
2019-04-10 17:09 ` Vivian Kong
2019-04-10 17:43 ` Thomas Monjalon
2019-04-10 17:43 ` Thomas Monjalon
2019-04-10 19:15 ` Vivian Kong
2019-04-10 19:15 ` Vivian Kong
2019-04-10 19:46 ` Thomas Monjalon
2019-04-10 19:46 ` Thomas Monjalon
2019-04-10 20:45 ` Vivian Kong
2019-04-10 20:45 ` Vivian Kong
2019-04-10 20:31 ` David Christensen
2019-04-10 20:31 ` David Christensen
2019-04-10 20:46 ` Thomas Monjalon
2019-04-10 20:46 ` Thomas Monjalon
2019-04-10 21:03 ` David Christensen
2019-04-10 21:03 ` David Christensen
2019-04-10 21:45 ` Pradeep Satyanarayana
2019-04-10 21:45 ` Pradeep Satyanarayana
2019-04-11 6:59 ` Thomas Monjalon
2019-04-11 6:59 ` Thomas Monjalon
2019-04-11 15:57 ` Pradeep Satyanarayana
2019-04-11 15:57 ` Pradeep Satyanarayana
[not found] ` <OFB9049735.7E51096E-ON882583D9.00574783-882583D9.00579FE2@LocalDomain>
2019-04-18 21:06 ` Pradeep Satyanarayana
2019-04-18 21:06 ` Pradeep Satyanarayana
2019-04-18 21:18 ` Thomas Monjalon
2019-04-18 21:18 ` Thomas Monjalon
2019-04-11 7:45 ` David Marchand
2019-04-11 7:45 ` David Marchand
2019-05-15 12:45 ` David Marchand
2019-05-15 12:45 ` David Marchand
2020-02-18 21:03 ` Thomas Monjalon
2020-02-20 0:20 ` Pradeep Satyanarayana
2020-02-21 13:33 ` Vivian Kong
2021-03-24 21:40 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190409190630.31975-4-vivkong@ca.ibm.com \
--to=vivkong@gmail.com \
--cc=dev@dpdk.org \
--cc=vivkong@ca.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).