@@ -67,8 +67,6 @@ void classification_test_pmr_composite_destroy(void);
void classification_test_pktio_set_skip(void);
void classification_test_pktio_set_headroom(void);
-void classification_test_pmr_terms_avail(void);
-void classification_test_pmr_terms_cap(void);
void classification_test_pktio_configure(void);
void classification_test_pktio_test(void);
@@ -75,7 +75,7 @@ void classification_test_create_pmr_match(void)
uint16_t val;
uint16_t mask;
int retval;
- odp_pmr_match_t match;
+ odp_pmr_param_t pmr_param;
odp_cos_t default_cos;
odp_cos_t cos;
odp_queue_t default_queue;
@@ -111,12 +111,14 @@ void classification_test_create_pmr_match(void)
val = 1024;
mask = 0xffff;
- match.term = find_first_supported_l3_pmr();
- match.val = &val;
- match.mask = &mask;
- match.val_sz = sizeof(val);
-
- pmr = odp_cls_pmr_create(&match, 1, default_cos, cos);
+ odp_cls_pmr_param_init(&pmr_param);
+ pmr_param.term = find_first_supported_l3_pmr();
+ pmr_param.range_term = false;
+ pmr_param.match.value = &val;
+ pmr_param.match.mask = &mask;
+ pmr_param.val_sz = sizeof(val);
+
+ pmr = odp_cls_pmr_create(&pmr_param, 1, default_cos, cos);
CU_ASSERT(pmr != ODP_PMR_INVAL);
CU_ASSERT(odp_pmr_to_u64(pmr) != odp_pmr_to_u64(ODP_PMR_INVAL));
/* destroy the created PMR */
@@ -254,7 +256,7 @@ void classification_test_pmr_composite_create(void)
{
odp_pmr_t pmr_composite;
int retval;
- odp_pmr_match_t pmr_terms[PMR_SET_NUM];
+ odp_pmr_param_t pmr_terms[PMR_SET_NUM];
odp_cos_t default_cos;
odp_cos_t cos;
odp_queue_t default_queue;
@@ -292,9 +294,11 @@ void classification_test_pmr_composite_create(void)
CU_ASSERT(cos != ODP_COS_INVALID);
for (i = 0; i < PMR_SET_NUM; i++) {
+ odp_cls_pmr_param_init(&pmr_terms[i]);
pmr_terms[i].term = ODP_PMR_TCP_DPORT;
- pmr_terms[i].val = &val;
- pmr_terms[i].mask = &mask;
+ pmr_terms[i].match.value = &val;
+ pmr_terms[i].range_term = false;
+ pmr_terms[i].match.mask = &mask;
pmr_terms[i].val_sz = sizeof(val);
}
@@ -340,18 +340,19 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan,
odp_pmr_term_t find_first_supported_l3_pmr(void)
{
- unsigned long long cap;
odp_pmr_term_t term = ODP_PMR_TCP_DPORT;
+ odp_cls_capability_t capability;
+
+ odp_cls_capability(&capability);
/* choose supported PMR */
- cap = odp_pmr_terms_cap();
- if (cap & (1 << ODP_PMR_UDP_SPORT))
+ if (capability.pmr_terms.proto.udp_sport)
term = ODP_PMR_UDP_SPORT;
- else if (cap & (1 << ODP_PMR_UDP_DPORT))
+ else if (capability.pmr_terms.proto.udp_dport)
term = ODP_PMR_UDP_DPORT;
- else if (cap & (1 << ODP_PMR_TCP_SPORT))
+ else if (capability.pmr_terms.proto.tcp_sport)
term = ODP_PMR_TCP_SPORT;
- else if (cap & (1 << ODP_PMR_TCP_DPORT))
+ else if (capability.pmr_terms.proto.tcp_dport)
term = ODP_PMR_TCP_DPORT;
else
CU_FAIL("Implementations doesn't support any TCP/UDP PMR");
@@ -106,7 +106,7 @@ void classification_test_pmr_term_tcp_dport(void)
odp_cls_cos_param_t cls_param;
odp_pool_t pool;
odp_pool_t pool_recv;
- odp_pmr_match_t match;
+ odp_pmr_param_t pmr_param;
odph_ethhdr_t *eth;
val = CLS_DEFAULT_DPORT;
@@ -136,12 +136,13 @@ void classification_test_pmr_term_tcp_dport(void)
cos = odp_cls_cos_create(cosname, &cls_param);
CU_ASSERT(cos != ODP_COS_INVALID);
- match.term = ODP_PMR_TCP_DPORT;
- match.val = &val;
- match.mask = &mask;
- match.val_sz = sizeof(val);
+ odp_cls_pmr_param_init(&pmr_param);
+ pmr_param.term = ODP_PMR_TCP_DPORT;
+ pmr_param.match.value = &val;
+ pmr_param.match.mask = &mask;
+ pmr_param.val_sz = sizeof(val);
- pmr = odp_cls_pmr_create(&match, 1, default_cos, cos);
+ pmr = odp_cls_pmr_create(&pmr_param, 1, default_cos, cos);
CU_ASSERT(pmr != ODP_PMR_INVAL);
pkt = create_packet(pkt_pool, false, &seq, false);
@@ -219,7 +220,7 @@ void classification_test_pmr_term_tcp_sport(void)
odp_cos_t cos;
char cosname[ODP_COS_NAME_LEN];
odp_cls_cos_param_t cls_param;
- odp_pmr_match_t match;
+ odp_pmr_param_t pmr_param;
odph_ethhdr_t *eth;
val = CLS_DEFAULT_SPORT;
@@ -249,12 +250,12 @@ void classification_test_pmr_term_tcp_sport(void)
cos = odp_cls_cos_create(cosname, &cls_param);
CU_ASSERT_FATAL(cos != ODP_COS_INVALID);
- match.term = ODP_PMR_TCP_SPORT;
- match.val = &val;
- match.mask = &mask;
- match.val_sz = sizeof(val);
+ pmr_param.term = ODP_PMR_TCP_SPORT;
+ pmr_param.match.value = &val;
+ pmr_param.match.mask = &mask;
+ pmr_param.val_sz = sizeof(val);
- pmr = odp_cls_pmr_create(&match, 1, default_cos, cos);
+ pmr = odp_cls_pmr_create(&pmr_param, 1, default_cos, cos);
CU_ASSERT(pmr != ODP_PMR_INVAL);
pkt = create_packet(pkt_pool, false, &seq, false);
@@ -329,7 +330,7 @@ void classification_test_pmr_term_udp_dport(void)
odp_pmr_t pmr;
odp_cos_t cos;
char cosname[ODP_COS_NAME_LEN];
- odp_pmr_match_t match;
+ odp_pmr_param_t pmr_param;
odp_cls_cos_param_t cls_param;
odph_ethhdr_t *eth;
@@ -360,12 +361,13 @@ void classification_test_pmr_term_udp_dport(void)
cos = odp_cls_cos_create(cosname, &cls_param);
CU_ASSERT_FATAL(cos != ODP_COS_INVALID);
- match.term = ODP_PMR_UDP_DPORT;
- match.val = &val;
- match.mask = &mask;
- match.val_sz = sizeof(val);
+ odp_cls_pmr_param_init(&pmr_param);
+ pmr_param.term = ODP_PMR_UDP_DPORT;
+ pmr_param.match.value = &val;
+ pmr_param.match.mask = &mask;
+ pmr_param.val_sz = sizeof(val);
- pmr = odp_cls_pmr_create(&match, 1, default_cos, cos);
+ pmr = odp_cls_pmr_create(&pmr_param, 1, default_cos, cos);
CU_ASSERT(pmr != ODP_PMR_INVAL);
pkt = create_packet(pkt_pool, false, &seq, true);
@@ -441,7 +443,7 @@ void classification_test_pmr_term_udp_sport(void)
odp_pmr_t pmr;
odp_cos_t cos;
char cosname[ODP_COS_NAME_LEN];
- odp_pmr_match_t match;
+ odp_pmr_param_t pmr_param;
odp_cls_cos_param_t cls_param;
odph_ethhdr_t *eth;
@@ -472,12 +474,12 @@ void classification_test_pmr_term_udp_sport(void)
cos = odp_cls_cos_create(cosname, &cls_param);
CU_ASSERT_FATAL(cos != ODP_COS_INVALID);
- match.term = ODP_PMR_UDP_SPORT;
- match.val = &val;
- match.mask = &mask;
- match.val_sz = sizeof(val);
+ pmr_param.term = ODP_PMR_UDP_SPORT;
+ pmr_param.match.value = &val;
+ pmr_param.match.mask = &mask;
+ pmr_param.val_sz = sizeof(val);
- pmr = odp_cls_pmr_create(&match, 1, default_cos, cos);
+ pmr = odp_cls_pmr_create(&pmr_param, 1, default_cos, cos);
CU_ASSERT(pmr != ODP_PMR_INVAL);
pkt = create_packet(pkt_pool, false, &seq, true);
@@ -552,7 +554,7 @@ void classification_test_pmr_term_ipproto(void)
odp_cos_t cos;
char cosname[ODP_COS_NAME_LEN];
odp_cls_cos_param_t cls_param;
- odp_pmr_match_t match;
+ odp_pmr_param_t pmr_param;
odph_ethhdr_t *eth;
val = ODPH_IPPROTO_UDP;
@@ -582,12 +584,13 @@ void classification_test_pmr_term_ipproto(void)
cos = odp_cls_cos_create(cosname, &cls_param);
CU_ASSERT_FATAL(cos != ODP_COS_INVALID);
- match.term = ODP_PMR_IPPROTO;
- match.val = &val;
- match.mask = &mask;
- match.val_sz = sizeof(val);
+ odp_cls_pmr_param_init(&pmr_param);
+ pmr_param.term = ODP_PMR_IPPROTO;
+ pmr_param.match.value = &val;
+ pmr_param.match.mask = &mask;
+ pmr_param.val_sz = sizeof(val);
- pmr = odp_cls_pmr_create(&match, 1, default_cos, cos);
+ pmr = odp_cls_pmr_create(&pmr_param, 1, default_cos, cos);
CU_ASSERT(pmr != ODP_PMR_INVAL);
pkt = create_packet(pkt_pool, false, &seq, true);
@@ -657,7 +660,7 @@ void classification_test_pmr_term_dmac(void)
odp_cos_t cos;
char cosname[ODP_COS_NAME_LEN];
odp_cls_cos_param_t cls_param;
- odp_pmr_match_t match;
+ odp_pmr_param_t pmr_param;
odph_ethhdr_t *eth;
val = CLS_DEFAULT_DMAC; /* 48 bit Ethernet Mac address */
@@ -687,12 +690,12 @@ void classification_test_pmr_term_dmac(void)
cos = odp_cls_cos_create(cosname, &cls_param);
CU_ASSERT_FATAL(cos != ODP_COS_INVALID);
- match.term = ODP_PMR_DMAC;
- match.val = &val;
- match.mask = &mask;
- match.val_sz = ODPH_ETHADDR_LEN;
+ pmr_param.term = ODP_PMR_DMAC;
+ pmr_param.match.value = &val;
+ pmr_param.match.mask = &mask;
+ pmr_param.val_sz = ODPH_ETHADDR_LEN;
- pmr = odp_cls_pmr_create(&match, 1, default_cos, cos);
+ pmr = odp_cls_pmr_create(&pmr_param, 1, default_cos, cos);
CU_ASSERT(pmr != ODP_PMR_INVAL);
pkt = create_packet(pkt_pool, false, &seq, true);
@@ -758,7 +761,7 @@ void classification_test_pmr_term_packet_len(void)
odp_cos_t cos;
char cosname[ODP_COS_NAME_LEN];
odp_cls_cos_param_t cls_param;
- odp_pmr_match_t match;
+ odp_pmr_param_t pmr_param;
odph_ethhdr_t *eth;
val = 1024;
@@ -789,12 +792,13 @@ void classification_test_pmr_term_packet_len(void)
cos = odp_cls_cos_create(cosname, &cls_param);
CU_ASSERT_FATAL(cos != ODP_COS_INVALID);
- match.term = ODP_PMR_LEN;
- match.val = &val;
- match.mask = &mask;
- match.val_sz = sizeof(val);
+ odp_cls_pmr_param_init(&pmr_param);
+ pmr_param.term = ODP_PMR_LEN;
+ pmr_param.match.value = &val;
+ pmr_param.match.mask = &mask;
+ pmr_param.val_sz = sizeof(val);
- pmr = odp_cls_pmr_create(&match, 1, default_cos, cos);
+ pmr = odp_cls_pmr_create(&pmr_param, 1, default_cos, cos);
CU_ASSERT(pmr != ODP_PMR_INVAL);
/* create packet of payload length 1024 */
@@ -866,7 +870,7 @@ static void classification_test_pmr_pool_set(void)
odp_cos_t cos;
char cosname[ODP_COS_NAME_LEN];
odp_cls_cos_param_t cls_param;
- odp_pmr_match_t match;
+ odp_pmr_param_t pmr_param;
odph_ethhdr_t *eth;
val = ODPH_IPPROTO_UDP;
@@ -903,12 +907,13 @@ static void classification_test_pmr_pool_set(void)
retval = odp_cls_cos_pool_set(cos, pool_new);
CU_ASSERT(retval == 0);
- match.term = ODP_PMR_IPPROTO;
- match.val = &val;
- match.mask = &mask;
- match.val_sz = sizeof(val);
+ odp_cls_pmr_param_init(&pmr_param);
+ pmr_param.term = ODP_PMR_IPPROTO;
+ pmr_param.match.value = &val;
+ pmr_param.match.mask = &mask;
+ pmr_param.val_sz = sizeof(val);
- pmr = odp_cls_pmr_create(&match, 1, default_cos, cos);
+ pmr = odp_cls_pmr_create(&pmr_param, 1, default_cos, cos);
CU_ASSERT(pmr != ODP_PMR_INVAL);
pkt = create_packet(pkt_pool, false, &seq, true);
@@ -961,7 +966,7 @@ static void classification_test_pmr_queue_set(void)
odp_cos_t cos;
char cosname[ODP_COS_NAME_LEN];
odp_cls_cos_param_t cls_param;
- odp_pmr_match_t match;
+ odp_pmr_param_t pmr_param;
odph_ethhdr_t *eth;
val = ODPH_IPPROTO_UDP;
@@ -998,12 +1003,13 @@ static void classification_test_pmr_queue_set(void)
retval = odp_cos_queue_set(cos, queue_new);
CU_ASSERT(retval == 0);
- match.term = ODP_PMR_IPPROTO;
- match.val = &val;
- match.mask = &mask;
- match.val_sz = sizeof(val);
+ odp_cls_pmr_param_init(&pmr_param);
+ pmr_param.term = ODP_PMR_IPPROTO;
+ pmr_param.match.value = &val;
+ pmr_param.match.mask = &mask;
+ pmr_param.val_sz = sizeof(val);
- pmr = odp_cls_pmr_create(&match, 1, default_cos, cos);
+ pmr = odp_cls_pmr_create(&pmr_param, 1, default_cos, cos);
CU_ASSERT(pmr != ODP_PMR_INVAL);
pkt = create_packet(pkt_pool, false, &seq, true);
@@ -1053,7 +1059,7 @@ static void classification_test_pmr_term_daddr(void)
uint32_t addr;
uint32_t mask;
char cosname[ODP_QUEUE_NAME_LEN];
- odp_pmr_match_t match;
+ odp_pmr_param_t pmr_param;
odp_cls_cos_param_t cls_param;
odph_ipv4hdr_t *ip;
const char *dst_addr = "10.0.0.99/32";
@@ -1082,12 +1088,13 @@ static void classification_test_pmr_term_daddr(void)
CU_ASSERT_FATAL(cos != ODP_COS_INVALID);
parse_ipv4_string(dst_addr, &addr, &mask);
- match.term = ODP_PMR_DIP_ADDR;
- match.val = &addr;
- match.mask = &mask;
- match.val_sz = sizeof(addr);
+ odp_cls_pmr_param_init(&pmr_param);
+ pmr_param.term = ODP_PMR_DIP_ADDR;
+ pmr_param.match.value = &addr;
+ pmr_param.match.mask = &mask;
+ pmr_param.val_sz = sizeof(addr);
- pmr = odp_cls_pmr_create(&match, 1, default_cos, cos);
+ pmr = odp_cls_pmr_create(&pmr_param, 1, default_cos, cos);
CU_ASSERT_FATAL(pmr != ODP_PMR_INVAL);
/* packet with dst ip address matching PMR rule to be
@@ -135,7 +135,7 @@ void configure_cls_pmr_chain(void)
char poolname[ODP_POOL_NAME_LEN];
uint32_t addr;
uint32_t mask;
- odp_pmr_match_t match;
+ odp_pmr_param_t pmr_param;
odp_queue_param_init(&qparam);
@@ -159,6 +159,7 @@ void configure_cls_pmr_chain(void)
cls_param.pool = pool_list[CLS_PMR_CHAIN_SRC];
cls_param.queue = queue_list[CLS_PMR_CHAIN_SRC];
cls_param.drop_policy = ODP_COS_DROP_POOL;
+
cos_list[CLS_PMR_CHAIN_SRC] = odp_cls_cos_create(cosname, &cls_param);
CU_ASSERT_FATAL(cos_list[CLS_PMR_CHAIN_SRC] != ODP_COS_INVALID);
@@ -186,23 +187,25 @@ void configure_cls_pmr_chain(void)
CU_ASSERT_FATAL(cos_list[CLS_PMR_CHAIN_DST] != ODP_COS_INVALID);
parse_ipv4_string(CLS_PMR_CHAIN_SADDR, &addr, &mask);
- match.term = ODP_PMR_SIP_ADDR;
- match.val = &addr;
- match.mask = &mask;
- match.val_sz = sizeof(addr);
+ odp_cls_pmr_param_init(&pmr_param);
+ pmr_param.term = ODP_PMR_SIP_ADDR;
+ pmr_param.match.value = &addr;
+ pmr_param.match.mask = &mask;
+ pmr_param.val_sz = sizeof(addr);
pmr_list[CLS_PMR_CHAIN_SRC] =
- odp_cls_pmr_create(&match, 1, cos_list[CLS_DEFAULT],
+ odp_cls_pmr_create(&pmr_param, 1, cos_list[CLS_DEFAULT],
cos_list[CLS_PMR_CHAIN_SRC]);
CU_ASSERT_FATAL(pmr_list[CLS_PMR_CHAIN_SRC] != ODP_PMR_INVAL);
val = CLS_PMR_CHAIN_PORT;
maskport = 0xffff;
- match.term = find_first_supported_l3_pmr();
- match.val = &val;
- match.mask = &maskport;
- match.val_sz = sizeof(val);
+ odp_cls_pmr_param_init(&pmr_param);
+ pmr_param.term = find_first_supported_l3_pmr();
+ pmr_param.match.value = &val;
+ pmr_param.match.mask = &maskport;
+ pmr_param.val_sz = sizeof(val);
pmr_list[CLS_PMR_CHAIN_DST] =
- odp_cls_pmr_create(&match, 1, cos_list[CLS_PMR_CHAIN_SRC],
+ odp_cls_pmr_create(&pmr_param, 1, cos_list[CLS_PMR_CHAIN_SRC],
cos_list[CLS_PMR_CHAIN_DST]);
CU_ASSERT_FATAL(pmr_list[CLS_PMR_CHAIN_DST] != ODP_PMR_INVAL);
}
@@ -495,7 +498,7 @@ void configure_pmr_cos(void)
{
uint16_t val;
uint16_t mask;
- odp_pmr_match_t match;
+ odp_pmr_param_t pmr_param;
odp_queue_param_t qparam;
odp_cls_cos_param_t cls_param;
char cosname[ODP_COS_NAME_LEN];
@@ -526,12 +529,14 @@ void configure_pmr_cos(void)
val = CLS_PMR_PORT;
mask = 0xffff;
- match.term = find_first_supported_l3_pmr();
- match.val = &val;
- match.mask = &mask;
- match.val_sz = sizeof(val);
-
- pmr_list[CLS_PMR] = odp_cls_pmr_create(&match, 1, cos_list[CLS_DEFAULT],
+ 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_PMR] = odp_cls_pmr_create(&pmr_param, 1,
+ cos_list[CLS_DEFAULT],
cos_list[CLS_PMR]);
CU_ASSERT_FATAL(pmr_list[CLS_PMR] != ODP_PMR_INVAL);
}
@@ -560,7 +565,7 @@ void test_pmr_cos(void)
void configure_pktio_pmr_composite(void)
{
- odp_pmr_match_t pmr_terms[2];
+ odp_pmr_param_t pmr_params[2];
uint16_t val;
uint16_t maskport;
int num_terms = 2; /* one pmr for each L3 and L4 */
@@ -595,19 +600,22 @@ void configure_pktio_pmr_composite(void)
CU_ASSERT_FATAL(cos_list[CLS_PMR_SET] != ODP_COS_INVALID);
parse_ipv4_string(CLS_PMR_SET_SADDR, &addr, &mask);
- pmr_terms[0].term = ODP_PMR_SIP_ADDR;
- pmr_terms[0].val = &addr;
- pmr_terms[0].mask = &mask;
- pmr_terms[0].val_sz = sizeof(addr);
+ odp_cls_pmr_param_init(&pmr_params[0]);
+ pmr_params[0].term = ODP_PMR_SIP_ADDR;
+ pmr_params[0].match.value = &addr;
+ pmr_params[0].match.mask = &mask;
+ pmr_params[0].val_sz = sizeof(addr);
val = CLS_PMR_SET_PORT;
maskport = 0xffff;
- pmr_terms[1].term = find_first_supported_l3_pmr();
- pmr_terms[1].val = &val;
- pmr_terms[1].mask = &maskport;
- pmr_terms[1].val_sz = sizeof(val);
-
- pmr_list[CLS_PMR_SET] = odp_cls_pmr_create(pmr_terms, num_terms,
+ odp_cls_pmr_param_init(&pmr_params[1]);
+ pmr_params[1].term = find_first_supported_l3_pmr();
+ pmr_params[1].match.value = &val;
+ pmr_params[1].match.mask = &maskport;
+ pmr_params[1].range_term = false;
+ pmr_params[1].val_sz = sizeof(val);
+
+ pmr_list[CLS_PMR_SET] = odp_cls_pmr_create(pmr_params, num_terms,
cos_list[CLS_DEFAULT],
cos_list[CLS_PMR_SET]);
CU_ASSERT_FATAL(pmr_list[CLS_PMR_SET] != ODP_PMR_INVAL);
@@ -645,23 +653,6 @@ void test_pktio_pmr_composite_cos(void)
odp_packet_free(pkt);
}
-void classification_test_pmr_terms_avail(void)
-{
- int retval;
- /* Since this API called at the start of the suite the return value
- should be greater than 0 */
- retval = odp_pmr_terms_avail();
- CU_ASSERT(retval > 0);
-}
-
-void classification_test_pmr_terms_cap(void)
-{
- unsigned long long retval;
- /* Need to check different values for different platforms */
- retval = odp_pmr_terms_cap();
- CU_ASSERT(retval & (1 << ODP_PMR_IPPROTO));
-}
-
void classification_test_pktio_configure(void)
{
/* Configure the Different CoS for the pktio interface */
@@ -697,10 +688,8 @@ void classification_test_pktio_test(void)
}
odp_testinfo_t classification_suite[] = {
- ODP_TEST_INFO(classification_test_pmr_terms_avail),
ODP_TEST_INFO(classification_test_pktio_set_skip),
ODP_TEST_INFO(classification_test_pktio_set_headroom),
- ODP_TEST_INFO(classification_test_pmr_terms_cap),
ODP_TEST_INFO(classification_test_pktio_configure),
ODP_TEST_INFO(classification_test_pktio_test),
ODP_TEST_INFO_NULL,
Adds validation suite for classification capability and PMR range functionality. Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org> --- test/validation/classification/classification.h | 2 - .../classification/odp_classification_basic.c | 24 ++-- .../classification/odp_classification_common.c | 13 ++- .../classification/odp_classification_test_pmr.c | 127 +++++++++++---------- .../classification/odp_classification_tests.c | 85 ++++++-------- 5 files changed, 125 insertions(+), 126 deletions(-)