@@ -72,10 +72,7 @@ typedef union {
uint64_t vlan_qinq:1; /* Stacked VLAN found, QinQ */
uint64_t snap:1; /* SNAP */
- uint64_t arp:1; /* ARP */
- uint64_t ipv4:1; /* IPv4 */
- uint64_t ipv6:1; /* IPv6 */
uint64_t ip_bcast:1; /* IP broadcast */
uint64_t ip_mcast:1; /* IP multicast */
uint64_t ipfrag:1; /* IP fragment */
@@ -51,7 +51,8 @@ static inline int verify_pmr_ip_proto(const uint8_t *pkt_addr,
{
const _odp_ipv4hdr_t *ip;
uint8_t proto;
- if (!pkt_hdr->p.input_flags.ipv4)
+
+ if (!packet_hdr_has_ipv4(pkt_hdr))
return 0;
ip = (const _odp_ipv4hdr_t *)(pkt_addr + pkt_hdr->p.l3_offset);
proto = ip->proto;
@@ -67,7 +68,8 @@ static inline int verify_pmr_ipv4_saddr(const uint8_t *pkt_addr,
{
const _odp_ipv4hdr_t *ip;
uint32_t ipaddr;
- if (!pkt_hdr->p.input_flags.ipv4)
+
+ if (!packet_hdr_has_ipv4(pkt_hdr))
return 0;
ip = (const _odp_ipv4hdr_t *)(pkt_addr + pkt_hdr->p.l3_offset);
ipaddr = _odp_be_to_cpu_32(ip->src_addr);
@@ -83,7 +85,8 @@ static inline int verify_pmr_ipv4_daddr(const uint8_t *pkt_addr,
{
const _odp_ipv4hdr_t *ip;
uint32_t ipaddr;
- if (!pkt_hdr->p.input_flags.ipv4)
+
+ if (!packet_hdr_has_ipv4(pkt_hdr))
return 0;
ip = (const _odp_ipv4hdr_t *)(pkt_addr + pkt_hdr->p.l3_offset);
ipaddr = _odp_be_to_cpu_32(ip->dst_addr);
@@ -281,9 +281,14 @@ static inline int packet_hdr_has_eth(odp_packet_hdr_t *pkt_hdr)
return pkt_hdr->p.input_flags.eth;
}
+static inline int packet_hdr_has_ipv4(odp_packet_hdr_t *pkt_hdr)
+{
+ return pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L3_TYPE_IPV4;
+}
+
static inline int packet_hdr_has_ipv6(odp_packet_hdr_t *pkt_hdr)
{
- return pkt_hdr->p.input_flags.ipv6;
+ return pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L3_TYPE_IPV6;
}
static inline void packet_set_ts(odp_packet_hdr_t *pkt_hdr, odp_time_t *ts)
@@ -1026,7 +1026,7 @@ static uint32_t packet_rss_hash(odp_packet_hdr_t *pkt_hdr,
tuple_len = 0;
hash = 0;
- if (pkt_hdr->p.input_flags.ipv4) {
+ if (packet_hdr_has_ipv4(pkt_hdr)) {
if (hash_proto.ipv4) {
/* add ipv4 */
ipv4 = (const _odp_ipv4hdr_t *)(base +
@@ -1051,7 +1051,7 @@ static uint32_t packet_rss_hash(odp_packet_hdr_t *pkt_hdr,
tuple.v4.dport = udp->dst_port;
tuple_len += 1;
}
- } else if (pkt_hdr->p.input_flags.ipv6) {
+ } else if (packet_hdr_has_ipv6(pkt_hdr)) {
if (hash_proto.ipv6) {
/* add ipv6 */
ipv6 = (const _odp_ipv6hdr_t *)(base +
@@ -1089,11 +1089,11 @@ cos_t *match_qos_l3_cos(pmr_l3_cos_t *l3_cos, const uint8_t *pkt_addr,
const _odp_ipv4hdr_t *ipv4;
const _odp_ipv6hdr_t *ipv6;
- if (hdr->p.input_flags.l3 && hdr->p.input_flags.ipv4) {
+ if (hdr->p.input_flags.l3 && packet_hdr_has_ipv4(hdr)) {
ipv4 = (const _odp_ipv4hdr_t *)(pkt_addr + hdr->p.l3_offset);
dscp = _ODP_IPV4HDR_DSCP(ipv4->tos);
cos = l3_cos->cos[dscp];
- } else if (hdr->p.input_flags.l3 && hdr->p.input_flags.ipv6) {
+ } else if (hdr->p.input_flags.l3 && packet_hdr_has_ipv6(hdr)) {
ipv6 = (const _odp_ipv6hdr_t *)(pkt_addr + hdr->p.l3_offset);
dscp = _ODP_IPV6HDR_DSCP(ipv6->ver_tc_flow);
cos = l3_cos->cos[dscp];
@@ -2196,14 +2196,12 @@ int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr,
/* Parse Layer 3 headers */
switch (ethtype) {
case _ODP_ETHTYPE_IPV4:
- prs->input_flags.ipv4 = 1;
prs->input_flags.l3_type = ODP_PROTO_L3_TYPE_IPV4;
ip_proto = parse_ipv4(prs, &parseptr, &offset, frame_len);
prs->l4_offset = offset;
break;
case _ODP_ETHTYPE_IPV6:
- prs->input_flags.ipv6 = 1;
prs->input_flags.l3_type = ODP_PROTO_L3_TYPE_IPV6;
ip_proto = parse_ipv6(prs, &parseptr, &offset, frame_len,
seg_len);
@@ -2211,7 +2209,6 @@ int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr,
break;
case _ODP_ETHTYPE_ARP:
- prs->input_flags.arp = 1;
prs->input_flags.l3_type = ODP_PROTO_L3_TYPE_ARP;
ip_proto = 255; /* Reserved invalid by IANA */
break;
@@ -2562,8 +2559,6 @@ void odp_packet_l3_type_set(odp_packet_t pkt, odp_proto_l3_type_t val)
odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
pkt_hdr->p.input_flags.l3_type = val;
- pkt_hdr->p.input_flags.ipv4 = (val == ODP_PROTO_L3_TYPE_IPV4);
- pkt_hdr->p.input_flags.ipv6 = (val == ODP_PROTO_L3_TYPE_IPV6);
}
odp_proto_l4_type_t odp_packet_l4_type(odp_packet_t pkt)
@@ -83,17 +83,23 @@ int odp_packet_has_vlan_qinq(odp_packet_t pkt)
int odp_packet_has_arp(odp_packet_t pkt)
{
- retflag(pkt, input_flags.arp);
+ odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+ return pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L3_TYPE_ARP;
}
int odp_packet_has_ipv4(odp_packet_t pkt)
{
- retflag(pkt, input_flags.ipv4);
+ odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+ return pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L3_TYPE_IPV4;
}
int odp_packet_has_ipv6(odp_packet_t pkt)
{
- retflag(pkt, input_flags.ipv6);
+ odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+ return pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L3_TYPE_IPV6;
}
int odp_packet_has_ip_bcast(odp_packet_t pkt)
@@ -226,17 +232,32 @@ void odp_packet_has_vlan_qinq_set(odp_packet_t pkt, int val)
void odp_packet_has_arp_set(odp_packet_t pkt, int val)
{
- setflag(pkt, input_flags.arp, val);
+ odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+ if (val)
+ odp_packet_l3_type_set(pkt, ODP_PROTO_L3_TYPE_ARP);
+ else if (pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L3_TYPE_ARP)
+ odp_packet_l3_type_set(pkt, ODP_PROTO_L3_TYPE_NONE);
}
void odp_packet_has_ipv4_set(odp_packet_t pkt, int val)
{
- setflag(pkt, input_flags.ipv4, val);
+ odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+ if (val)
+ odp_packet_l3_type_set(pkt, ODP_PROTO_L3_TYPE_IPV4);
+ else if (pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L3_TYPE_IPV4)
+ odp_packet_l3_type_set(pkt, ODP_PROTO_L3_TYPE_NONE);
}
void odp_packet_has_ipv6_set(odp_packet_t pkt, int val)
{
- setflag(pkt, input_flags.ipv6, val);
+ odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+ if (val)
+ odp_packet_l3_type_set(pkt, ODP_PROTO_L3_TYPE_IPV6);
+ else if (pkt_hdr->p.input_flags.l3_type == ODP_PROTO_L3_TYPE_IPV6)
+ odp_packet_l3_type_set(pkt, ODP_PROTO_L3_TYPE_NONE);
}
void odp_packet_has_ip_bcast_set(odp_packet_t pkt, int val)