Skip to content

Commit

Permalink
validation: cls: use correct L4 proto for the PMR used
Browse files Browse the repository at this point in the history
The test code goes through the trouble of checking classification
capabilities when deciding whether to use UDP or TCP port matching
rules in tests but then always uses UDP test packets anyway. Tests
are thus broken if only TCP port matching is supported despite all
the capability checking.

Fix the problem by selecting also the protocol used in test packets
based on capabilities. Fix also the return value checking of a couple
of odp_cls_capability() calls.

Signed-off-by: Janne Peltonen <[email protected]>
Reviewed-by: Jere Leppänen <[email protected]>
  • Loading branch information
JannePeltonen authored and MatiasElo committed Oct 29, 2024
1 parent 31cbc84 commit 44d0b1c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ static int check_capa_cos_hashing(void)
{
odp_cls_capability_t capa;

if (odp_cls_capability(&capa) < 0)
if (odp_cls_capability(&capa) != 0)
return ODP_TEST_INACTIVE;

return capa.max_hash_queues > 1 ? ODP_TEST_ACTIVE : ODP_TEST_INACTIVE;
Expand Down
29 changes: 26 additions & 3 deletions test/validation/api/classification/odp_classification_common.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2015-2018 Linaro Limited
* Copyright (c) 2020 Nokia
* Copyright (c) 2020-2024 Nokia
*/

#include "odp_classification_testsuites.h"
Expand Down Expand Up @@ -546,7 +546,10 @@ odp_cls_pmr_term_t find_first_supported_l3_pmr(void)
odp_cls_pmr_term_t term = ODP_PMR_TCP_DPORT;
odp_cls_capability_t capability;

odp_cls_capability(&capability);
if (odp_cls_capability(&capability)) {
CU_FAIL("odp_cls_capability() failed");
return term;
}

/* choose supported PMR */
if (capability.supported_terms.bit.udp_sport)
Expand All @@ -558,11 +561,31 @@ odp_cls_pmr_term_t find_first_supported_l3_pmr(void)
else if (capability.supported_terms.bit.tcp_dport)
term = ODP_PMR_TCP_DPORT;
else
CU_FAIL("Implementations doesn't support any TCP/UDP PMR");
CU_FAIL("Implementation doesn't support any TCP/UDP PMR");

return term;
}

cls_packet_l4_info find_first_supported_proto(void)
{
odp_cls_capability_t capability;

if (odp_cls_capability(&capability)) {
CU_FAIL("odp_cls_capability() failed");
return CLS_PKT_L4_UDP;
}

if (capability.supported_terms.bit.udp_sport ||
capability.supported_terms.bit.udp_dport)
return CLS_PKT_L4_UDP;
else if (capability.supported_terms.bit.tcp_sport ||
capability.supported_terms.bit.tcp_dport)
return CLS_PKT_L4_TCP;

CU_FAIL("TCP or UDP port matching is not supported");
return CLS_PKT_L4_UDP;
}

int set_first_supported_pmr_port(odp_packet_t pkt, uint16_t port)
{
odph_udphdr_t *udp;
Expand Down
15 changes: 9 additions & 6 deletions test/validation/api/classification/odp_classification_tests.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2015-2018 Linaro Limited
* Copyright (c) 2020-2023 Nokia
* Copyright (c) 2020-2024 Nokia
*/

#include "odp_classification_testsuites.h"
Expand Down Expand Up @@ -352,7 +352,7 @@ void test_cls_pmr_chain(odp_bool_t enable_pktv, int src, int dst, const char *sa
cls_packet_info_t pkt_info;

pkt_info = default_pkt_info;
pkt_info.l4_type = CLS_PKT_L4_UDP;
pkt_info.l4_type = find_first_supported_proto();
pkt = create_packet(pkt_info);
CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
seqno = cls_pkt_get_seq(pkt);
Expand Down Expand Up @@ -514,7 +514,7 @@ void test_pktio_drop_cos(odp_bool_t enable_pktv)

CU_ASSERT_FATAL(odp_cls_capability(&capa) == 0);
pkt_info = default_pkt_info;
pkt_info.l4_type = CLS_PKT_L4_UDP;
pkt_info.l4_type = find_first_supported_proto();
pkt = create_packet(pkt_info);
CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
seqno = cls_pkt_get_seq(pkt);
Expand Down Expand Up @@ -771,7 +771,7 @@ void test_pmr_cos(odp_bool_t enable_pktv)
cls_packet_info_t pkt_info;

pkt_info = default_pkt_info;
pkt_info.l4_type = CLS_PKT_L4_UDP;
pkt_info.l4_type = find_first_supported_proto();
pkt = create_packet(pkt_info);
CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
seqno = cls_pkt_get_seq(pkt);
Expand Down Expand Up @@ -867,7 +867,7 @@ void test_pktio_pmr_composite_cos(odp_bool_t enable_pktv)
cls_packet_info_t pkt_info;

pkt_info = default_pkt_info;
pkt_info.l4_type = CLS_PKT_L4_UDP;
pkt_info.l4_type = find_first_supported_proto();
pkt = create_packet(pkt_info);
CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID);
seqno = cls_pkt_get_seq(pkt);
Expand All @@ -894,7 +894,10 @@ static void cls_pktio_configure_common(odp_bool_t enable_pktv)
odp_cls_capability_t capa;
int num_cos;

odp_cls_capability(&capa);
if (odp_cls_capability(&capa)) {
CU_FAIL("odp_cls_capability() failed");
return;
}
num_cos = capa.max_cos;

/* Configure the Different CoS for the pktio interface */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ void configure_pktio_pmr_composite(odp_bool_t enable_pktv);
void test_pktio_pmr_composite_cos(odp_bool_t enable_pktv);
int stop_pktio(odp_pktio_t pktio);
odp_cls_pmr_term_t find_first_supported_l3_pmr(void);
cls_packet_l4_info find_first_supported_proto(void);
int set_first_supported_pmr_port(odp_packet_t pkt, uint16_t port);

#endif /* ODP_BUFFER_TESTSUITES_H_ */

0 comments on commit 44d0b1c

Please sign in to comment.