diff options
Diffstat (limited to 'test/validation/api')
-rw-r--r-- | test/validation/api/classification/classification.h | 7 | ||||
-rw-r--r-- | test/validation/api/classification/odp_classification_basic.c | 45 | ||||
-rw-r--r-- | test/validation/api/classification/odp_classification_tests.c | 76 | ||||
-rw-r--r-- | test/validation/api/classification/odp_classification_testsuites.h | 3 | ||||
-rw-r--r-- | test/validation/api/crypto/odp_crypto_test_inp.c | 14 | ||||
-rw-r--r-- | test/validation/api/ipsec/ipsec.c | 9 | ||||
-rw-r--r-- | test/validation/api/pktio/pktio.c | 11 | ||||
-rw-r--r-- | test/validation/api/traffic_mngr/traffic_mngr.c | 218 |
8 files changed, 331 insertions, 52 deletions
diff --git a/test/validation/api/classification/classification.h b/test/validation/api/classification/classification.h index 4c8613555..70dcc6230 100644 --- a/test/validation/api/classification/classification.h +++ b/test/validation/api/classification/classification.h @@ -23,6 +23,11 @@ #define CLS_DEFAULT_SMAC {0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c} #define CLS_MAGIC_VAL 0xdeadbeef +/* Config values for Drop CoS */ +#define TEST_DROP 1 +#define CLS_DROP 6 +#define CLS_DROP_PORT 4001 + /* Config values for Error CoS */ #define TEST_ERROR 1 #define CLS_ERROR 1 @@ -47,7 +52,7 @@ /* Config values for CoS L2 Priority */ #define TEST_L2_QOS 1 -#define CLS_L2_QOS_0 6 +#define CLS_L2_QOS_0 7 #define CLS_L2_QOS_MAX 5 #define CLS_ENTRIES (CLS_L2_QOS_0 + CLS_L2_QOS_MAX) diff --git a/test/validation/api/classification/odp_classification_basic.c b/test/validation/api/classification/odp_classification_basic.c index 3aeb89462..fb5ec4ed0 100644 --- a/test/validation/api/classification/odp_classification_basic.c +++ b/test/validation/api/classification/odp_classification_basic.c @@ -52,6 +52,49 @@ static void classification_test_create_cos(void) odp_queue_destroy(queue); } +static void classification_test_create_cos_max_common(odp_bool_t stats) +{ + uint32_t i; + odp_cls_cos_param_t cls_param; + odp_cls_capability_t capa; + + CU_ASSERT_FATAL(odp_cls_capability(&capa) == 0); + + uint32_t num = capa.max_cos; + + if (stats && capa.max_cos_stats < num) + num = capa.max_cos_stats; + + odp_cos_t cos[num]; + + for (i = 0; i < num; i++) { + odp_cls_cos_param_init(&cls_param); + cls_param.action = ODP_COS_ACTION_DROP; + cls_param.stats_enable = stats; + + cos[i] = odp_cls_cos_create(NULL, &cls_param); + if (cos[i] == ODP_COS_INVALID) { + ODPH_ERR("odp_cls_cos_create() failed at CoS %u out of %u.\n", i + 1, num); + break; + } + } + + CU_ASSERT(i == num); + + for (uint32_t j = 0; j < i; j++) + CU_ASSERT(!odp_cos_destroy(cos[j])); +} + +static void classification_test_create_cos_max(void) +{ + classification_test_create_cos_max_common(false); +} + +static void classification_test_create_cos_max_stats(void) +{ + classification_test_create_cos_max_common(true); +} + static void classification_test_destroy_cos(void) { odp_cos_t cos; @@ -345,6 +388,8 @@ static void classification_test_pmr_composite_create(void) odp_testinfo_t classification_suite_basic[] = { ODP_TEST_INFO(classification_test_default_values), ODP_TEST_INFO(classification_test_create_cos), + ODP_TEST_INFO(classification_test_create_cos_max), + ODP_TEST_INFO(classification_test_create_cos_max_stats), ODP_TEST_INFO(classification_test_destroy_cos), ODP_TEST_INFO(classification_test_create_pmr_match), ODP_TEST_INFO(classification_test_cos_set_queue), diff --git a/test/validation/api/classification/odp_classification_tests.c b/test/validation/api/classification/odp_classification_tests.c index 41b4ab02f..4511fc1d7 100644 --- a/test/validation/api/classification/odp_classification_tests.c +++ b/test/validation/api/classification/odp_classification_tests.c @@ -23,6 +23,7 @@ static int global_num_l2_qos; #define NUM_COS_PMR_CHAIN 2 #define NUM_COS_DEFAULT 1 +#define NUM_COS_DROP 1 #define NUM_COS_ERROR 1 #define NUM_COS_L2_PRIO CLS_L2_QOS_MAX #define NUM_COS_PMR 1 @@ -453,6 +454,74 @@ void test_pktio_default_cos(odp_bool_t enable_pktv) odp_packet_free(pkt); } +void configure_pktio_drop_cos(odp_bool_t enable_pktv, uint32_t max_cos_stats) +{ + uint16_t val; + uint16_t mask; + odp_pmr_param_t pmr_param; + odp_cls_cos_param_t cls_param; + char cosname[ODP_COS_NAME_LEN]; + + sprintf(cosname, "DropCoS"); + odp_cls_cos_param_init(&cls_param); + + cls_param.action = ODP_COS_ACTION_DROP; + cls_param.stats_enable = max_cos_stats > 0; + + if (enable_pktv) { + cls_param.vector.enable = true; + cls_param.vector.pool = pktv_config.pool; + cls_param.vector.max_size = pktv_config.max_size; + cls_param.vector.max_tmo_ns = pktv_config.max_tmo_ns; + } + + cos_list[CLS_DROP] = odp_cls_cos_create(cosname, &cls_param); + CU_ASSERT_FATAL(cos_list[CLS_DROP] != ODP_COS_INVALID); + + val = odp_cpu_to_be_16(CLS_DROP_PORT); + mask = odp_cpu_to_be_16(0xffff); + odp_cls_pmr_param_init(&pmr_param); + pmr_param.term = find_first_supported_l3_pmr(); + pmr_param.match.value = &val; + pmr_param.match.mask = &mask; + pmr_param.val_sz = sizeof(val); + + pmr_list[CLS_DROP] = odp_cls_pmr_create(&pmr_param, 1, + cos_list[CLS_DEFAULT], + cos_list[CLS_DROP]); + CU_ASSERT_FATAL(pmr_list[CLS_DROP] != ODP_PMR_INVALID); +} + +void test_pktio_drop_cos(odp_bool_t enable_pktv) +{ + odp_packet_t pkt; + odp_queue_t queue; + uint32_t seqno = 0; + cls_packet_info_t pkt_info; + odp_cls_capability_t capa; + odp_cls_cos_stats_t start, stop; + + CU_ASSERT_FATAL(odp_cls_capability(&capa) == 0); + pkt_info = default_pkt_info; + pkt_info.l4_type = CLS_PKT_L4_UDP; + pkt = create_packet(pkt_info); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + seqno = cls_pkt_get_seq(pkt); + CU_ASSERT(seqno != TEST_SEQ_INVALID); + set_first_supported_pmr_port(pkt, CLS_DROP_PORT); + CU_ASSERT(odp_cls_cos_stats(cos_list[CLS_DROP], &start) == 0); + enqueue_pktio_interface(pkt, pktio_loop); + pkt = receive_packet(&queue, ODP_TIME_SEC_IN_NS, enable_pktv); + CU_ASSERT(odp_cls_cos_stats(cos_list[CLS_DROP], &stop) == 0); + CU_ASSERT_FATAL(pkt == ODP_PACKET_INVALID); + if (capa.stats.cos.counter.packets) + CU_ASSERT((stop.packets - start.packets) == 1); + if (capa.stats.cos.counter.discards) + CU_ASSERT((stop.discards - start.discards) == 0); + if (capa.stats.cos.counter.errors) + CU_ASSERT((stop.errors - start.errors) == 0); +} + static int classification_check_queue_stats(void) { odp_cls_capability_t capa; @@ -926,6 +995,11 @@ static void classification_test_pktio_configure_common(odp_bool_t enable_pktv) tc.default_cos = 1; num_cos -= NUM_COS_DEFAULT; } + if (num_cos >= NUM_COS_DEFAULT && TEST_DROP) { + configure_pktio_drop_cos(enable_pktv, capa.max_cos_stats); + tc.drop_cos = 1; + num_cos -= NUM_COS_DROP; + } if (num_cos >= NUM_COS_ERROR && TEST_ERROR) { configure_pktio_error_cos(enable_pktv); tc.error_cos = 1; @@ -969,6 +1043,8 @@ static void classification_test_pktio_test_common(odp_bool_t enable_pktv) /* Test Different CoS on the pktio interface */ if (tc.default_cos && TEST_DEFAULT) test_pktio_default_cos(enable_pktv); + if (tc.drop_cos && TEST_DROP) + test_pktio_drop_cos(enable_pktv); if (tc.error_cos && TEST_ERROR) test_pktio_error_cos(enable_pktv); if (tc.pmr_chain && TEST_PMR_CHAIN) diff --git a/test/validation/api/classification/odp_classification_testsuites.h b/test/validation/api/classification/odp_classification_testsuites.h index 2b5da94e2..6b00e138b 100644 --- a/test/validation/api/classification/odp_classification_testsuites.h +++ b/test/validation/api/classification/odp_classification_testsuites.h @@ -34,6 +34,7 @@ typedef struct cls_packet_info { typedef union odp_cls_testcase { struct { uint32_t default_cos:1; + uint32_t drop_cos:1; uint32_t error_cos:1; uint32_t pmr_chain:1; uint32_t l2_priority:1; @@ -72,6 +73,8 @@ odp_pool_t pktv_pool_create(const char *poolname); odp_queue_t queue_create(const char *queuename, bool sched); void configure_pktio_default_cos(odp_bool_t enable_pktv); void test_pktio_default_cos(odp_bool_t enable_pktv); +void configure_pktio_drop_cos(odp_bool_t enable_pktv, uint32_t max_cos_stats); +void test_pktio_drop_cos(odp_bool_t enable_pktv); void configure_pktio_error_cos(odp_bool_t enable_pktv); void test_pktio_error_cos(odp_bool_t enable_pktv); void configure_cls_pmr_chain(odp_bool_t enable_pktv); diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c index 721dfe8c9..97f721dd5 100644 --- a/test/validation/api/crypto/odp_crypto_test_inp.c +++ b/test/validation/api/crypto/odp_crypto_test_inp.c @@ -37,7 +37,9 @@ static void test_default_values(void) CU_ASSERT_EQUAL(param.op, ODP_CRYPTO_OP_ENCODE); CU_ASSERT_EQUAL(param.auth_cipher_text, false); +#if ODP_DEPRECATED_API CU_ASSERT_EQUAL(param.pref_mode, ODP_CRYPTO_SYNC); +#endif CU_ASSERT_EQUAL(param.op_mode, ODP_CRYPTO_SYNC); CU_ASSERT_EQUAL(param.cipher_alg, ODP_CIPHER_ALG_NULL); CU_ASSERT_EQUAL(param.cipher_iv_len, 0); @@ -194,6 +196,7 @@ static const char *cipher_alg_name(odp_cipher_alg_t cipher) } } +#if ODP_DEPRECATED_API static int alg_op(odp_packet_t pkt, odp_bool_t *ok, odp_crypto_session_t session, @@ -273,6 +276,7 @@ static int alg_op(odp_packet_t pkt, return 0; } +#endif static int alg_packet_op(odp_packet_t pkt, odp_bool_t *ok, @@ -370,10 +374,14 @@ static int crypto_op(odp_packet_t pkt, int rc; if (!suite_context.packet) +#if ODP_DEPRECATED_API rc = alg_op(pkt, ok, session, cipher_iv, auth_iv, cipher_range, auth_range, aad, hash_result_offset); +#else + rc = -1; +#endif else rc = alg_packet_op(pkt, ok, session, cipher_iv, auth_iv, @@ -657,7 +665,9 @@ static odp_crypto_session_t session_create(odp_crypto_op_t op, ses_params.op = op; ses_params.auth_cipher_text = false; ses_params.op_mode = suite_context.op_mode; +#if ODP_DEPRECATED_API ses_params.pref_mode = suite_context.pref_mode; +#endif ses_params.cipher_alg = cipher_alg; ses_params.auth_alg = auth_alg; ses_params.compl_queue = suite_context.queue; @@ -2154,6 +2164,7 @@ static odp_event_t plain_compl_queue_deq(void) return odp_queue_deq(suite_context.queue); } +#if ODP_DEPRECATED_API static int crypto_suite_sync_init(void) { suite_context.pool = odp_pool_lookup("packet_pool"); @@ -2206,6 +2217,7 @@ static int crypto_suite_async_sched_init(void) return 0; } +#endif static int crypto_suite_packet_sync_init(void) { @@ -2422,12 +2434,14 @@ odp_testinfo_t crypto_suite[] = { }; odp_suiteinfo_t crypto_suites[] = { +#if ODP_DEPRECATED_API {"odp_crypto_sync_inp", crypto_suite_sync_init, NULL, crypto_suite}, {"odp_crypto_async_plain_inp", crypto_suite_async_plain_init, crypto_suite_term, crypto_suite}, {"odp_crypto_async_sched_inp", crypto_suite_async_sched_init, crypto_suite_term, crypto_suite}, +#endif {"odp_crypto_packet_sync_inp", crypto_suite_packet_sync_init, NULL, crypto_suite}, {"odp_crypto_packet_async_plain_inp", diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c index 88f204ea4..d12234a5a 100644 --- a/test/validation/api/ipsec/ipsec.c +++ b/test/validation/api/ipsec/ipsec.c @@ -281,10 +281,6 @@ int ipsec_check_esp_chacha20_poly1305(void) int ipsec_check_test_sa_update_seq_num(void) { - odp_ipsec_capability_t capa; - - odp_ipsec_capability(&capa); - if (!capa.test.sa_operations.seq_num) return ODP_TEST_INACTIVE; @@ -942,9 +938,8 @@ static void verify_in(const ipsec_test_part *part, result.orig_ip_len == len); } } - ipsec_check_packet(part->out[i].pkt_res, - pkto[i], - false); + if (part->out[i].l3_type != ODP_PROTO_L3_TYPE_NONE) + ipsec_check_packet(part->out[i].pkt_res, pkto[i], false); if (suite_context.inbound_op_mode == ODP_IPSEC_OP_MODE_INLINE) expected_user_ptr = NULL; CU_ASSERT(odp_packet_user_ptr(pkto[i]) == expected_user_ptr); diff --git a/test/validation/api/pktio/pktio.c b/test/validation/api/pktio/pktio.c index 9144e1260..f6408c788 100644 --- a/test/validation/api/pktio/pktio.c +++ b/test/validation/api/pktio/pktio.c @@ -770,8 +770,8 @@ static int recv_packets_tmo(odp_pktio_t pktio, odp_packet_t pkt_tbl[], int num_q; int i; int n; - unsigned int from_val = 0; - unsigned *from = NULL; + uint32_t from_val = 0; + uint32_t *from = NULL; if (mode == RECV_MQ_TMO) from = &from_val; @@ -787,8 +787,7 @@ static int recv_packets_tmo(odp_pktio_t pktio, odp_packet_t pkt_tbl[], n = odp_pktin_recv_tmo(pktin[0], pkt_tmp, num - num_rx, tmo); else - n = odp_pktin_recv_mq_tmo(pktin, (unsigned)num_q, - from, pkt_tmp, + n = odp_pktin_recv_mq_tmo(pktin, (uint32_t)num_q, from, pkt_tmp, num - num_rx, tmo); ts2 = odp_time_global(); @@ -812,7 +811,7 @@ static int recv_packets_tmo(odp_pktio_t pktio, odp_packet_t pkt_tbl[], odp_packet_free(pkt_tmp[i]); } if (mode == RECV_MQ_TMO) - CU_ASSERT(from_val < (unsigned)num_q); + CU_ASSERT(from_val < (uint32_t)num_q); } while (num_rx < num); if (num_rx < num) { @@ -1265,7 +1264,7 @@ static void test_recv_tmo(recv_tmo_mode_e mode) odp_packet_t pkt_tbl[test_pkt_count]; uint32_t pkt_seq[test_pkt_count]; uint64_t ns; - unsigned num_q; + uint32_t num_q; int ret; int i; diff --git a/test/validation/api/traffic_mngr/traffic_mngr.c b/test/validation/api/traffic_mngr/traffic_mngr.c index cab1fd06d..65f91192c 100644 --- a/test/validation/api/traffic_mngr/traffic_mngr.c +++ b/test/validation/api/traffic_mngr/traffic_mngr.c @@ -120,6 +120,12 @@ typedef enum { SHAPER_PROFILE, SCHED_PROFILE, THRESHOLD_PROFILE, WRED_PROFILE } profile_kind_t; +typedef enum { + THRESHOLD_BYTE, + THRESHOLD_PACKET, + THRESHOLD_BYTE_AND_PACKET +} threshold_type_t; + typedef struct { uint32_t num_queues; odp_tm_queue_t tm_queues[]; @@ -516,6 +522,7 @@ static int open_pktios(void) uint32_t iface; char pool_name[ODP_POOL_NAME_LEN]; int rc, ret; + int pkt_aging = 0; int lso = 0; odp_pool_param_init(&pool_param); @@ -620,6 +627,12 @@ static int open_pktios(void) odp_pktio_config_init(&pktio_config); + /* Enable packet aging if supported */ + if (xmt_pktio_capa.max_tx_aging_tmo_ns) { + pkt_aging = 1; + pktio_config.pktout.bit.aging_ena = 1; + } + /* Enable LSO if supported */ if (xmt_pktio_capa.lso.max_profiles && xmt_pktio_capa.lso.max_profiles_per_pktio) { lso = 1; @@ -627,7 +640,7 @@ static int open_pktios(void) } /* Enable selected features */ - if (lso) { + if (lso || pkt_aging) { if (odp_pktio_config(xmt_pktio, &pktio_config)) { ODPH_ERR("pktio configure failed\n"); return -1; @@ -693,15 +706,16 @@ static int get_unique_id(odp_packet_t odp_pkt, /* For IPv4 pkts use the ident field to store the unique_id. */ ident_offset = l3_offset + offsetof(odph_ipv4hdr_t, id); - odp_packet_copy_to_mem(odp_pkt, ident_offset, 2, &be_ip_ident); + CU_ASSERT_FATAL(odp_packet_copy_to_mem(odp_pkt, ident_offset, 2, + &be_ip_ident) == 0); unique_id = odp_be_to_cpu_16(be_ip_ident); is_ipv4 = true; } else if (odp_packet_has_ipv6(odp_pkt)) { /* For IPv6 pkts use the flow field to store the unique_id. */ flow_offset = l3_offset + offsetof(odph_ipv6hdr_t, ver_tc_flow); - odp_packet_copy_to_mem(odp_pkt, flow_offset, 4, - &be_ver_tc_flow); + CU_ASSERT_FATAL(odp_packet_copy_to_mem(odp_pkt, flow_offset, 4, + &be_ver_tc_flow) == 0); ver_tc_flow = odp_be_to_cpu_32(be_ver_tc_flow); unique_id = ver_tc_flow & ODPH_IPV6HDR_FLOW_LABEL_MASK; is_ipv4 = false; @@ -1818,11 +1832,15 @@ set_reqs_based_on_capas(odp_tm_requirements_t *req) req->tm_queue_dual_slope_needed = true; if (tm_capabilities.vlan_marking_supported) req->vlan_marking_needed = true; - if (tm_capabilities.tm_queue_threshold) + if (tm_capabilities.tm_queue_threshold.byte || + tm_capabilities.tm_queue_threshold.packet || + tm_capabilities.tm_queue_threshold.byte_and_packet) req->tm_queue_threshold_needed = true; for (j = 0; j < tm_capabilities.max_levels; j++) { - if (tm_capabilities.per_level[j].tm_node_threshold) + if (tm_capabilities.per_level[j].tm_node_threshold.byte || + tm_capabilities.per_level[j].tm_node_threshold.packet || + tm_capabilities.per_level[j].tm_node_threshold.byte_and_packet) req->per_level[j].tm_node_threshold_needed = true; } @@ -2638,7 +2656,8 @@ static void traffic_mngr_test_sched_profile(void) } static void check_threshold_profile(char *threshold_name, - uint32_t threshold_idx) + uint32_t threshold_idx, + threshold_type_t threshold) { odp_tm_threshold_params_t threshold_params; odp_tm_threshold_t profile; @@ -2657,15 +2676,17 @@ static void check_threshold_profile(char *threshold_name, if (ret) return; - CU_ASSERT(threshold_params.max_pkts == - threshold_idx * MIN_PKT_THRESHOLD); - CU_ASSERT(threshold_params.max_bytes == - threshold_idx * MIN_BYTE_THRESHOLD); - CU_ASSERT(threshold_params.enable_max_pkts == 1); - CU_ASSERT(threshold_params.enable_max_bytes == 1); + if (threshold == THRESHOLD_PACKET || threshold == THRESHOLD_BYTE_AND_PACKET) { + CU_ASSERT(threshold_params.enable_max_pkts == 1); + CU_ASSERT(threshold_params.max_pkts == threshold_idx * MIN_PKT_THRESHOLD); + } + if (threshold == THRESHOLD_BYTE || threshold == THRESHOLD_BYTE_AND_PACKET) { + CU_ASSERT(threshold_params.enable_max_bytes == 1); + CU_ASSERT(threshold_params.max_bytes == threshold_idx * MIN_BYTE_THRESHOLD); + } } -static void traffic_mngr_test_threshold_profile(void) +static void traffic_mngr_test_threshold_profile(threshold_type_t threshold) { odp_tm_threshold_params_t threshold_params; odp_tm_threshold_t profile; @@ -2673,14 +2694,19 @@ static void traffic_mngr_test_threshold_profile(void) char threshold_name[TM_NAME_LEN]; odp_tm_threshold_params_init(&threshold_params); - threshold_params.enable_max_pkts = 1; - threshold_params.enable_max_bytes = 1; + + if (threshold == THRESHOLD_PACKET || threshold == THRESHOLD_BYTE_AND_PACKET) + threshold_params.enable_max_pkts = 1; + if (threshold == THRESHOLD_BYTE || threshold == THRESHOLD_BYTE_AND_PACKET) + threshold_params.enable_max_bytes = 1; for (idx = 1; idx <= NUM_THRESH_TEST_PROFILES; idx++) { snprintf(threshold_name, sizeof(threshold_name), "threshold_profile_%" PRIu32, idx); - threshold_params.max_pkts = idx * MIN_PKT_THRESHOLD; - threshold_params.max_bytes = idx * MIN_BYTE_THRESHOLD; + if (threshold == THRESHOLD_PACKET || threshold == THRESHOLD_BYTE_AND_PACKET) + threshold_params.max_pkts = idx * MIN_PKT_THRESHOLD; + if (threshold == THRESHOLD_BYTE || threshold == THRESHOLD_BYTE_AND_PACKET) + threshold_params.max_bytes = idx * MIN_BYTE_THRESHOLD; profile = odp_tm_threshold_create(threshold_name, &threshold_params); @@ -2702,10 +2728,30 @@ static void traffic_mngr_test_threshold_profile(void) threshold_idx = ((3 + 7 * idx) % NUM_THRESH_TEST_PROFILES) + 1; snprintf(threshold_name, sizeof(threshold_name), "threshold_profile_%" PRIu32, threshold_idx); - check_threshold_profile(threshold_name, threshold_idx); + check_threshold_profile(threshold_name, threshold_idx, threshold); + } + + for (i = 0; i < NUM_THRESH_TEST_PROFILES; i++) { + CU_ASSERT(odp_tm_threshold_destroy(threshold_profiles[i]) == 0); + num_threshold_profiles--; } } +static void traffic_mngr_test_threshold_profile_byte(void) +{ + traffic_mngr_test_threshold_profile(THRESHOLD_BYTE); +} + +static void traffic_mngr_test_threshold_profile_packet(void) +{ + traffic_mngr_test_threshold_profile(THRESHOLD_PACKET); +} + +static void traffic_mngr_test_threshold_profile_byte_and_packet(void) +{ + traffic_mngr_test_threshold_profile(THRESHOLD_BYTE_AND_PACKET); +} + static void check_wred_profile(char *wred_name, uint32_t wred_idx, uint32_t color) @@ -3353,6 +3399,7 @@ static int test_sched_wfq(const char *sched_base_name, if (FANIN_RATIO <= fanin) fanin = 0; } + CU_ASSERT(pkts_sent == pkt_cnt + 4); busy_wait(1000000); /* wait 1 millisecond */ @@ -3433,7 +3480,8 @@ static int test_threshold(const char *threshold_name, odp_tm_threshold_params_t threshold_params; odp_tm_queue_t tm_queue; pkt_info_t pkt_info; - uint32_t num_pkts, pkt_len, pkts_sent; + uint32_t pkt_len, pkts_sent; + uint32_t num_pkts = 0; odp_tm_threshold_params_init(&threshold_params); if (max_pkts != 0) { @@ -3442,16 +3490,19 @@ static int test_threshold(const char *threshold_name, threshold_params.enable_max_pkts = true; num_pkts = 2 * max_pkts; pkt_len = 256; - } else if (max_bytes != 0) { + } + + if (max_bytes != 0) { max_bytes = MIN(max_bytes, MAX_PKTS * MAX_PAYLOAD / 3); threshold_params.max_bytes = max_bytes; threshold_params.enable_max_bytes = true; num_pkts = 2 * max_bytes / MAX_PAYLOAD; pkt_len = MAX_PAYLOAD; - } else { - return -1; } + if (max_pkts == 0 && max_bytes == 0) + return -1; + /* Pick a tm_queue and set the tm_queue's threshold profile and then * send in twice the amount of traffic as suggested by the thresholds * and make sure at least SOME pkts get dropped. */ @@ -4366,6 +4417,40 @@ static int test_fanin_info(const char *node_name) return walk_tree_backwards(node_desc->node); } +static void test_packet_aging(uint64_t tmo_ns, uint32_t pkt_len, odp_bool_t is_dropping) +{ + odp_tm_queue_t tm_queue; + const char *node_name = "node_1_1_1"; + const char *shaper_name = "test_shaper"; + const uint64_t rate = 256 * 1000; + pkt_info_t pkt_info; + const uint16_t num_pkts = 4; + int recv_pkts; + + tm_queue = find_tm_queue(0, node_name, 0); + CU_ASSERT_FATAL(tm_queue != ODP_TM_INVALID); + init_xmt_pkts(&pkt_info); + pkt_info.drop_eligible = false; + pkt_info.pkt_class = 1; + CU_ASSERT_FATAL(make_pkts(num_pkts, pkt_len, &pkt_info) == 0); + + for (int i = 0; i < num_pkts; i++) + odp_packet_aging_tmo_set(xmt_pkts[i], tmo_ns); + + CU_ASSERT_FATAL(set_shaper(node_name, shaper_name, rate, rate) == 0); + CU_ASSERT(send_pkts(tm_queue, num_pkts) == num_pkts); + recv_pkts = receive_pkts(odp_tm_systems[0], rcv_pktin, num_pkts, MBPS); + + if (is_dropping) + CU_ASSERT(recv_pkts < num_pkts) + else + CU_ASSERT(recv_pkts == num_pkts); + + set_shaper(node_name, NULL, 0, 0); + flush_leftover_pkts(odp_tm_systems[0], rcv_pktin); + CU_ASSERT(odp_tm_is_idle(odp_tm_systems[0])); +} + static void traffic_mngr_test_default_values(void) { odp_tm_requirements_t req; @@ -4517,25 +4602,51 @@ static void traffic_mngr_test_scheduler(void) INCREASING_WEIGHTS) == 0); } -static int traffic_mngr_check_thresholds(void) +static int traffic_mngr_check_thresholds_byte(void) { - /* Check only for tm queue threshold support as - * we only test queue threshold. - */ - if (!tm_capabilities.tm_queue_threshold) + /* Check only for TM queue threshold support as we only test queue threshold. */ + if (!tm_capabilities.tm_queue_threshold.byte) return ODP_TEST_INACTIVE; return ODP_TEST_ACTIVE; } -static void traffic_mngr_test_thresholds(void) +static int traffic_mngr_check_thresholds_packet(void) { - CU_ASSERT(test_threshold("thresh_A", "shaper_A", "node_1_2_1", 0, - 16, 0) == 0); - CU_ASSERT(test_threshold("thresh_B", "shaper_B", "node_1_2_1", 1, + /* Check only for TM queue threshold support as we only test queue threshold. */ + if (!tm_capabilities.tm_queue_threshold.packet) + return ODP_TEST_INACTIVE; + + return ODP_TEST_ACTIVE; +} + +static int traffic_mngr_check_thresholds_byte_and_packet(void) +{ + /* Check only for TM queue threshold support as we only test queue threshold. */ + if (!tm_capabilities.tm_queue_threshold.byte_and_packet) + return ODP_TEST_INACTIVE; + + return ODP_TEST_ACTIVE; +} + +static void traffic_mngr_test_thresholds_byte(void) +{ + CU_ASSERT(test_threshold("thresh_byte", "shaper_B", "node_1_2_1", 1, 0, 6400) == 0); } +static void traffic_mngr_test_thresholds_packet(void) +{ + CU_ASSERT(test_threshold("thresh_packet", "shaper_A", "node_1_2_1", 0, + 16, 0) == 0); +} + +static void traffic_mngr_test_thresholds_byte_and_packet(void) +{ + CU_ASSERT(test_threshold("thresh_byte_and_packet", "shaper_A", "node_1_2_1", 0, + 16, 6400) == 0); +} + static int traffic_mngr_check_queue_stats(void) { if (tm_capabilities.queue_stats.all_counters == 0) @@ -4617,7 +4728,8 @@ static int traffic_mngr_check_wred(void) static int traffic_mngr_check_byte_wred(void) { /* Check if wred is part of created odp_tm_t capabilities */ - if (!tm_capabilities.tm_queue_wred_supported) + if (!tm_capabilities.tm_queue_wred_supported || + !tm_capabilities.tm_queue_threshold.byte) return ODP_TEST_INACTIVE; if ((tm_shaper_min_rate > 64 * 1000) || @@ -4631,7 +4743,8 @@ static int traffic_mngr_check_byte_wred(void) static int traffic_mngr_check_pkt_wred(void) { /* Check if wred is part of created odp_tm_t capabilities */ - if (!tm_capabilities.tm_queue_wred_supported) + if (!tm_capabilities.tm_queue_wred_supported || + !tm_capabilities.tm_queue_threshold.packet) return ODP_TEST_INACTIVE; if ((tm_shaper_min_rate > 64 * 1000) || @@ -4772,6 +4885,23 @@ static void traffic_mngr_test_ecn_drop_prec_marking(void) CU_ASSERT(ip_marking_tests("node_1_4_2", true, true) == 0); } +static int traffic_mngr_check_tx_aging(void) +{ + return xmt_pktio_capa.max_tx_aging_tmo_ns ? ODP_TEST_ACTIVE : ODP_TEST_INACTIVE; +} + +static void traffic_mngr_test_tx_aging_no_drop(void) +{ + /* Set very long aging tmo, packets should not be dropped due to aging */ + test_packet_aging(60000000000, 128, false); +} + +static void traffic_mngr_test_tx_aging_drop(void) +{ + /* Set very short aging tmo, there should be drops due to aging */ + test_packet_aging(10, MAX_PAYLOAD, true); +} + static void traffic_mngr_test_fanin_info(void) { CU_ASSERT(test_fanin_info("node_1") == 0); @@ -4845,16 +4975,24 @@ odp_testinfo_t traffic_mngr_suite[] = { ODP_TEST_INFO(traffic_mngr_test_tm_create), ODP_TEST_INFO(traffic_mngr_test_shaper_profile), ODP_TEST_INFO(traffic_mngr_test_sched_profile), - ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_threshold_profile, - traffic_mngr_check_thresholds), + ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_threshold_profile_byte, + traffic_mngr_check_thresholds_byte), + ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_threshold_profile_packet, + traffic_mngr_check_thresholds_packet), + ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_threshold_profile_byte_and_packet, + traffic_mngr_check_thresholds_byte_and_packet), ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_wred_profile, traffic_mngr_check_wred), ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_shaper, traffic_mngr_check_shaper), ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_scheduler, traffic_mngr_check_scheduler), - ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_thresholds, - traffic_mngr_check_thresholds), + ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_thresholds_byte, + traffic_mngr_check_thresholds_byte), + ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_thresholds_packet, + traffic_mngr_check_thresholds_packet), + ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_thresholds_byte_and_packet, + traffic_mngr_check_thresholds_byte_and_packet), ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_byte_wred, traffic_mngr_check_byte_wred), ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_pkt_wred, @@ -4871,6 +5009,10 @@ odp_testinfo_t traffic_mngr_suite[] = { traffic_mngr_check_drop_prec_marking), ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_ecn_drop_prec_marking, traffic_mngr_check_ecn_drop_prec_marking), + ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_tx_aging_no_drop, + traffic_mngr_check_tx_aging), + ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_tx_aging_drop, + traffic_mngr_check_tx_aging), ODP_TEST_INFO(traffic_mngr_test_fanin_info), ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_lso_ipv4, traffic_mngr_check_lso_ipv4), ODP_TEST_INFO(traffic_mngr_test_destroy), |