aboutsummaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2020-10-20 13:31:57 +0300
committerMatias Elo <matias.elo@nokia.com>2020-10-20 13:31:57 +0300
commit47906491e30611b9700657349bfe4a843591e956 (patch)
tree57ed51178c3bc161d93c98767c70754b4d287c30 /platform
parent2e00d3740f1f5a1f3a4fdeeda6176b485e29466c (diff)
parent5929f15fe8887bd8e0c2eef766dd6bf26d7d176c (diff)
Merge branch 'master' of https://github.com/OpenDataPlane/odp into odp-dpdk
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Diffstat (limited to 'platform')
-rw-r--r--platform/linux-generic/include/odp/api/plat/packet_inline_types.h1
-rw-r--r--platform/linux-generic/include/odp_classification_datamodel.h6
-rw-r--r--platform/linux-generic/include/odp_packet_internal.h9
-rw-r--r--platform/linux-generic/include/odp_pkt_queue_internal.h3
-rw-r--r--platform/linux-generic/include/odp_traffic_mngr_internal.h1
-rw-r--r--platform/linux-generic/m4/configure.m47
-rw-r--r--platform/linux-generic/odp_classification.c46
-rw-r--r--platform/linux-generic/odp_crypto_null.c14
-rw-r--r--platform/linux-generic/odp_crypto_openssl.c14
-rw-r--r--platform/linux-generic/odp_ishm.c2
-rw-r--r--platform/linux-generic/odp_packet.c13
-rw-r--r--platform/linux-generic/odp_pkt_queue.c44
-rw-r--r--platform/linux-generic/odp_traffic_mngr.c18
-rw-r--r--platform/linux-generic/test/Makefile.am27
-rw-r--r--platform/linux-generic/test/example/Makefile.am7
-rw-r--r--platform/linux-generic/test/example/l2fwd_simple/Makefile.am1
-rw-r--r--platform/linux-generic/test/example/l2fwd_simple/pktio_env47
-rw-r--r--platform/linux-generic/test/example/l3fwd/Makefile.am1
-rw-r--r--platform/linux-generic/test/example/l3fwd/pktio_env51
-rw-r--r--platform/linux-generic/test/example/packet/Makefile.am1
-rw-r--r--platform/linux-generic/test/example/packet/pktio_env50
-rw-r--r--platform/linux-generic/test/example/ping/Makefile.am1
-rw-r--r--platform/linux-generic/test/example/ping/pktio_env50
-rw-r--r--platform/linux-generic/test/example/simple_pipeline/Makefile.am1
-rw-r--r--platform/linux-generic/test/example/simple_pipeline/pktio_env47
-rw-r--r--platform/linux-generic/test/example/switch/Makefile.am1
-rw-r--r--platform/linux-generic/test/example/switch/pktio_env53
-rwxr-xr-xplatform/linux-generic/test/ipsec/ipsec_crypto_example.sh (renamed from platform/linux-generic/test/ipsec/ipsec_example.sh)8
-rw-r--r--platform/linux-generic/test/pktio_ipc/Makefile.am20
-rw-r--r--platform/linux-generic/test/validation/api/pktio/Makefile.am20
30 files changed, 513 insertions, 51 deletions
diff --git a/platform/linux-generic/include/odp/api/plat/packet_inline_types.h b/platform/linux-generic/include/odp/api/plat/packet_inline_types.h
index fd18488fd..1b6f3bc45 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_inline_types.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_inline_types.h
@@ -59,6 +59,7 @@ typedef union {
/* Individual input flags */
struct {
uint64_t dst_queue:1; /* Dst queue present */
+ uint64_t cls_mark: 1; /* Classifier mark value present*/
uint64_t flow_hash:1; /* Flow hash present */
uint64_t timestamp:1; /* Timestamp present */
diff --git a/platform/linux-generic/include/odp_classification_datamodel.h b/platform/linux-generic/include/odp_classification_datamodel.h
index 9ebb2a509..83063a853 100644
--- a/platform/linux-generic/include/odp_classification_datamodel.h
+++ b/platform/linux-generic/include/odp_classification_datamodel.h
@@ -145,14 +145,12 @@ typedef union cos_u {
uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct cos_s))];
} cos_t;
-/**
-Packet Matching Rule
-
-**/
+/* Pattern Matching Rule */
struct pmr_s {
uint32_t valid; /* Validity Flag */
odp_atomic_u32_t count; /* num of packets matching this rule */
uint32_t num_pmr; /* num of PMR Term Values*/
+ uint16_t mark;
odp_spinlock_t lock; /* pmr lock*/
cos_t *src_cos; /* source CoS where PMR is attached */
pmr_term_value_t pmr_term_value[CLS_PMRTERM_MAX];
diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h
index ef9b3ba89..83a6fdfed 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -123,6 +123,9 @@ typedef struct odp_packet_hdr_t {
/* Flow hash value */
uint32_t flow_hash;
+ /* Classifier mark */
+ uint16_t cls_mark;
+
union {
struct {
/* Result for crypto packet op */
@@ -198,8 +201,9 @@ static inline void packet_init(odp_packet_hdr_t *pkt_hdr, uint32_t len)
last->seg_len = seg_len;
}
- pkt_hdr->p.input_flags.all = 0;
- pkt_hdr->p.flags.all_flags = 0;
+ /* Clear all flags. Resets also return value of cls_mark, user_ptr, etc. */
+ pkt_hdr->p.input_flags.all = 0;
+ pkt_hdr->p.flags.all_flags = 0;
pkt_hdr->p.l2_offset = 0;
pkt_hdr->p.l3_offset = ODP_PACKET_OFFSET_INVALID;
@@ -233,6 +237,7 @@ static inline void copy_packet_cls_metadata(odp_packet_hdr_t *src_hdr,
dst_hdr->dst_queue = src_hdr->dst_queue;
dst_hdr->flow_hash = src_hdr->flow_hash;
dst_hdr->timestamp = src_hdr->timestamp;
+ dst_hdr->cls_mark = src_hdr->cls_mark;
}
static inline void *packet_data(odp_packet_hdr_t *pkt_hdr)
diff --git a/platform/linux-generic/include/odp_pkt_queue_internal.h b/platform/linux-generic/include/odp_pkt_queue_internal.h
index 23eb2b41b..11ac97de1 100644
--- a/platform/linux-generic/include/odp_pkt_queue_internal.h
+++ b/platform/linux-generic/include/odp_pkt_queue_internal.h
@@ -43,6 +43,9 @@ _odp_int_queue_pool_t _odp_queue_pool_create(uint32_t max_num_queues,
_odp_int_pkt_queue_t _odp_pkt_queue_create(_odp_int_queue_pool_t queue_pool);
+void _odp_pkt_queue_destroy(_odp_int_queue_pool_t queue_pool,
+ _odp_int_pkt_queue_t pkt_queue);
+
int _odp_pkt_queue_append(_odp_int_queue_pool_t queue_pool,
_odp_int_pkt_queue_t pkt_queue,
odp_packet_t pkt);
diff --git a/platform/linux-generic/include/odp_traffic_mngr_internal.h b/platform/linux-generic/include/odp_traffic_mngr_internal.h
index 040bb117a..8a65a1685 100644
--- a/platform/linux-generic/include/odp_traffic_mngr_internal.h
+++ b/platform/linux-generic/include/odp_traffic_mngr_internal.h
@@ -372,7 +372,6 @@ struct tm_system_s {
_odp_int_name_t name_tbl_id;
void *trace_buffer;
- uint32_t next_queue_num;
tm_queue_obj_t *queue_num_tbl[ODP_TM_MAX_TM_QUEUES];
input_work_queue_t input_work_queue;
tm_queue_cnts_t priority_queue_cnts;
diff --git a/platform/linux-generic/m4/configure.m4 b/platform/linux-generic/m4/configure.m4
index 79b2b9ffa..c084d844b 100644
--- a/platform/linux-generic/m4/configure.m4
+++ b/platform/linux-generic/m4/configure.m4
@@ -41,6 +41,13 @@ AC_CONFIG_FILES([platform/linux-generic/Makefile
platform/linux-generic/libodp-linux.pc
platform/linux-generic/dumpconfig/Makefile
platform/linux-generic/test/Makefile
+ platform/linux-generic/test/example/Makefile
+ platform/linux-generic/test/example/l2fwd_simple/Makefile
+ platform/linux-generic/test/example/l3fwd/Makefile
+ platform/linux-generic/test/example/packet/Makefile
+ platform/linux-generic/test/example/ping/Makefile
+ platform/linux-generic/test/example/simple_pipeline/Makefile
+ platform/linux-generic/test/example/switch/Makefile
platform/linux-generic/test/validation/api/shmem/Makefile
platform/linux-generic/test/validation/api/pktio/Makefile
platform/linux-generic/test/pktio_ipc/Makefile])
diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c
index 8637e611f..1d5384c9e 100644
--- a/platform/linux-generic/odp_classification.c
+++ b/platform/linux-generic/odp_classification.c
@@ -26,8 +26,11 @@
#include <string.h>
#include <errno.h>
#include <stdbool.h>
+#include <inttypes.h>
#include <odp/api/spinlock.h>
+#define MAX_MARK UINT16_MAX
+
#define LOCK(a) odp_spinlock_lock(a)
#define UNLOCK(a) odp_spinlock_unlock(a)
#define LOCK_INIT(a) odp_spinlock_init(a)
@@ -180,9 +183,17 @@ int odp_cls_capability(odp_cls_capability_t *capability)
capability->threshold_red.all_bits = 0;
capability->threshold_bp.all_bits = 0;
capability->max_hash_queues = CLS_COS_QUEUE_MAX;
+ capability->max_mark = MAX_MARK;
return 0;
}
+void odp_cls_pmr_create_opt_init(odp_pmr_create_opt_t *opt)
+{
+ opt->terms = NULL;
+ opt->num_terms = 0;
+ opt->mark = 0;
+}
+
static void _odp_cls_update_hash_proto(cos_t *cos,
odp_pktin_hash_proto_t hash_proto)
{
@@ -692,8 +703,8 @@ no_rule:
return 0;
}
-odp_pmr_t odp_cls_pmr_create(const odp_pmr_param_t *terms, int num_terms,
- odp_cos_t src_cos, odp_cos_t dst_cos)
+static odp_pmr_t cls_pmr_create(const odp_pmr_param_t *terms, int num_terms, uint16_t mark,
+ odp_cos_t src_cos, odp_cos_t dst_cos)
{
pmr_t *pmr;
int i;
@@ -729,6 +740,8 @@ odp_pmr_t odp_cls_pmr_create(const odp_pmr_param_t *terms, int num_terms,
}
}
+ pmr->s.mark = mark;
+
loc = odp_atomic_fetch_inc_u32(&cos_src->s.num_rule);
cos_src->s.pmr[loc] = pmr;
cos_src->s.linked_cos[loc] = cos_dst;
@@ -738,6 +751,28 @@ odp_pmr_t odp_cls_pmr_create(const odp_pmr_param_t *terms, int num_terms,
return id;
}
+odp_pmr_t odp_cls_pmr_create(const odp_pmr_param_t *terms, int num_terms,
+ odp_cos_t src_cos, odp_cos_t dst_cos)
+{
+ return cls_pmr_create(terms, num_terms, 0, src_cos, dst_cos);
+}
+
+odp_pmr_t odp_cls_pmr_create_opt(const odp_pmr_create_opt_t *opt,
+ odp_cos_t src_cos, odp_cos_t dst_cos)
+{
+ if (opt == NULL) {
+ ODP_ERR("Bad parameter\n");
+ return ODP_PMR_INVALID;
+ }
+
+ if (opt->mark > MAX_MARK) {
+ ODP_ERR("Too large mark value: %" PRIu64 "\n", opt->mark);
+ return ODP_PMR_INVALID;
+ }
+
+ return cls_pmr_create(opt->terms, opt->num_terms, opt->mark, src_cos, dst_cos);
+}
+
int odp_cls_cos_pool_set(odp_cos_t cos_id, odp_pool_t pool)
{
cos_t *cos;
@@ -1298,6 +1333,13 @@ static cos_t *match_pmr_cos(cos_t *cos, const uint8_t *pkt_addr, pmr_t *pmr,
return NULL;
if (verify_pmr(pmr, pkt_addr, hdr)) {
+ /* PRM matched */
+ hdr->p.input_flags.cls_mark = 0;
+ if (pmr->s.mark) {
+ hdr->p.input_flags.cls_mark = 1;
+ hdr->cls_mark = pmr->s.mark;
+ }
+
/* This gets called recursively. First matching leaf or branch
* is returned. */
num_rule = odp_atomic_load_u32(&cos->s.num_rule);
diff --git a/platform/linux-generic/odp_crypto_null.c b/platform/linux-generic/odp_crypto_null.c
index 8dfac007d..6dd98a2b7 100644
--- a/platform/linux-generic/odp_crypto_null.c
+++ b/platform/linux-generic/odp_crypto_null.c
@@ -530,10 +530,10 @@ int odp_crypto_op(const odp_packet_t pkt_in[],
int i, rc;
odp_crypto_generic_session_t *session;
- session = (odp_crypto_generic_session_t *)(intptr_t)param->session;
- ODP_ASSERT(ODP_CRYPTO_SYNC == session->p.op_mode);
-
for (i = 0; i < num_pkt; i++) {
+ session = (odp_crypto_generic_session_t *)(intptr_t)param[i].session;
+ ODP_ASSERT(ODP_CRYPTO_SYNC == session->p.op_mode);
+
rc = crypto_int(pkt_in[i], &pkt_out[i], &param[i]);
if (rc < 0)
break;
@@ -552,11 +552,11 @@ int odp_crypto_op_enq(const odp_packet_t pkt_in[],
odp_crypto_generic_session_t *session;
int i, rc;
- session = (odp_crypto_generic_session_t *)(intptr_t)param->session;
- ODP_ASSERT(ODP_CRYPTO_ASYNC == session->p.op_mode);
- ODP_ASSERT(ODP_QUEUE_INVALID != session->p.compl_queue);
-
for (i = 0; i < num_pkt; i++) {
+ session = (odp_crypto_generic_session_t *)(intptr_t)param[i].session;
+ ODP_ASSERT(ODP_CRYPTO_ASYNC == session->p.op_mode);
+ ODP_ASSERT(ODP_QUEUE_INVALID != session->p.compl_queue);
+
pkt = pkt_out[i];
rc = crypto_int(pkt_in[i], &pkt, &param[i]);
if (rc < 0)
diff --git a/platform/linux-generic/odp_crypto_openssl.c b/platform/linux-generic/odp_crypto_openssl.c
index 2a8d4fb9b..64984e201 100644
--- a/platform/linux-generic/odp_crypto_openssl.c
+++ b/platform/linux-generic/odp_crypto_openssl.c
@@ -2818,10 +2818,10 @@ int odp_crypto_op(const odp_packet_t pkt_in[],
int i, rc;
odp_crypto_generic_session_t *session;
- session = (odp_crypto_generic_session_t *)(intptr_t)param->session;
- ODP_ASSERT(ODP_CRYPTO_SYNC == session->p.op_mode);
-
for (i = 0; i < num_pkt; i++) {
+ session = (odp_crypto_generic_session_t *)(intptr_t)param[i].session;
+ ODP_ASSERT(ODP_CRYPTO_SYNC == session->p.op_mode);
+
rc = crypto_int(pkt_in[i], &pkt_out[i], &param[i]);
if (rc < 0)
break;
@@ -2840,11 +2840,11 @@ int odp_crypto_op_enq(const odp_packet_t pkt_in[],
odp_crypto_generic_session_t *session;
int i, rc;
- session = (odp_crypto_generic_session_t *)(intptr_t)param->session;
- ODP_ASSERT(ODP_CRYPTO_ASYNC == session->p.op_mode);
- ODP_ASSERT(ODP_QUEUE_INVALID != session->p.compl_queue);
-
for (i = 0; i < num_pkt; i++) {
+ session = (odp_crypto_generic_session_t *)(intptr_t)param[i].session;
+ ODP_ASSERT(ODP_CRYPTO_ASYNC == session->p.op_mode);
+ ODP_ASSERT(ODP_QUEUE_INVALID != session->p.compl_queue);
+
pkt = pkt_out[i];
rc = crypto_int(pkt_in[i], &pkt, &param[i]);
if (rc < 0)
diff --git a/platform/linux-generic/odp_ishm.c b/platform/linux-generic/odp_ishm.c
index 8e34feecd..6b2d03d40 100644
--- a/platform/linux-generic/odp_ishm.c
+++ b/platform/linux-generic/odp_ishm.c
@@ -1775,7 +1775,7 @@ int _odp_ishm_init_global(const odp_init_t *init)
ishm_ftbl->unused_fragmnts = &ishm_ftbl->fragment[1];
/*
- * We run _odp_ishm_init_local() directely here to give the
+ * We run _odp_ishm_init_local() directly here to give the
* possibility to run shm_reserve() before the odp_init_local()
* is performed for the main thread... Many init_global() functions
* indeed assume the availability of odp_shm_reserve()...:
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 430839be6..e47d3b724 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -1579,6 +1579,8 @@ void odp_packet_print(odp_packet_t pkt)
}
len += snprintf(&str[len], n - len, " flags 0x%" PRIx32 "\n",
hdr->p.flags.all_flags);
+ len += snprintf(&str[len], n - len, " cls_mark %" PRIu64 "\n",
+ odp_packet_cls_mark(pkt));
len += snprintf(&str[len], n - len,
" l2_offset %" PRIu32 "\n", hdr->p.l2_offset);
len += snprintf(&str[len], n - len,
@@ -1718,6 +1720,7 @@ int _odp_packet_copy_md_to_packet(odp_packet_t srcpkt, odp_packet_t dstpkt)
dsthdr->input = srchdr->input;
dsthdr->dst_queue = srchdr->dst_queue;
+ dsthdr->cls_mark = srchdr->cls_mark;
dsthdr->buf_hdr.user_ptr = srchdr->buf_hdr.user_ptr;
if (dsthdr->buf_hdr.uarea_addr != NULL &&
srchdr->buf_hdr.uarea_addr != NULL) {
@@ -2843,3 +2846,13 @@ odp_proto_l4_type_t odp_packet_l4_type(odp_packet_t pkt)
return ODP_PROTO_L4_TYPE_NONE;
}
+
+uint64_t odp_packet_cls_mark(odp_packet_t pkt)
+{
+ odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
+
+ if (pkt_hdr->p.input_flags.cls_mark)
+ return pkt_hdr->cls_mark;
+
+ return 0;
+}
diff --git a/platform/linux-generic/odp_pkt_queue.c b/platform/linux-generic/odp_pkt_queue.c
index edc82803b..556e034f8 100644
--- a/platform/linux-generic/odp_pkt_queue.c
+++ b/platform/linux-generic/odp_pkt_queue.c
@@ -13,6 +13,7 @@
#include <inttypes.h>
#include <odp_api.h>
#include <odp_pkt_queue_internal.h>
+#include <odp_traffic_mngr_internal.h>
#include <odp_debug_internal.h>
#include <odp_macros_internal.h>
@@ -46,6 +47,7 @@ typedef struct {
} queue_region_desc_t;
typedef struct {
+ uint8_t queue_status[ODP_TM_MAX_TM_QUEUES];
uint64_t total_pkt_appends;
uint64_t total_pkt_removes;
uint64_t total_bad_removes;
@@ -55,7 +57,7 @@ typedef struct {
uint32_t free_list_head_idx;
uint32_t max_queue_num;
uint32_t max_queued_pkts;
- uint32_t next_queue_num;
+ uint32_t num_queues;
queue_region_desc_t queue_region_descs[16];
uint32_t *queue_num_tbl;
uint8_t current_region;
@@ -251,7 +253,7 @@ _odp_int_queue_pool_t _odp_queue_pool_create(uint32_t max_num_queues,
pool->max_queue_num = max_num_queues;
pool->max_queued_pkts = max_queued_pkts;
- pool->next_queue_num = 1;
+ pool->num_queues = 0;
pool->min_free_list_size = pool->free_list_size;
pool->peak_free_list_size = pool->free_list_size;
@@ -260,15 +262,35 @@ _odp_int_queue_pool_t _odp_queue_pool_create(uint32_t max_num_queues,
_odp_int_pkt_queue_t _odp_pkt_queue_create(_odp_int_queue_pool_t queue_pool)
{
- queue_pool_t *pool;
- uint32_t queue_num;
+ queue_pool_t *pool = (queue_pool_t *)(uintptr_t)queue_pool;
+ uint32_t i;
- pool = (queue_pool_t *)(uintptr_t)queue_pool;
- queue_num = pool->next_queue_num++;
- if (pool->max_queue_num < queue_num)
+ if (pool->num_queues >= pool->max_queue_num)
return _ODP_INT_PKT_QUEUE_INVALID;
- return (_odp_int_pkt_queue_t)queue_num;
+ for (i = 0; i < pool->max_queue_num; i++) {
+ if (pool->queue_status[i] == TM_STATUS_FREE) {
+ pool->queue_status[i] = TM_STATUS_RESERVED;
+ pool->num_queues++;
+ return (_odp_int_pkt_queue_t)(i + 1);
+ }
+ }
+ return _ODP_INT_PKT_QUEUE_INVALID;
+}
+
+void _odp_pkt_queue_destroy(_odp_int_queue_pool_t queue_pool,
+ _odp_int_pkt_queue_t pkt_queue)
+{
+ queue_pool_t *pool = (queue_pool_t *)(uintptr_t)queue_pool;
+ uint32_t queue_num = (uint32_t)pkt_queue;
+
+ if ((queue_num == 0) || (queue_num > pool->max_queue_num)) {
+ ODP_ERR("Invalid TM packet queue ID\n");
+ return;
+ }
+
+ pool->queue_status[queue_num - 1] = TM_STATUS_FREE;
+ pool->num_queues--;
}
int _odp_pkt_queue_append(_odp_int_queue_pool_t queue_pool,
@@ -390,9 +412,9 @@ void _odp_pkt_queue_stats_print(_odp_int_queue_pool_t queue_pool)
pool = (queue_pool_t *)(uintptr_t)queue_pool;
ODP_PRINT("pkt_queue_stats - queue_pool=0x%" PRIX64 "\n", queue_pool);
- ODP_PRINT(" max_queue_num=%u max_queued_pkts=%u next_queue_num=%u\n",
- pool->max_queue_num, pool->max_queued_pkts,
- pool->next_queue_num);
+ ODP_PRINT(" max_queue_num=%" PRIu32 " max_queued_pkts=%" PRIu32 " "
+ "num_queues=%" PRIu32 "\n", pool->max_queue_num,
+ pool->max_queued_pkts, pool->num_queues);
ODP_PRINT(" total pkt appends=%" PRIu64 " total pkt removes=%" PRIu64
" bad removes=%" PRIu64 "\n",
pool->total_pkt_appends, pool->total_pkt_removes,
diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c
index 278929c99..ebd7d1785 100644
--- a/platform/linux-generic/odp_traffic_mngr.c
+++ b/platform/linux-generic/odp_traffic_mngr.c
@@ -367,25 +367,25 @@ static void free_tbl_entry(profile_tbl_t *profile_tbl,
switch (profile_kind) {
case TM_SHAPER_PROFILE:
odp_ticketlock_lock(&profile_tbl->shaper.lock);
- profile_tbl->shaper.profile[idx].status = TM_STATUS_RESERVED;
+ profile_tbl->shaper.profile[idx].status = TM_STATUS_FREE;
odp_ticketlock_unlock(&profile_tbl->shaper.lock);
return;
case TM_SCHED_PROFILE:
odp_ticketlock_lock(&profile_tbl->sched.lock);
- profile_tbl->sched.profile[idx].status = TM_STATUS_RESERVED;
+ profile_tbl->sched.profile[idx].status = TM_STATUS_FREE;
odp_ticketlock_unlock(&profile_tbl->sched.lock);
return;
case TM_THRESHOLD_PROFILE:
odp_ticketlock_lock(&profile_tbl->threshold.lock);
- profile_tbl->threshold.profile[idx].status = TM_STATUS_RESERVED;
+ profile_tbl->threshold.profile[idx].status = TM_STATUS_FREE;
odp_ticketlock_unlock(&profile_tbl->threshold.lock);
return;
case TM_WRED_PROFILE:
odp_ticketlock_lock(&profile_tbl->wred.lock);
- profile_tbl->wred.profile[idx].status = TM_STATUS_RESERVED;
+ profile_tbl->wred.profile[idx].status = TM_STATUS_FREE;
odp_ticketlock_unlock(&profile_tbl->wred.lock);
return;
@@ -2959,7 +2959,6 @@ odp_tm_t odp_tm_create(const char *name,
tm_system_capabilities_set(&tm_system->capabilities,
&tm_system->requirements);
- tm_system->next_queue_num = 1;
tm_system->root_node.is_root_node = true;
tm_init_random_data(&tm_system->tm_random_data);
@@ -3973,7 +3972,7 @@ odp_tm_queue_t odp_tm_queue_create(odp_tm_t odp_tm,
queue_obj->user_context = params->user_context;
queue_obj->priority = params->priority;
queue_obj->tm_idx = tm_system->tm_idx;
- queue_obj->queue_num = tm_system->next_queue_num++;
+ queue_obj->queue_num = (uint32_t)_odp_int_pkt_queue;
queue_obj->_odp_int_pkt_queue = _odp_int_pkt_queue;
queue_obj->pkt = ODP_PACKET_INVALID;
odp_ticketlock_init(&queue_obj->tm_wred_node.tm_wred_node_lock);
@@ -4052,6 +4051,8 @@ int odp_tm_queue_destroy(odp_tm_queue_t tm_queue)
odp_queue_destroy(tm_queue_obj->queue);
odp_ticketlock_lock(&tm_glb->queue_obj.lock);
+ _odp_pkt_queue_destroy(tm_system->_odp_int_queue_pool,
+ tm_queue_obj->_odp_int_pkt_queue);
tm_queue_obj->status = TM_STATUS_FREE;
odp_ticketlock_unlock(&tm_glb->queue_obj.lock);
@@ -4683,7 +4684,7 @@ void odp_tm_stats_print(odp_tm_t odp_tm)
input_work_queue_t *input_work_queue;
tm_queue_obj_t *tm_queue_obj;
tm_system_t *tm_system;
- uint32_t queue_num, max_queue_num;
+ uint32_t queue_num;
tm_system = GET_TM_SYSTEM(odp_tm);
input_work_queue = &tm_system->input_work_queue;
@@ -4706,8 +4707,7 @@ void odp_tm_stats_print(odp_tm_t odp_tm)
_odp_timer_wheel_stats_print(tm_system->_odp_int_timer_wheel);
_odp_sorted_list_stats_print(tm_system->_odp_int_sorted_pool);
- max_queue_num = tm_system->next_queue_num;
- for (queue_num = 1; queue_num < max_queue_num; queue_num++) {
+ for (queue_num = 1; queue_num <= ODP_TM_MAX_TM_QUEUES; queue_num++) {
tm_queue_obj = tm_system->queue_num_tbl[queue_num - 1];
if (tm_queue_obj && tm_queue_obj->pkts_rcvd_cnt != 0)
ODP_PRINT("queue_num=%u priority=%u rcvd=%u enqueued=%u "
diff --git a/platform/linux-generic/test/Makefile.am b/platform/linux-generic/test/Makefile.am
index b025d1331..c32bd274b 100644
--- a/platform/linux-generic/test/Makefile.am
+++ b/platform/linux-generic/test/Makefile.am
@@ -14,16 +14,17 @@ TESTS = validation/api/pktio/pktio_run.sh \
validation/api/pktio/pktio_run_tap.sh \
validation/api/shmem/shmem_linux$(EXEEXT) \
ipsec/ipsec_api_example.sh \
- ipsec/ipsec_example.sh
+ ipsec/ipsec_crypto_example.sh
dist_check_SCRIPTS = ipsec/ipsec_api_example.sh \
- ipsec/ipsec_example.sh
+ ipsec/ipsec_crypto_example.sh
test_SCRIPTS = $(dist_check_SCRIPTS)
SUBDIRS += validation/api/pktio\
validation/api/shmem\
- pktio_ipc
+ pktio_ipc \
+ example
if ODP_PKTIO_PCAP
TESTS += validation/api/pktio/pktio_run_pcap.sh
@@ -62,3 +63,23 @@ if test_installdir
installcheck-local:
$(DESTDIR)/$(testdir)/run-test.sh $(TESTNAME)
endif
+
+# If building out-of-tree, make check will not copy the scripts and data to the
+# $(builddir) assuming that all commands are run locally. However this prevents
+# running tests on a remote target using LOG_COMPILER.
+# So copy all script and data files explicitly here.
+all-local:
+ if [ "x$(srcdir)" != "x$(builddir)" ]; then \
+ for f in $(dist_check_SCRIPTS); do \
+ if [ -e $(srcdir)/$$f ]; then \
+ mkdir -p $(builddir)/$$(dirname $$f); \
+ cp -f $(srcdir)/$$f $(builddir)/$$f; \
+ fi \
+ done \
+ fi
+clean-local:
+ if [ "x$(srcdir)" != "x$(builddir)" ]; then \
+ for f in $(dist_check_SCRIPTS); do \
+ rm -f $(builddir)/$$f; \
+ done \
+ fi
diff --git a/platform/linux-generic/test/example/Makefile.am b/platform/linux-generic/test/example/Makefile.am
new file mode 100644
index 000000000..2e6a7ce6c
--- /dev/null
+++ b/platform/linux-generic/test/example/Makefile.am
@@ -0,0 +1,7 @@
+SUBDIRS = \
+ l2fwd_simple \
+ l3fwd \
+ packet \
+ ping \
+ simple_pipeline \
+ switch
diff --git a/platform/linux-generic/test/example/l2fwd_simple/Makefile.am b/platform/linux-generic/test/example/l2fwd_simple/Makefile.am
new file mode 100644
index 000000000..2ffced539
--- /dev/null
+++ b/platform/linux-generic/test/example/l2fwd_simple/Makefile.am
@@ -0,0 +1 @@
+EXTRA_DIST = pktio_env
diff --git a/platform/linux-generic/test/example/l2fwd_simple/pktio_env b/platform/linux-generic/test/example/l2fwd_simple/pktio_env
new file mode 100644
index 000000000..e1fbe87cc
--- /dev/null
+++ b/platform/linux-generic/test/example/l2fwd_simple/pktio_env
@@ -0,0 +1,47 @@
+#!/bin/sh
+#
+# Copyright (C) 2020, Marvell
+# All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Script to setup interfaces used for running application on linux-generic.
+#
+# For linux-generic the default behavior is to create two pcap interfaces
+# and one interface uses udp64.pcap to inject traffic. An output pcap file
+# is generated via second interface.
+#
+# Network set-up
+# IF0 <---> IF1
+
+PCAP_IN=`find . ${TEST_DIR} $(dirname $0) -name udp64.pcap -print -quit`
+echo "using PCAP_IN = ${PCAP_IN}"
+
+IF0=pcap:in=${PCAP_IN}
+IF1=pcap:out=pcapout.pcap
+
+if [ "$0" = "$BASH_SOURCE" ]; then
+ echo "Error: Platform specific env file has to be sourced."
+fi
+
+validate_result()
+{
+ if [ `stat -c %s pcapout.pcap` -ne `stat -c %s ${PCAP_IN}` ]; then
+ echo "File sizes disagree"
+ exit 1
+ fi
+
+ rm -f pcapout.pcap
+}
+
+setup_interfaces()
+{
+ echo "pktio: setting up test interfaces $IF0, $IF1."
+ return 0
+}
+
+cleanup_interfaces()
+{
+ echo "pktio: cleaning up test interfaces $IF0, $IF1."
+ return 0
+}
diff --git a/platform/linux-generic/test/example/l3fwd/Makefile.am b/platform/linux-generic/test/example/l3fwd/Makefile.am
new file mode 100644
index 000000000..2ffced539
--- /dev/null
+++ b/platform/linux-generic/test/example/l3fwd/Makefile.am
@@ -0,0 +1 @@
+EXTRA_DIST = pktio_env
diff --git a/platform/linux-generic/test/example/l3fwd/pktio_env b/platform/linux-generic/test/example/l3fwd/pktio_env
new file mode 100644
index 000000000..a692d79bc
--- /dev/null
+++ b/platform/linux-generic/test/example/l3fwd/pktio_env
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# Copyright (C) 2020, Marvell
+# All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Script to setup interfaces used for running application on linux-generic.
+#
+# For linux-generic the default behavior is to create two pcap interfaces
+# and one interface uses udp64.pcap to inject traffic. An output pcap file
+# is generated via second interface.
+#
+# Network set-up
+# IF0 <---> IF1
+
+PCAP_IN=`find . ${TEST_DIR} $(dirname $0) -name udp64.pcap -print -quit`
+PCAP_OUT="pcapout.pcap"
+PCAP_IN_SIZE=`stat -c %s ${PCAP_IN}`
+echo "using PCAP_IN = ${PCAP_IN}, PCAP_OUT = ${PCAP_OUT}"
+
+IF0=pcap:in=${PCAP_IN}
+IF1=pcap:out=${PCAP_OUT}
+
+if [ "$0" = "$BASH_SOURCE" ]; then
+ echo "Error: Platform specific env file has to be sourced."
+fi
+
+validate_result()
+{
+ PCAP_OUT_SIZE=`stat -c %s ${PCAP_OUT}`
+ if [ ${PCAP_IN_SIZE} -ne ${PCAP_OUT_SIZE} ]; then
+ echo "in:${PCAP_IN_SIZE} out:${PCAP_OUT_SIZE}"
+ exit 1
+ fi
+
+ echo "Pass: in:${PCAP_IN_SIZE} out:${PCAP_OUT_SIZE}"
+ rm -f pcapout.pcap
+}
+
+setup_interfaces()
+{
+ echo "pktio: setting up test interfaces $IF0, $IF1."
+ return 0
+}
+
+cleanup_interfaces()
+{
+ echo "pktio: cleaning up test interfaces $IF0, $IF1."
+ return 0
+}
diff --git a/platform/linux-generic/test/example/packet/Makefile.am b/platform/linux-generic/test/example/packet/Makefile.am
new file mode 100644
index 000000000..2ffced539
--- /dev/null
+++ b/platform/linux-generic/test/example/packet/Makefile.am
@@ -0,0 +1 @@
+EXTRA_DIST = pktio_env
diff --git a/platform/linux-generic/test/example/packet/pktio_env b/platform/linux-generic/test/example/packet/pktio_env
new file mode 100644
index 000000000..4e1914e2e
--- /dev/null
+++ b/platform/linux-generic/test/example/packet/pktio_env
@@ -0,0 +1,50 @@
+#!/bin/sh
+#
+# Copyright (C) 2020, Marvell
+# All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Script to setup interfaces used for running application on linux-generic.
+#
+# For linux-generic the default behavior is to create two pcap interfaces
+# and one interface uses udp64.pcap to inject traffic. An output pcap file
+# is generated via second interface.
+#
+# Network set-up
+# IF0 <---> IF1
+
+PCAP_IN=`find . ${TEST_DIR} $(dirname $0) -name udp64.pcap -print -quit`
+PCAP_OUT="pcapout.pcap"
+PCAP_IN_SIZE=`stat -c %s ${PCAP_IN}`
+echo "using PCAP in=${PCAP_IN}:out=${PCAP_OUT} size %${PCAP_IN_SIZE}"
+
+IF0=pcap:in=${PCAP_IN}:loops=10
+IF1=pcap:in=${PCAP_IN}:out=${PCAP_OUT}
+
+if [ "$0" = "$BASH_SOURCE" ]; then
+ echo "Error: Platform specific env file has to be sourced."
+fi
+
+validate_result()
+{
+ PCAP_OUT_SIZE=`stat -c %s ${PCAP_OUT}`
+ if [ ${PCAP_IN_SIZE} -ne ${PCAP_OUT_SIZE} ]; then
+ echo "Error: in:${PCAP_IN_SIZE} out:${PCAP_OUT_SIZE}"
+ exit 1
+ fi
+
+ rm -f pcapout.pcap
+}
+
+setup_interfaces()
+{
+ echo "pktio: setting up test interfaces $IF0, $IF1."
+ return 0
+}
+
+cleanup_interfaces()
+{
+ echo "pktio: cleaning up test interfaces $IF0, $IF1."
+ return 0
+}
diff --git a/platform/linux-generic/test/example/ping/Makefile.am b/platform/linux-generic/test/example/ping/Makefile.am
new file mode 100644
index 000000000..2ffced539
--- /dev/null
+++ b/platform/linux-generic/test/example/ping/Makefile.am
@@ -0,0 +1 @@
+EXTRA_DIST = pktio_env
diff --git a/platform/linux-generic/test/example/ping/pktio_env b/platform/linux-generic/test/example/ping/pktio_env
new file mode 100644
index 000000000..90106da9d
--- /dev/null
+++ b/platform/linux-generic/test/example/ping/pktio_env
@@ -0,0 +1,50 @@
+#!/bin/sh
+#
+# Copyright (C) 2020, Marvell
+# All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Script to setup interfaces used for running application on linux-generic.
+#
+# For linux-generic the default behavior is to create two pcap interfaces
+# and one interface uses udp64.pcap to inject traffic. An output pcap file
+# is generated via second interface.
+#
+# Network set-up
+# IF0 <---> IF1
+
+PCAP_IN=`find . ${TEST_DIR} $(dirname $0) -name icmp_echo_req.pcap -print -quit`
+PCAP_OUT="pcapout.pcap"
+PCAP_IN_SIZE=`stat -c %s ${PCAP_IN}`
+echo "using PCAP in=${PCAP_IN}:out=${PCAP_OUT} size %${PCAP_IN_SIZE}"
+
+IF0=pcap:in=${PCAP_IN}:out=${PCAP_OUT}
+
+if [ "$0" = "$BASH_SOURCE" ]; then
+ echo "Error: Platform specific env file has to be sourced."
+fi
+
+validate_result()
+{
+ PCAP_OUT_SIZE=`stat -c %s ${PCAP_OUT}`
+ if [ ${PCAP_IN_SIZE} -ne ${PCAP_OUT_SIZE} ]; then
+ echo "Error: in:${PCAP_IN_SIZE} out:${PCAP_OUT_SIZE}"
+ exit 1
+ fi
+
+ echo "pcap in size:${PCAP_IN_SIZE} pcap out size:${PCAP_OUT_SIZE}"
+ rm -f pcapout.pcap
+}
+
+setup_interfaces()
+{
+ echo "pktio: setting up test interfaces $IF0, $IF1."
+ return 0
+}
+
+cleanup_interfaces()
+{
+ echo "pktio: cleaning up test interfaces $IF0, $IF1."
+ return 0
+}
diff --git a/platform/linux-generic/test/example/simple_pipeline/Makefile.am b/platform/linux-generic/test/example/simple_pipeline/Makefile.am
new file mode 100644
index 000000000..2ffced539
--- /dev/null
+++ b/platform/linux-generic/test/example/simple_pipeline/Makefile.am
@@ -0,0 +1 @@
+EXTRA_DIST = pktio_env
diff --git a/platform/linux-generic/test/example/simple_pipeline/pktio_env b/platform/linux-generic/test/example/simple_pipeline/pktio_env
new file mode 100644
index 000000000..e1fbe87cc
--- /dev/null
+++ b/platform/linux-generic/test/example/simple_pipeline/pktio_env
@@ -0,0 +1,47 @@
+#!/bin/sh
+#
+# Copyright (C) 2020, Marvell
+# All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Script to setup interfaces used for running application on linux-generic.
+#
+# For linux-generic the default behavior is to create two pcap interfaces
+# and one interface uses udp64.pcap to inject traffic. An output pcap file
+# is generated via second interface.
+#
+# Network set-up
+# IF0 <---> IF1
+
+PCAP_IN=`find . ${TEST_DIR} $(dirname $0) -name udp64.pcap -print -quit`
+echo "using PCAP_IN = ${PCAP_IN}"
+
+IF0=pcap:in=${PCAP_IN}
+IF1=pcap:out=pcapout.pcap
+
+if [ "$0" = "$BASH_SOURCE" ]; then
+ echo "Error: Platform specific env file has to be sourced."
+fi
+
+validate_result()
+{
+ if [ `stat -c %s pcapout.pcap` -ne `stat -c %s ${PCAP_IN}` ]; then
+ echo "File sizes disagree"
+ exit 1
+ fi
+
+ rm -f pcapout.pcap
+}
+
+setup_interfaces()
+{
+ echo "pktio: setting up test interfaces $IF0, $IF1."
+ return 0
+}
+
+cleanup_interfaces()
+{
+ echo "pktio: cleaning up test interfaces $IF0, $IF1."
+ return 0
+}
diff --git a/platform/linux-generic/test/example/switch/Makefile.am b/platform/linux-generic/test/example/switch/Makefile.am
new file mode 100644
index 000000000..2ffced539
--- /dev/null
+++ b/platform/linux-generic/test/example/switch/Makefile.am
@@ -0,0 +1 @@
+EXTRA_DIST = pktio_env
diff --git a/platform/linux-generic/test/example/switch/pktio_env b/platform/linux-generic/test/example/switch/pktio_env
new file mode 100644
index 000000000..cbf5c4ddc
--- /dev/null
+++ b/platform/linux-generic/test/example/switch/pktio_env
@@ -0,0 +1,53 @@
+#!/bin/sh
+#
+# Copyright (C) 2020, Marvell
+# All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Script to setup interfaces used for running application on linux-generic.
+#
+# For linux-generic the default behavior is to create two pcap interfaces
+# and one interface uses udp64.pcap to inject traffic. An output pcap file
+# is generated via second interface.
+#
+# Network set-up
+# IF0 |---> IF1
+# |---> IF2
+# |---> IF3
+
+NUM_RX_PORT=3
+PCAP_IN=`find . ${TEST_DIR} $(dirname $0) -name udp64.pcap -print -quit`
+echo "Switch test using PCAP_IN = ${PCAP_IN}"
+
+IF0=pcap:in=${PCAP_IN}
+IF1=pcap:out=pcapout1.pcap
+IF2=pcap:out=pcapout2.pcap
+IF3=pcap:out=pcapout3.pcap
+
+if [ "$0" = "$BASH_SOURCE" ]; then
+ echo "Error: Platform specific env file has to be sourced."
+fi
+
+validate_result()
+{
+ for i in `seq 1 $NUM_RX_PORT`;
+ do
+ if [ `stat -c %s pcapout${i}.pcap` -ne `stat -c %s ${PCAP_IN}` ]; then
+ echo "Error: Output file $i size not matching"
+ fi
+ rm -f pcapout${i}.pcap
+ done
+}
+
+setup_interfaces()
+{
+ echo "pktio: setting up test interfaces $IF0, $IF1, $IF2, $IF3."
+ return 0
+}
+
+cleanup_interfaces()
+{
+ echo "pktio: cleaning up test interfaces $IF0, $IF1, $IF2, $IF3."
+ return 0
+}
diff --git a/platform/linux-generic/test/ipsec/ipsec_example.sh b/platform/linux-generic/test/ipsec/ipsec_crypto_example.sh
index e38350c03..d99fc3bd2 100755
--- a/platform/linux-generic/test/ipsec/ipsec_example.sh
+++ b/platform/linux-generic/test/ipsec/ipsec_crypto_example.sh
@@ -15,16 +15,16 @@ fi
# Absolute path to the example binary. This is needed during distcheck, which
# keeps scripts and binaries in different directories (scripts are not copied
# into the distribution directory).
-export IPSEC_EXAMPLE_PATH=$(pwd)/../../../example/ipsec
+export IPSEC_EXAMPLE_PATH=$(pwd)/../../../example/ipsec_crypto
declare -i RESULT=0
-pushd $(dirname $0)/../../../../example/ipsec
+pushd $(dirname $0)/../../../../example/ipsec_crypto
-./odp_ipsec_run_simple.sh
+./odp_ipsec_crypto_run_simple.sh
RESULT+=$?
-./odp_ipsec_run_esp_out.sh
+./odp_ipsec_crypto_run_esp_out.sh
RESULT+=$?
popd
diff --git a/platform/linux-generic/test/pktio_ipc/Makefile.am b/platform/linux-generic/test/pktio_ipc/Makefile.am
index 4287fbc08..b9623cc76 100644
--- a/platform/linux-generic/test/pktio_ipc/Makefile.am
+++ b/platform/linux-generic/test/pktio_ipc/Makefile.am
@@ -9,3 +9,23 @@ pktio_ipc2_SOURCES = pktio_ipc2.c ipc_common.c ipc_common.h
dist_check_SCRIPTS = pktio_ipc_run.sh
test_SCRIPTS = $(dist_check_SCRIPTS)
+
+# If building out-of-tree, make check will not copy the scripts and data to the
+# $(builddir) assuming that all commands are run locally. However this prevents
+# running tests on a remote target using LOG_COMPILER.
+# So copy all script and data files explicitly here.
+all-local:
+ if [ "x$(srcdir)" != "x$(builddir)" ]; then \
+ for f in $(dist_check_SCRIPTS); do \
+ if [ -e $(srcdir)/$$f ]; then \
+ mkdir -p $(builddir)/$$(dirname $$f); \
+ cp -f $(srcdir)/$$f $(builddir)/$$f; \
+ fi \
+ done \
+ fi
+clean-local:
+ if [ "x$(srcdir)" != "x$(builddir)" ]; then \
+ for f in $(dist_check_SCRIPTS); do \
+ rm -f $(builddir)/$$f; \
+ done \
+ fi
diff --git a/platform/linux-generic/test/validation/api/pktio/Makefile.am b/platform/linux-generic/test/validation/api/pktio/Makefile.am
index 385700de8..98b8b233d 100644
--- a/platform/linux-generic/test/validation/api/pktio/Makefile.am
+++ b/platform/linux-generic/test/validation/api/pktio/Makefile.am
@@ -13,3 +13,23 @@ dist_check_SCRIPTS += pktio_run_dpdk.sh
endif
test_SCRIPTS = $(dist_check_SCRIPTS)
+
+# If building out-of-tree, make check will not copy the scripts and data to the
+# $(builddir) assuming that all commands are run locally. However this prevents
+# running tests on a remote target using LOG_COMPILER.
+# So copy all script and data files explicitly here.
+all-local:
+ if [ "x$(srcdir)" != "x$(builddir)" ]; then \
+ for f in $(dist_check_SCRIPTS); do \
+ if [ -e $(srcdir)/$$f ]; then \
+ mkdir -p $(builddir)/$$(dirname $$f); \
+ cp -f $(srcdir)/$$f $(builddir)/$$f; \
+ fi \
+ done \
+ fi
+clean-local:
+ if [ "x$(srcdir)" != "x$(builddir)" ]; then \
+ for f in $(dist_check_SCRIPTS); do \
+ rm -f $(builddir)/$$f; \
+ done \
+ fi