Skip to content

Commit

Permalink
Add support for IBM Z s390x
Browse files Browse the repository at this point in the history
Minimal changes to drivers and app to support the IBM s390x.

Signed-off-by: David Miller <dmiller423@gmail.com>
Reviewed-by: Mathew S Thoennes <tardis@us.ibm.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
  • Loading branch information
dmiller423 authored and ovsrobot committed Jul 26, 2023
1 parent 74913fd commit 5bef0a0
Show file tree
Hide file tree
Showing 53 changed files with 2,439 additions and 14 deletions.
4 changes: 4 additions & 0 deletions app/test-acl/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ static const struct acl_alg acl_alg[] = {
.name = "altivec",
.alg = RTE_ACL_CLASSIFY_ALTIVEC,
},
{
.name = "s390x",
.alg = RTE_ACL_CLASSIFY_S390X,
},
{
.name = "avx512x16",
.alg = RTE_ACL_CLASSIFY_AVX512X16,
Expand Down
1 change: 1 addition & 0 deletions app/test/test_acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ test_classify_run(struct rte_acl_ctx *acx, struct ipv4_7tuple test_data[],
RTE_ACL_CLASSIFY_AVX2,
RTE_ACL_CLASSIFY_NEON,
RTE_ACL_CLASSIFY_ALTIVEC,
RTE_ACL_CLASSIFY_S390X,
RTE_ACL_CLASSIFY_AVX512X16,
RTE_ACL_CLASSIFY_AVX512X32,
};
Expand Down
7 changes: 6 additions & 1 deletion app/test/test_atomic.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <rte_lcore.h>
#include <rte_random.h>
#include <rte_hash_crc.h>
#include <rte_byteorder.h>

#include "test.h"

Expand Down Expand Up @@ -351,6 +352,7 @@ volatile uint16_t token16;
volatile uint32_t token32;
volatile uint64_t token64;

#ifndef RTE_ARCH_S390X
static void
build_crc8_table(void)
{
Expand Down Expand Up @@ -441,6 +443,8 @@ test_atomic_exchange(__rte_unused void *arg)

return 0;
}
#endif

static int
test_atomic(void)
{
Expand Down Expand Up @@ -597,6 +601,7 @@ test_atomic(void)
}
#endif

#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
/*
* Test 16/32/64bit atomic exchange.
*/
Expand Down Expand Up @@ -628,7 +633,7 @@ test_atomic(void)
printf("Atomic exchange test failed\n");
return -1;
}

#endif
return 0;
}
REGISTER_TEST_COMMAND(atomic_autotest, test_atomic);
12 changes: 11 additions & 1 deletion app/test/test_cmdline_ipaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,29 @@
#include <inttypes.h>

#include <rte_string_fns.h>
#include <rte_byteorder.h>

#include <cmdline_parse.h>
#include <cmdline_parse_ipaddr.h>

#include "test_cmdline.h"

#define IP4(a,b,c,d) {.s_addr = (uint32_t)(((a) & 0xff) | \
#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
#define IP4(a, b, c, d) {.s_addr = (uint32_t)(((a) & 0xff) | \
(((b) & 0xff) << 8) | \
(((c) & 0xff) << 16) | \
((d) & 0xff) << 24)}

#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
Expand Down
110 changes: 110 additions & 0 deletions app/test/test_cmdline_num.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <cmdline_parse.h>
#include <cmdline_parse_num.h>
#include <rte_byteorder.h>

#include "test_cmdline.h"

Expand Down Expand Up @@ -438,6 +439,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 RTE_UINT8:
{
uint8_t *temp = (uint8_t *)&result;
result = *temp;
break;
}
case RTE_UINT16:
{
uint16_t *temp = (uint16_t *)&result;
result = *temp;
break;
}
case RTE_UINT32:
{
uint32_t *temp = (uint32_t *)&result;
result = *temp;
break;
}
case RTE_INT8:
{
int8_t *temp = (int8_t *)&result;
result = *temp;
break;
}
case RTE_INT16:
{
int16_t *temp = (int16_t *)&result;
result = *temp;
break;
}
case RTE_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);
Expand Down Expand Up @@ -467,6 +510,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 RTE_INT8:
result = (int8_t) result;
Expand All @@ -480,6 +524,30 @@ test_parse_num_valid(void)
default:
break;
}
#else
switch (type) {
case RTE_INT8:
{
int8_t *temp = (int8_t *)&result;
result = *temp;
break;
}
case RTE_INT16:
{
int16_t *temp = (int16_t *)&result;
result = *temp;
break;
}
case RTE_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",
Expand Down Expand Up @@ -516,6 +584,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 RTE_UINT8:
{
uint8_t *temp = (uint8_t *)&result;
result = *temp;
break;
}
case RTE_UINT16:
{
uint16_t *temp = (uint16_t *)&result;
result = *temp;
break;
}
case RTE_UINT32:
{
uint32_t *temp = (uint32_t *)&result;
result = *temp;
break;
}
case RTE_INT8:
{
int8_t *temp = (int8_t *)&result;
result = *temp;
break;
}
case RTE_INT16:
{
int16_t *temp = (int16_t *)&result;
result = *temp;
break;
}
case RTE_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);
Expand Down
29 changes: 29 additions & 0 deletions app/test/test_hash_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* e.g.: key size = 4, key = 0x03020100
* key size = 8, key = 0x0706050403020100
*/
#if !defined(RTE_ARCH_S390X)
static uint32_t hash_values_jhash[2][12] = {{
0x8ba9414b, 0xdf0d39c9,
0xe4cf1d42, 0xd4ccb93c, 0x5e84eafc, 0x21362cfe,
Expand All @@ -51,6 +52,34 @@ static uint32_t hash_values_crc[2][12] = {{
0x789c104f, 0x53028d3e
}
};
#else
static uint32_t hash_values_jhash[2][12] = {{
0x8ba9414b, 0x8a2f8eb,
0x55dcd60b, 0xf0b95bfe, 0x1a28d94c, 0x003d8f00,
0x84c90b2c, 0x24b83acf, 0x5e16af2f, 0x751c9f59,
0x665b8254, 0x6e347c81
},
{
0x5c62c303, 0xb21d4b7b,
0xa33cdfcf, 0x47cf3d14, 0x1cae829f, 0x1253a9ea,
0x7171efd1, 0xcef21db0, 0x3df3f5fe, 0x35fd67d2,
0x2922cbc4, 0xeaee5c5c
}
};
static uint32_t hash_values_crc[2][12] = {{
0x00000000, 0x13a29877,
0x3eef4343, 0xb6719589, 0x938d3d79, 0xed93196b,
0xe710a46c, 0x81f7ab71, 0x702bc9ee, 0x26c72488,
0x2e7092a9, 0xf2fbc80b
},
{
0xbdfd3980, 0x91e95e36,
0x37765e57, 0x6559eb17, 0x49c8a164, 0x18daa0d3,
0x67065980, 0x62f966d0, 0x4e28a2a0, 0xe342d18f,
0x1518c680, 0xebe8026b
}
};
#endif

/*******************************************************************************
* Hash function performance test configuration section. Each performance test
Expand Down
14 changes: 14 additions & 0 deletions app/test/test_xmmt_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,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){.u32 = {i0, i1, i2, i3}};

return data;
}

#elif defined(RTE_ARCH_RISCV)

#define vect_loadu_sil128(p) vect_load_128(p)
Expand Down
11 changes: 9 additions & 2 deletions buildtools/pmdinfogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@
except ImportError:
pass

import coff
try:
import coff
except TypeError:
pass

def decode_asciiz(data):
index = data.find(b'\x00')
end = index if index >= 0 else len(data)
return data[:end].decode()

class ELFSymbol:
def __init__(self, image, symbol):
Expand All @@ -28,7 +35,7 @@ def __init__(self, image, symbol):
def string_value(self):
size = self._symbol["st_size"]
value = self.get_value(0, size)
return coff.decode_asciiz(value) # not COFF-specific
return decode_asciiz(value) # not COFF-specific

def get_value(self, offset, size):
section = self._symbol["st_shndx"]
Expand Down
2 changes: 2 additions & 0 deletions config/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ if cpu_instruction_set == 'generic'
cpu_instruction_set = 'generic'
elif host_machine.cpu_family().startswith('ppc')
cpu_instruction_set = 'power8'
elif host_machine.cpu_family().startswith('s390x')
machine = 'z13'
elif host_machine.cpu_family().startswith('riscv')
cpu_instruction_set = 'riscv'
endif
Expand Down
51 changes: 51 additions & 0 deletions config/s390x/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# SPDX-License-Identifier: BSD-3-Clause
# (c) Copyright IBM Corp. 2019, 2020

if not dpdk_conf.get('RTE_ARCH_64')
error('Only 64-bit compiles are supported for this platform type')
endif
dpdk_conf.set('RTE_ARCH', 's390x')
dpdk_conf.set('RTE_ARCH_S390X', 1)
dpdk_conf.set('RTE_FORCE_INTRINSICS', 1)

# overrides specific to s390x
dpdk_conf.set('RTE_MAX_LCORE', 256)
dpdk_conf.set('RTE_MAX_NUMA_NODES', 32)
dpdk_conf.set('RTE_CACHE_LINE_SIZE', 128)



# default to z13
cpu_instruction_set = 'z13'

# test compiler support
cc_march_z14 = cc.has_argument('-march=z14')
cc_march_z15 = cc.has_argument('-march=z15')


machine_args = ['-march=' + cpu_instruction_set, '-mtune=' + cpu_instruction_set]

dpdk_conf.set('RTE_MACHINE','s390x')
dpdk_conf.set('RTE_MACHINE_CPUFLAG_ZARCH', 1) # should this be z# 13 ?
#dpdk_conf.set('RTE_MACHINE', cpu_instruction_set)

if (cc.get_define('__s390x__', args: machine_args) != '')
compile_time_cpuflags += ['RTE_MACHINE_CPUFLAG_ZARCH']
endif


# Suppress the gcc warning "note: the layout of aggregates containing
# vectors with 4-byte alignment has changed in GCC 5".
if (cc.get_id() == 'gcc' and cc.version().version_compare('>=10.0') and
cc.version().version_compare('<12.0') and cc.has_argument('-Wno-psabi'))
add_project_arguments('-Wno-psabi', language: 'c')
endif









Loading

0 comments on commit 5bef0a0

Please sign in to comment.