diff mbox series

[API-NEXT,v3,7/14] validation: switch to using odp_packet_l3_type_set()

Message ID 1518008409-31750-8-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v3,1/14] linux-gen: packet: implement packet l3/l4 proto types | expand

Commit Message

Github ODP bot Feb. 7, 2018, 1 p.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Use odp_packet_l3_type_set() instead of calling
odp_packet_has_ipv4_set() or odp_packet_has_ipv6_set().

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 457 (lumag:packet-types)
 ** https://github.com/Linaro/odp/pull/457
 ** Patch: https://github.com/Linaro/odp/pull/457.patch
 ** Base sha: e1175d5a69c65bb465022c9f1381c40fdb5c4069
 ** Merge commit sha: 86fcf3650d33f5dd82712dda131fb8ca66a3bdf8
 **/
 .../api/classification/odp_classification_common.c |  4 ++--
 test/validation/api/packet/packet.c                | 27 +++++++++++++++++++---
 test/validation/api/traffic_mngr/traffic_mngr.c    |  4 ++--
 3 files changed, 28 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/test/validation/api/classification/odp_classification_common.c b/test/validation/api/classification/odp_classification_common.c
index 7b54ef157..191489126 100644
--- a/test/validation/api/classification/odp_classification_common.c
+++ b/test/validation/api/classification/odp_classification_common.c
@@ -321,10 +321,10 @@  odp_packet_t create_packet(cls_packet_info_t pkt_info)
 		ip->proto = next_hdr;
 		ip->tot_len = odp_cpu_to_be_16(l3_len);
 		ip->ttl = DEFAULT_TTL;
-		odp_packet_has_ipv4_set(pkt, 1);
+		odp_packet_l3_type_set(pkt, ODP_PROTO_L3_TYPE_IPV4);
 	} else {
 		/* ipv6 */
-		odp_packet_has_ipv6_set(pkt, 1);
+		odp_packet_l3_type_set(pkt, ODP_PROTO_L3_TYPE_IPV6);
 		ipv6 = (odph_ipv6hdr_t *)odp_packet_l3_ptr(pkt, NULL);
 		version     = ODPH_IPV6        << ODPH_IPV6HDR_VERSION_SHIFT;
 		tc          = DEFAULT_TOS << ODPH_IPV6HDR_TC_SHIFT;
diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c
index f829d0cb1..00228b240 100644
--- a/test/validation/api/packet/packet.c
+++ b/test/validation/api/packet/packet.c
@@ -1047,9 +1047,6 @@  void packet_test_in_flags(void)
 	TEST_INFLAG(pkt, jumbo);
 	TEST_INFLAG(pkt, vlan);
 	TEST_INFLAG(pkt, vlan_qinq);
-	TEST_INFLAG(pkt, arp);
-	TEST_INFLAG(pkt, ipv4);
-	TEST_INFLAG(pkt, ipv6);
 	TEST_INFLAG(pkt, ip_bcast);
 	TEST_INFLAG(pkt, ip_mcast);
 	TEST_INFLAG(pkt, ipfrag);
@@ -1059,6 +1056,30 @@  void packet_test_in_flags(void)
 	TEST_INFLAG(pkt, tcp);
 	TEST_INFLAG(pkt, sctp);
 	TEST_INFLAG(pkt, icmp);
+
+	odp_packet_l3_type_set(pkt, ODP_PROTO_L3_TYPE_NONE);
+	CU_ASSERT_EQUAL(odp_packet_l3_type(pkt), ODP_PROTO_L3_TYPE_NONE);
+	CU_ASSERT(!odp_packet_has_arp(pkt));
+	CU_ASSERT(!odp_packet_has_ipv4(pkt));
+	CU_ASSERT(!odp_packet_has_ipv6(pkt));
+
+	odp_packet_l3_type_set(pkt, ODP_PROTO_L3_TYPE_ARP);
+	CU_ASSERT_EQUAL(odp_packet_l3_type(pkt), ODP_PROTO_L3_TYPE_ARP);
+	CU_ASSERT(odp_packet_has_arp(pkt));
+	CU_ASSERT(!odp_packet_has_ipv4(pkt));
+	CU_ASSERT(!odp_packet_has_ipv6(pkt));
+
+	odp_packet_l3_type_set(pkt, ODP_PROTO_L3_TYPE_IPV4);
+	CU_ASSERT_EQUAL(odp_packet_l3_type(pkt), ODP_PROTO_L3_TYPE_IPV4);
+	CU_ASSERT(!odp_packet_has_arp(pkt));
+	CU_ASSERT(odp_packet_has_ipv4(pkt));
+	CU_ASSERT(!odp_packet_has_ipv6(pkt));
+
+	odp_packet_l3_type_set(pkt, ODP_PROTO_L3_TYPE_IPV6);
+	CU_ASSERT_EQUAL(odp_packet_l3_type(pkt), ODP_PROTO_L3_TYPE_IPV6);
+	CU_ASSERT(!odp_packet_has_arp(pkt));
+	CU_ASSERT(!odp_packet_has_ipv4(pkt));
+	CU_ASSERT(odp_packet_has_ipv6(pkt));
 }
 
 void packet_test_error_flags(void)
diff --git a/test/validation/api/traffic_mngr/traffic_mngr.c b/test/validation/api/traffic_mngr/traffic_mngr.c
index d11fa0542..4b70282b1 100644
--- a/test/validation/api/traffic_mngr/traffic_mngr.c
+++ b/test/validation/api/traffic_mngr/traffic_mngr.c
@@ -739,7 +739,7 @@  static odp_packet_t make_pkt(odp_pool_t  pkt_pool,
 	odp_packet_l3_offset_set(odp_pkt, l3_offset);
 	if (pkt_info->use_ipv6) {
 		/* IPv6 Header */
-		odp_packet_has_ipv6_set(odp_pkt, 1);
+		odp_packet_l3_type_set(odp_pkt, ODP_PROTO_L3_TYPE_IPV6);
 		version     = ODPH_IPV6        << ODPH_IPV6HDR_VERSION_SHIFT;
 		tc          = pkt_info->ip_tos << ODPH_IPV6HDR_TC_SHIFT;
 		flow        = unique_id        << ODPH_IPV6HDR_FLOW_LABEL_SHIFT;
@@ -754,7 +754,7 @@  static odp_packet_t make_pkt(odp_pool_t  pkt_pool,
 		memcpy(ipv6_hdr->dst_addr, IPV6_DST_ADDR, ODPH_IPV6ADDR_LEN);
 	} else {
 		/* IPv4 Header */
-		odp_packet_has_ipv4_set(odp_pkt, 1);
+		odp_packet_l3_type_set(odp_pkt, ODP_PROTO_L3_TYPE_IPV4);
 		ipv4_hdr              = (odph_ipv4hdr_t *)(buf + l3_offset);
 		ipv4_hdr->ver_ihl     = (ODPH_IPV4 << 4) | ODPH_IPV4HDR_IHL_MIN;
 		ipv4_hdr->tos         = pkt_info->ip_tos;