DPDK patches and discussions
 help / color / mirror / Atom feed
From: Vivian Kong <vivkong@gmail.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [RFC 07/12] test: add support for s390x architecture
Date: Tue,  9 Apr 2019 15:06:25 -0400	[thread overview]
Message-ID: <20190409190630.31975-8-vivkong@ca.ibm.com> (raw)
Message-ID: <20190409190625._rD_G4K20G3jS-3oqGrBxQKkWz_DTUzlj2ckiMQqLbc@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/test_cmdline_ipaddr.c |  13 +++-
 app/test/test_cmdline_num.c    | 111 +++++++++++++++++++++++++++++++++
 app/test/test_xmmt_ops.h       |  14 +++++
 3 files changed, 137 insertions(+), 1 deletion(-)

diff --git a/app/test/test_cmdline_ipaddr.c b/app/test/test_cmdline_ipaddr.c
index 8ee7f6288..5e7629bba 100644
--- a/app/test/test_cmdline_ipaddr.c
+++ b/app/test/test_cmdline_ipaddr.c
@@ -6,6 +6,7 @@
 #include <string.h>
 #include <inttypes.h>
 #include <netinet/in.h>
+#include <rte_byteorder.h>
 
 #ifndef __linux__
 #ifndef __FreeBSD__
@@ -22,7 +23,8 @@
 
 #include "test_cmdline.h"
 
-#define IP4(a,b,c,d) {((uint32_t)(((a) & 0xff)) | \
+#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
+#define IP4(a, b, c, d) {((uint32_t)(((a) & 0xff)) | \
 					   (((b) & 0xff) << 8) | \
 					   (((c) & 0xff) << 16)  | \
 					   ((d) & 0xff)  << 24)}
@@ -30,6 +32,15 @@
 #define U16_SWAP(x) \
 		(((x & 0xFF) << 8) | ((x & 0xFF00) >> 8))
 
+#else
+#define IP4(a, b, c, d) {((uint32_t)(((a) & 0xff) << 24) | \
+					   (((b) & 0xff) << 16) | \
+					   (((c) & 0xff) << 8)  | \
+					   ((d) & 0xff))}
+
+#define U16_SWAP(x) x
+#endif
+
 /* create IPv6 address, swapping bytes where needed */
 #ifndef s6_addr16
 # define s6_addr16      __u6_addr.__u6_addr16
diff --git a/app/test/test_cmdline_num.c b/app/test/test_cmdline_num.c
index 4c97caf3d..9e80397ac 100644
--- a/app/test/test_cmdline_num.c
+++ b/app/test/test_cmdline_num.c
@@ -11,6 +11,8 @@
 #include <cmdline_parse.h>
 #include <cmdline_parse_num.h>
 
+
+#include <rte_byteorder.h>
 #include "test_cmdline.h"
 
 struct num_unsigned_str {
@@ -451,6 +453,48 @@ test_parse_num_valid(void)
 			/* check if result matches what it should have matched
 			 * since unsigned numbers don't care about number of bits, we can just convert
 			 * everything to uint64_t without any worries. */
+			#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
+			switch (type) {
+			case UINT8:
+			{
+				uint8_t *temp = (uint8_t *)&result;
+				result = *temp;
+				break;
+			}
+			case UINT16:
+			{
+				uint16_t *temp = (uint16_t *)&result;
+				result = *temp;
+				break;
+			}
+			case UINT32:
+			{
+				uint32_t *temp = (uint32_t *)&result;
+				result = *temp;
+				break;
+			}
+			case INT8:
+			{
+				int8_t *temp = (int8_t *)&result;
+				result = *temp;
+				break;
+			}
+			case INT16:
+			{
+				int16_t *temp = (int16_t *)&result;
+				result = *temp;
+				break;
+			}
+			case INT32:
+			{
+				int32_t *temp = (int32_t *)&result;
+				result = *temp;
+				break;
+			}
+			default:
+				break;
+			}
+			#endif
 			if (ret > 0 && num_valid_positive_strs[i].result != result) {
 				printf("Error: parsing %s as %s failed: result mismatch!\n",
 						num_valid_positive_strs[i].str, buf);
@@ -480,6 +524,7 @@ test_parse_num_valid(void)
 			 * the result is signed in this case, so we have to account for that */
 			if (ret > 0) {
 				/* detect negative */
+				#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
 				switch (type) {
 				case INT8:
 					result = (int8_t) result;
@@ -493,6 +538,30 @@ test_parse_num_valid(void)
 				default:
 					break;
 				}
+				#else
+				switch (type) {
+				case INT8:
+				{
+					int8_t *temp = (int8_t *)&result;
+					result = *temp;
+					break;
+				}
+				case INT16:
+				{
+					int16_t *temp = (int16_t *)&result;
+					result = *temp;
+					break;
+				}
+				case INT32:
+				{
+					int32_t *temp = (int32_t *)&result;
+					result = *temp;
+					break;
+				}
+				default:
+					break;
+				}
+				#endif
 				if (num_valid_negative_strs[i].result == (int64_t) result)
 					continue;
 				printf("Error: parsing %s as %s failed: result mismatch!\n",
@@ -529,6 +598,48 @@ test_parse_num_valid(void)
 			/* check if result matches what it should have matched
 			 * since unsigned numbers don't care about number of bits, we can just convert
 			 * everything to uint64_t without any worries. */
+			#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
+			switch (type) {
+			case UINT8:
+			{
+				uint8_t *temp = (uint8_t *)&result;
+				result = *temp;
+				break;
+			}
+			case UINT16:
+			{
+				uint16_t *temp = (uint16_t *)&result;
+				result = *temp;
+				break;
+			}
+			case UINT32:
+			{
+				uint32_t *temp = (uint32_t *)&result;
+				result = *temp;
+				break;
+			}
+			case INT8:
+			{
+				int8_t *temp = (int8_t *)&result;
+				result = *temp;
+				break;
+			}
+			case INT16:
+			{
+				int16_t *temp = (int16_t *)&result;
+				result = *temp;
+				break;
+			}
+			case INT32:
+			{
+				int32_t *temp = (int32_t *)&result;
+				result = *temp;
+				break;
+			}
+			default:
+				break;
+			}
+			#endif
 			if (ret > 0 && num_garbage_positive_strs[i].result != result) {
 				printf("Error: parsing %s as %s failed: result mismatch!\n",
 						num_garbage_positive_strs[i].str, buf);
diff --git a/app/test/test_xmmt_ops.h b/app/test/test_xmmt_ops.h
index 8bcf0b261..6d8cd1998 100644
--- a/app/test/test_xmmt_ops.h
+++ b/app/test/test_xmmt_ops.h
@@ -49,6 +49,20 @@ vect_set_epi32(int i3, int i2, int i1, int i0)
 	return data;
 }
 
+#elif defined(RTE_ARCH_S390X)
+
+/* loads the xmm_t value from address p(does not need to be 16-byte aligned)*/
+#define vect_loadu_sil128(p) vec_xld2(0, (signed int *)p)
+
+/* sets the 4 signed 32-bit integer values and returns the xmm_t variable */
+static __rte_always_inline xmm_t
+vect_set_epi32(int i3, int i2, int i1, int i0)
+{
+	xmm_t data = (xmm_t){i0, i1, i2, i3};
+
+	return data;
+}
+
 #endif
 
 #endif /* _TEST_XMMT_OPS_H_ */
-- 
2.17.1


  parent reply	other threads:[~2019-04-09 19:08 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 ` [dpdk-dev] [RFC 03/12] acl: " Vivian Kong
2019-04-09 19:06   ` 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 ` Vivian Kong [this message]
2019-04-09 19:06   ` [dpdk-dev] [RFC 07/12] test: " 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-8-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).