@@ -54,18 +54,9 @@ Stores the Term and Value mapping for a PMR.
The maximum size of value currently supported in 64 bits
**/
typedef struct pmr_term_value {
- odp_pmr_match_type_e match_type; /**< Packet Match Type*/
- odp_pmr_term_e term; /* PMR Term */
- union {
- struct {
- uint64_t val;
- uint64_t mask;
- } mask; /**< Match a masked set of bits */
- struct {
- uint64_t val1;
- uint64_t val2;
- } range; /**< Match an integer range */
- };
+ odp_pmr_term_e term; /* PMR Term */
+ uint64_t val; /**< Value to be matched */
+ uint64_t mask; /**< Masked set of bits to be matched */
} pmr_term_value_t;
/*
@@ -32,15 +32,10 @@ These following functions return 1 on success and 0 on failure
static inline int verify_pmr_packet_len(odp_packet_hdr_t *pkt_hdr,
pmr_term_value_t *term_value)
{
- if (term_value->match_type == ODP_PMR_MASK) {
- if (term_value->mask.val == (pkt_hdr->frame_len &
- term_value->mask.mask))
- return 1;
- } else {
- if ((term_value->range.val1 <= pkt_hdr->frame_len) &&
- (pkt_hdr->frame_len <= term_value->range.val2))
- return 1;
- }
+ if (term_value->val == (pkt_hdr->frame_len &
+ term_value->mask))
+ return 1;
+
return 0;
}
static inline int verify_pmr_ip_proto(uint8_t *pkt_addr,
@@ -53,14 +48,9 @@ static inline int verify_pmr_ip_proto(uint8_t *pkt_addr,
return 0;
ip = (odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
proto = ip->proto;
- if (term_value->match_type == ODP_PMR_MASK) {
- if (term_value->mask.val == (proto & term_value->mask.mask))
- return 1;
- } else {
- if ((term_value->range.val1 <= proto) &&
- (proto <= term_value->range.val2))
- return 1;
- }
+ if (term_value->val == (proto & term_value->mask))
+ return 1;
+
return 0;
}
@@ -74,14 +64,9 @@ static inline int verify_pmr_ipv4_saddr(uint8_t *pkt_addr,
return 0;
ip = (odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
ipaddr = odp_be_to_cpu_32(ip->src_addr);
- if (term_value->match_type == ODP_PMR_MASK) {
- if (term_value->mask.val == (ipaddr & term_value->mask.mask))
- return 1;
- } else {
- if ((term_value->range.val1 <= ipaddr) &&
- (ipaddr <= term_value->range.val2))
- return 1;
- }
+ if (term_value->val == (ipaddr & term_value->mask))
+ return 1;
+
return 0;
}
@@ -95,14 +80,9 @@ static inline int verify_pmr_ipv4_daddr(uint8_t *pkt_addr,
return 0;
ip = (odph_ipv4hdr_t *)(pkt_addr + pkt_hdr->l3_offset);
ipaddr = odp_be_to_cpu_32(ip->dst_addr);
- if (term_value->match_type == ODP_PMR_MASK) {
- if (term_value->mask.val == (ipaddr & term_value->mask.mask))
- return 1;
- } else {
- if ((term_value->range.val1 <= ipaddr) &&
- (ipaddr <= term_value->range.val2))
- return 1;
- }
+ if (term_value->val == (ipaddr & term_value->mask))
+ return 1;
+
return 0;
}
@@ -116,14 +96,9 @@ static inline int verify_pmr_tcp_sport(uint8_t *pkt_addr,
return 0;
tcp = (odph_tcphdr_t *)(pkt_addr + pkt_hdr->l4_offset);
sport = odp_be_to_cpu_16(tcp->src_port);
- if (term_value->match_type == ODP_PMR_MASK) {
- if (term_value->mask.val == (sport & term_value->mask.mask))
- return 1;
- } else {
- if ((term_value->range.val1 <= sport) &&
- (sport <= term_value->range.val2))
- return 1;
- }
+ if (term_value->val == (sport & term_value->mask))
+ return 1;
+
return 0;
}
@@ -137,14 +112,9 @@ static inline int verify_pmr_tcp_dport(uint8_t *pkt_addr,
return 0;
tcp = (odph_tcphdr_t *)(pkt_addr + pkt_hdr->l4_offset);
dport = odp_be_to_cpu_16(tcp->dst_port);
- if (term_value->match_type == ODP_PMR_MASK) {
- if (term_value->mask.val == (dport & term_value->mask.mask))
- return 1;
- } else {
- if ((term_value->range.val1 <= dport) &&
- (dport <= term_value->range.val2))
- return 1;
- }
+ if (term_value->val == (dport & term_value->mask))
+ return 1;
+
return 0;
}
@@ -158,14 +128,9 @@ static inline int verify_pmr_udp_dport(uint8_t *pkt_addr,
return 0;
udp = (odph_udphdr_t *)(pkt_addr + pkt_hdr->l4_offset);
dport = odp_be_to_cpu_16(udp->dst_port);
- if (term_value->match_type == ODP_PMR_MASK) {
- if (term_value->mask.val == (dport & term_value->mask.mask))
+ if (term_value->val == (dport & term_value->mask))
return 1;
- } else {
- if ((term_value->range.val1 <= dport) &&
- (dport <= term_value->range.val2))
- return 1;
- }
+
return 0;
}
static inline int verify_pmr_udp_sport(uint8_t *pkt_addr,
@@ -178,14 +143,9 @@ static inline int verify_pmr_udp_sport(uint8_t *pkt_addr,
return 0;
udp = (odph_udphdr_t *)(pkt_addr + pkt_hdr->l4_offset);
sport = odp_be_to_cpu_16(udp->src_port);
- if (term_value->match_type == ODP_PMR_MASK) {
- if (term_value->mask.val == (sport & term_value->mask.mask))
- return 1;
- } else {
- if ((term_value->range.val1 <= sport) &&
- (sport <= term_value->range.val2))
- return 1;
- }
+ if (term_value->val == (sport & term_value->mask))
+ return 1;
+
return 0;
}
@@ -414,10 +414,8 @@ int odp_cos_with_l3_qos(odp_pktio_t pktio_in,
return 0;
}
-odp_pmr_t odp_pmr_create_match(odp_pmr_term_e term,
- const void *val,
- const void *mask,
- uint32_t val_sz)
+odp_pmr_t odp_pmr_create(odp_pmr_term_e term, const void *val,
+ const void *mask, uint32_t val_sz)
{
pmr_t *pmr;
odp_pmr_t id;
@@ -432,41 +430,12 @@ odp_pmr_t odp_pmr_create_match(odp_pmr_term_e term,
return ODP_PMR_INVAL;
pmr->s.num_pmr = 1;
- pmr->s.pmr_term_value[0].match_type = ODP_PMR_MASK;
pmr->s.pmr_term_value[0].term = term;
- pmr->s.pmr_term_value[0].mask.val = 0;
- pmr->s.pmr_term_value[0].mask.mask = 0;
- memcpy(&pmr->s.pmr_term_value[0].mask.val, val, val_sz);
- memcpy(&pmr->s.pmr_term_value[0].mask.mask, mask, val_sz);
- pmr->s.pmr_term_value[0].mask.val &= pmr->s.pmr_term_value[0].mask.mask;
- UNLOCK(&pmr->s.lock);
- return id;
-}
-
-odp_pmr_t odp_pmr_create_range(odp_pmr_term_e term,
- const void *val1,
- const void *val2,
- uint32_t val_sz)
-{
- pmr_t *pmr;
- odp_pmr_t id;
-
- if (val_sz > ODP_PMR_TERM_BYTES_MAX) {
- ODP_ERR("val_sz greater than max supported limit");
- return ODP_PMR_INVAL;
- }
- id = alloc_pmr(&pmr);
- /*if alloc_pmr() is successful it returns with lock acquired*/
- if (id == ODP_PMR_INVAL)
- return ODP_PMR_INVAL;
-
- pmr->s.num_pmr = 1;
- pmr->s.pmr_term_value[0].match_type = ODP_PMR_RANGE;
- pmr->s.pmr_term_value[0].term = term;
- pmr->s.pmr_term_value[0].range.val1 = 0;
- pmr->s.pmr_term_value[0].range.val2 = 0;
- memcpy(&pmr->s.pmr_term_value[0].range.val1, val1, val_sz);
- memcpy(&pmr->s.pmr_term_value[0].range.val2, val2, val_sz);
+ pmr->s.pmr_term_value[0].val = 0;
+ pmr->s.pmr_term_value[0].mask = 0;
+ memcpy(&pmr->s.pmr_term_value[0].val, val, val_sz);
+ memcpy(&pmr->s.pmr_term_value[0].mask, mask, val_sz);
+ pmr->s.pmr_term_value[0].val &= pmr->s.pmr_term_value[0].mask;
UNLOCK(&pmr->s.lock);
return id;
}
@@ -590,32 +559,18 @@ int odp_pmr_match_set_create(int num_terms, odp_pmr_match_t *terms,
pmr->s.num_pmr = num_terms;
for (i = 0; i < num_terms; i++) {
- pmr->s.pmr_term_value[i].match_type = terms[i].match_type;
- if (terms[i].match_type == ODP_PMR_MASK) {
- val_sz = terms[i].mask.val_sz;
- if (val_sz > ODP_PMR_TERM_BYTES_MAX)
- continue;
- pmr->s.pmr_term_value[i].term = terms[i].mask.term;
- pmr->s.pmr_term_value[i].mask.val = 0;
- pmr->s.pmr_term_value[i].mask.mask = 0;
- memcpy(&pmr->s.pmr_term_value[i].mask.val,
- terms[i].mask.val, val_sz);
- memcpy(&pmr->s.pmr_term_value[i].mask.mask,
- terms[i].mask.mask, val_sz);
- pmr->s.pmr_term_value[i].mask.val &= pmr->s
- .pmr_term_value[i].mask.mask;
- } else {
- val_sz = terms[i].range.val_sz;
- if (val_sz > ODP_PMR_TERM_BYTES_MAX)
- continue;
- pmr->s.pmr_term_value[i].term = terms[i].range.term;
- pmr->s.pmr_term_value[i].range.val1 = 0;
- pmr->s.pmr_term_value[i].range.val2 = 0;
- memcpy(&pmr->s.pmr_term_value[i].range.val1,
- terms[i].range.val1, val_sz);
- memcpy(&pmr->s.pmr_term_value[i].range.val2,
- terms[i].range.val2, val_sz);
- }
+ val_sz = terms[i].val_sz;
+ if (val_sz > ODP_PMR_TERM_BYTES_MAX)
+ continue;
+ pmr->s.pmr_term_value[i].term = terms[i].term;
+ pmr->s.pmr_term_value[i].val = 0;
+ pmr->s.pmr_term_value[i].mask = 0;
+ memcpy(&pmr->s.pmr_term_value[i].val,
+ terms[i].val, val_sz);
+ memcpy(&pmr->s.pmr_term_value[i].mask,
+ terms[i].mask, val_sz);
+ pmr->s.pmr_term_value[i].val &= pmr->s
+ .pmr_term_value[i].mask;
count++;
}
*pmr_set_id = id;