aboutsummaryrefslogtreecommitdiff
path: root/test/validation
diff options
context:
space:
mode:
authorNithin Dabilpuram <ndabilpuram@marvell.com>2021-07-06 22:12:58 +0530
committerMatias Elo <matias.elo@nokia.com>2021-07-12 11:17:15 +0300
commit222c52764b4c2daf80b607fb7e7ba17c8264e4e2 (patch)
tree801e232b5dc2193135fa0fc9b674cfa864a2d715 /test/validation
parente936d16670932cf80b822889cfb8d0490c30a92f (diff)
validation: tm: check egress capabilities before running tests
Use egress capabilities to identify if different features are supported before running the test for features like, threshold, pkt marking, wred etc. Also mark test as inactive if required number of levels, queues or nodes are not supported for a test suite. This patch also splits marking tests to subtests for better control and replaces odp_tm_capabilities() calls with odp_tm_egress_capabilities() Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com> Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
Diffstat (limited to 'test/validation')
-rw-r--r--test/validation/api/traffic_mngr/traffic_mngr.c315
1 files changed, 197 insertions, 118 deletions
diff --git a/test/validation/api/traffic_mngr/traffic_mngr.c b/test/validation/api/traffic_mngr/traffic_mngr.c
index 71cf0aca6..f9dcd04d0 100644
--- a/test/validation/api/traffic_mngr/traffic_mngr.c
+++ b/test/validation/api/traffic_mngr/traffic_mngr.c
@@ -20,7 +20,6 @@
#define TM_DEBUG 0
-#define MAX_CAPABILITIES 16
#define MAX_NUM_IFACES 2
#define MAX_TM_SYSTEMS 3
#define NUM_LEVELS 3
@@ -386,35 +385,29 @@ static odp_bool_t approx_eq64(uint64_t val, uint64_t correct)
static int test_overall_capabilities(void)
{
odp_tm_level_capabilities_t *per_level;
- odp_tm_capabilities_t capabilities_array[MAX_CAPABILITIES];
+ odp_tm_capabilities_t capabilities_array[2];
odp_tm_capabilities_t *cap_ptr;
+ odp_tm_egress_t egress;
uint32_t num_records, idx, num_levels, level;
int rc;
- rc = odp_tm_capabilities(capabilities_array, MAX_CAPABILITIES);
- if (rc < 0) {
- CU_ASSERT(rc < 0);
- return -1;
- }
+ odp_tm_egress_init(&egress);
+ egress.egress_kind = ODP_TM_EGRESS_PKT_IO;
+ egress.pktio = xmt_pktio;
- /* Now test the return code (which did not indicate a failure code)
- * to make sure that there is at least ONE capabilities record
- * returned */
- if (rc == 0) {
- CU_ASSERT(rc != 0);
- return -1;
- }
+ rc = odp_tm_egress_capabilities(&capabilities_array[0], &egress);
+ CU_ASSERT_FATAL(rc == 0);
+ num_records = 1;
- /* Now test the return code to see if there were more capabilities
- * records than the call above allowed for. This is not an error,
- * just an interesting fact.
- */
- num_records = MAX_CAPABILITIES;
- if (MAX_CAPABILITIES < rc)
- ODPH_DBG("There were more than %u capabilities (%u)\n",
- MAX_CAPABILITIES, rc);
- else
- num_records = rc;
+ /* Get capabilities for egress kind function. */
+ odp_tm_egress_init(&egress);
+ egress.egress_kind = ODP_TM_EGRESS_FN;
+ rc = odp_tm_egress_capabilities(&capabilities_array[1], &egress);
+ CU_ASSERT_FATAL(rc == 0);
+
+ /* Validate this record only if egress function is supported */
+ if (capabilities_array[1].max_tm_queues)
+ num_records++;
/* Loop through the returned capabilities (there MUST be at least one)
* and do some basic checks to prove that it isn't just an empty
@@ -1649,12 +1642,50 @@ static uint32_t find_child_queues(uint8_t tm_system_idx,
return num_queues;
}
+static void
+set_reqs_based_on_capas(odp_tm_requirements_t *req)
+{
+ odp_packet_color_t color;
+ int j;
+
+ /* Use tm capabilities identified based on egress capabilities
+ * to see what can be enabled.
+ */
+ if (tm_capabilities.ecn_marking_supported)
+ req->ecn_marking_needed = true;
+ if (tm_capabilities.drop_prec_marking_supported)
+ req->drop_prec_marking_needed = true;
+ if (tm_capabilities.tm_queue_wred_supported)
+ req->tm_queue_wred_needed = true;
+ if (tm_capabilities.tm_queue_dual_slope_supported)
+ req->tm_queue_dual_slope_needed = true;
+ if (tm_capabilities.vlan_marking_supported)
+ req->vlan_marking_needed = true;
+ if (tm_capabilities.tm_queue_threshold)
+ req->tm_queue_threshold_needed = true;
+
+ for (j = 0; j < tm_capabilities.max_levels; j++) {
+ if (tm_capabilities.per_level[j].tm_node_threshold)
+ req->per_level[j].tm_node_threshold_needed = true;
+ }
+
+ /* Mark colors as needed if at least one of the marking
+ * feature is needed.
+ * */
+ if (req->ecn_marking_needed || req->drop_prec_marking_needed) {
+ for (color = 0; color < ODP_NUM_PACKET_COLORS; color++)
+ req->marking_colors_needed[color] = true;
+ }
+
+ if (tm_capabilities.tm_queue_shaper_supported)
+ req->tm_queue_shaper_needed = true;
+}
+
static int create_tm_system(void)
{
odp_tm_level_requirements_t *per_level;
odp_tm_requirements_t requirements;
odp_tm_egress_t egress;
- odp_packet_color_t color;
tm_node_desc_t *root_node_desc;
uint32_t level, max_nodes[ODP_TM_MAX_LEVELS];
odp_tm_t odp_tm, found_odp_tm;
@@ -1664,16 +1695,10 @@ static int create_tm_system(void)
odp_tm_requirements_init(&requirements);
odp_tm_egress_init(&egress);
- requirements.max_tm_queues = NUM_TM_QUEUES + 1;
+ requirements.max_tm_queues = NUM_TM_QUEUES;
requirements.num_levels = NUM_LEVELS;
- requirements.tm_queue_shaper_needed = true;
- requirements.tm_queue_wred_needed = true;
- requirements.tm_queue_dual_slope_needed = true;
- requirements.vlan_marking_needed = false;
- requirements.ecn_marking_needed = true;
- requirements.drop_prec_marking_needed = true;
- for (color = 0; color < ODP_NUM_PACKET_COLORS; color++)
- requirements.marking_colors_needed[color] = true;
+
+ set_reqs_based_on_capas(&requirements);
/* Set the max_num_tm_nodes to be double the expected number of nodes
* at that level */
@@ -1701,10 +1726,8 @@ static int create_tm_system(void)
snprintf(tm_name, sizeof(tm_name), "TM_system_%" PRIu32,
num_odp_tm_systems);
odp_tm = odp_tm_create(tm_name, &requirements, &egress);
- if (odp_tm == ODP_TM_INVALID) {
- ODPH_ERR("odp_tm_create() failed\n");
- return -1;
- }
+ CU_ASSERT_FATAL(odp_tm != ODP_TM_INVALID);
+
odp_tm_systems[num_odp_tm_systems] = odp_tm;
@@ -2144,9 +2167,10 @@ static int destroy_tm_systems(void)
static int traffic_mngr_suite_init(void)
{
- odp_tm_capabilities_t capabilities_array[MAX_CAPABILITIES];
+ odp_tm_capabilities_t egress_capa;
uint32_t payload_len, copy_len;
- int ret, i;
+ odp_tm_egress_t egress;
+ int j, ret;
/* Initialize some global variables. */
num_pkts_made = 0;
@@ -2195,27 +2219,50 @@ static int traffic_mngr_suite_init(void)
if (ret > 0)
goto skip_tests;
- /* Fetch initial dynamic update capabilities, it will be updated
- * later after TM system is created.
- */
- ret = odp_tm_capabilities(capabilities_array, MAX_CAPABILITIES);
- if (ret <= 0)
- return -1;
+ odp_tm_egress_init(&egress);
+ egress.egress_kind = ODP_TM_EGRESS_PKT_IO;
+ egress.pktio = xmt_pktio;
- for (i = 0; i < ret; i++) {
- if (!capabilities_array[i].dynamic_shaper_update)
- dynamic_shaper_update = false;
+ /* Get TM capabilities */
+ ret = odp_tm_egress_capabilities(&egress_capa, &egress);
+ if (ret) {
+ ODPH_ERR("Failed to retrieve tm capabilities");
+ return ret;
+ }
- if (!capabilities_array[i].dynamic_sched_update)
- dynamic_sched_update = false;
+ /* Check for sufficient TM queues */
+ if (egress_capa.max_tm_queues < NUM_TM_QUEUES)
+ goto skip_tests;
- if (!capabilities_array[i].dynamic_threshold_update)
- dynamic_threshold_update = false;
+ /* Check for sufficient TM levels */
+ if (egress_capa.max_levels < NUM_LEVELS)
+ goto skip_tests;
- if (!capabilities_array[i].dynamic_wred_update)
- dynamic_wred_update = false;
+ for (j = 0; j < NUM_LEVELS; j++) {
+ /* Per node fanin */
+ if (egress_capa.per_level[j].max_fanin_per_node <
+ FANIN_RATIO)
+ break;
}
+ if (j != NUM_LEVELS)
+ goto skip_tests;
+
+ /* Init tm capabilities with matching egress capa until tm is created */
+ tm_capabilities = egress_capa;
+
+ if (!tm_capabilities.dynamic_shaper_update)
+ dynamic_shaper_update = false;
+
+ if (!tm_capabilities.dynamic_sched_update)
+ dynamic_sched_update = false;
+
+ if (!tm_capabilities.dynamic_threshold_update)
+ dynamic_threshold_update = false;
+
+ if (!tm_capabilities.dynamic_wred_update)
+ dynamic_wred_update = false;
+
return 0;
skip_tests:
/* Mark all tests as inactive under this suite */
@@ -4147,6 +4194,17 @@ static void traffic_mngr_test_scheduler(void)
INCREASING_WEIGHTS) == 0);
}
+static int traffic_mngr_check_thresholds(void)
+{
+ /* Check only for tm queue threshold support as
+ * we only test queue threshold.
+ */
+ if (!tm_capabilities.tm_queue_threshold)
+ return ODP_TEST_INACTIVE;
+
+ return ODP_TEST_ACTIVE;
+}
+
static void traffic_mngr_test_thresholds(void)
{
CU_ASSERT(test_threshold("thresh_A", "shaper_A", "node_1_2_1", 0,
@@ -4157,12 +4215,7 @@ static void traffic_mngr_test_thresholds(void)
static int traffic_mngr_check_queue_stats(void)
{
- odp_tm_capabilities_t capa;
-
- if (odp_tm_capabilities(&capa, 1) < 1)
- return ODP_TEST_INACTIVE;
-
- if (capa.queue_stats.all_counters == 0)
+ if (tm_capabilities.queue_stats.all_counters == 0)
return ODP_TEST_INACTIVE;
return ODP_TEST_ACTIVE;
@@ -4229,14 +4282,17 @@ static void traffic_mngr_test_queue_stats(void)
CU_ASSERT(odp_tm_is_idle(odp_tm_systems[0]));
}
-static void traffic_mngr_test_byte_wred(void)
+static int traffic_mngr_check_wred(void)
{
- if (!tm_capabilities.tm_queue_wred_supported) {
- ODPH_DBG("\nwas not run because tm_capabilities indicates"
- " no WRED support\n");
- return;
- }
+ /* Check if wred is part of created odp_tm_t capabilities */
+ if (!tm_capabilities.tm_queue_wred_supported)
+ return ODP_TEST_INACTIVE;
+ return ODP_TEST_ACTIVE;
+}
+
+static void traffic_mngr_test_byte_wred(void)
+{
CU_ASSERT(test_byte_wred("byte_wred_30G", "byte_bw_30G",
"byte_thresh_30G", "node_1_3_1", 1,
ODP_PACKET_GREEN, TM_PERCENT(30), true) == 0);
@@ -4256,12 +4312,6 @@ static void traffic_mngr_test_pkt_wred(void)
{
int rc;
- if (!tm_capabilities.tm_queue_wred_supported) {
- ODPH_DBG("\ntest_pkt_wred was not run because tm_capabilities "
- "indicates no WRED support\n");
- return;
- }
-
rc = test_pkt_wred("pkt_wred_40G", "pkt_bw_40G",
"pkt_thresh_40G", "node_1_3_2", 1,
ODP_PACKET_GREEN, TM_PERCENT(30), false);
@@ -4293,59 +4343,75 @@ static void traffic_mngr_test_pkt_wred(void)
CU_FAIL("70Y test failed\n");
}
+static int traffic_mngr_check_query(void)
+{
+ uint32_t query_flags = (ODP_TM_QUERY_PKT_CNT | ODP_TM_QUERY_BYTE_CNT);
+
+ /* We need both pkt count and byte count query support */
+ if ((tm_capabilities.tm_queue_query_flags & query_flags) != query_flags)
+ return ODP_TEST_INACTIVE;
+
+ return ODP_TEST_ACTIVE;
+}
+
static void traffic_mngr_test_query(void)
{
CU_ASSERT(test_query_functions("query_shaper", "node_1_3_3", 3, 10)
== 0);
}
-static void traffic_mngr_test_marking(void)
+static int traffic_mngr_check_vlan_marking(void)
{
- odp_packet_color_t color;
- odp_bool_t test_ecn, test_drop_prec;
- int rc;
+ if (!tm_capabilities.vlan_marking_supported)
+ return ODP_TEST_INACTIVE;
+ return ODP_TEST_ACTIVE;
+}
- if (tm_capabilities.vlan_marking_supported) {
- for (color = 0; color < ODP_NUM_PKT_COLORS; color++) {
- rc = test_vlan_marking("node_1_3_1", color);
- CU_ASSERT(rc == 0);
- }
- } else {
- ODPH_DBG("\ntest_vlan_marking was not run because "
- "tm_capabilities indicates no vlan marking support\n");
- }
+static int traffic_mngr_check_ecn_marking(void)
+{
+ if (!tm_capabilities.ecn_marking_supported)
+ return ODP_TEST_INACTIVE;
+ return ODP_TEST_ACTIVE;
+}
- if (tm_capabilities.ecn_marking_supported) {
- test_ecn = true;
- test_drop_prec = false;
+static int traffic_mngr_check_drop_prec_marking(void)
+{
+ if (!tm_capabilities.drop_prec_marking_supported)
+ return ODP_TEST_INACTIVE;
+ return ODP_TEST_ACTIVE;
+}
- rc = ip_marking_tests("node_1_3_2", test_ecn, test_drop_prec);
- CU_ASSERT(rc == 0);
- } else {
- ODPH_DBG("\necn_marking tests were not run because "
- "tm_capabilities indicates no ecn marking support\n");
- }
+static int traffic_mngr_check_ecn_drop_prec_marking(void)
+{
+ if (!tm_capabilities.ecn_marking_supported ||
+ !tm_capabilities.drop_prec_marking_supported)
+ return ODP_TEST_INACTIVE;
+ return ODP_TEST_ACTIVE;
+}
- if (tm_capabilities.drop_prec_marking_supported) {
- test_ecn = false;
- test_drop_prec = true;
+static void traffic_mngr_test_vlan_marking(void)
+{
+ odp_packet_color_t color;
- rc = ip_marking_tests("node_1_4_2", test_ecn, test_drop_prec);
- CU_ASSERT(rc == 0);
- } else {
- ODPH_DBG("\ndrop_prec marking tests were not run because "
- "tm_capabilities indicates no drop precedence "
- "marking support\n");
+ for (color = 0; color < ODP_NUM_PKT_COLORS; color++) {
+ /* Tree is 3 level */
+ CU_ASSERT(test_vlan_marking("node_1_3_1", color) == 0);
}
+}
- if (tm_capabilities.ecn_marking_supported &&
- tm_capabilities.drop_prec_marking_supported) {
- test_ecn = true;
- test_drop_prec = true;
+static void traffic_mngr_test_ecn_marking(void)
+{
+ CU_ASSERT(ip_marking_tests("node_1_3_2", true, false) == 0);
+}
- rc = ip_marking_tests("node_1_4_2", test_ecn, test_drop_prec);
- CU_ASSERT(rc == 0);
- }
+static void traffic_mngr_test_drop_prec_marking(void)
+{
+ CU_ASSERT(ip_marking_tests("node_1_4_2", false, true) == 0);
+}
+
+static void traffic_mngr_test_ecn_drop_prec_marking(void)
+{
+ CU_ASSERT(ip_marking_tests("node_1_4_2", true, true) == 0);
}
static void traffic_mngr_test_fanin_info(void)
@@ -4365,19 +4431,32 @@ 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(traffic_mngr_test_threshold_profile),
- ODP_TEST_INFO(traffic_mngr_test_wred_profile),
+ ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_threshold_profile,
+ traffic_mngr_check_thresholds),
+ 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(traffic_mngr_test_thresholds),
- ODP_TEST_INFO(traffic_mngr_test_byte_wred),
- ODP_TEST_INFO(traffic_mngr_test_pkt_wred),
- ODP_TEST_INFO(traffic_mngr_test_query),
+ ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_thresholds,
+ traffic_mngr_check_thresholds),
+ ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_byte_wred,
+ traffic_mngr_check_wred),
+ ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_pkt_wred,
+ traffic_mngr_check_wred),
+ ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_query,
+ traffic_mngr_check_query),
ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_queue_stats,
traffic_mngr_check_queue_stats),
- ODP_TEST_INFO(traffic_mngr_test_marking),
+ ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_vlan_marking,
+ traffic_mngr_check_vlan_marking),
+ ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_ecn_marking,
+ traffic_mngr_check_ecn_marking),
+ ODP_TEST_INFO_CONDITIONAL(traffic_mngr_test_drop_prec_marking,
+ 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(traffic_mngr_test_fanin_info),
ODP_TEST_INFO(traffic_mngr_test_destroy),
ODP_TEST_INFO_NULL,