diff mbox

[v2,1/5] linux-generic: packet: remove l3_protocol and l4_protocol members from odp_packet_hdr_t

Message ID 1463392220-22856-2-git-send-email-matias.elo@nokia.com
State Accepted
Commit e15953609ace31ab4409216125213c44b1723c8e
Headers show

Commit Message

Elo, Matias (Nokia - FI/Espoo) May 16, 2016, 9:50 a.m. UTC
Remove unnecessary struct odp_packet_hdr_t members
l3_protocol and l4_protocol to reduce struct size.

l4_protocol was only used by IPsec and is now replaced by
two new input flags ipsec_ah and ipsec_esp.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
---
 platform/linux-generic/include/odp_classification_inlines.h |  7 ++-----
 platform/linux-generic/include/odp_packet_internal.h        | 10 +++++-----
 platform/linux-generic/odp_packet.c                         |  9 +++++----
 3 files changed, 12 insertions(+), 14 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_classification_inlines.h b/platform/linux-generic/include/odp_classification_inlines.h
index b8b04ce..08300f5 100644
--- a/platform/linux-generic/include/odp_classification_inlines.h
+++ b/platform/linux-generic/include/odp_classification_inlines.h
@@ -217,16 +217,13 @@  static inline int verify_pmr_ipsec_spi(const uint8_t *pkt_addr,
 {
 	uint32_t spi;
 
-	if (!pkt_hdr->input_flags.ipsec)
-		return 0;
-
 	pkt_addr += pkt_hdr->l4_offset;
 
-	if (pkt_hdr->l4_protocol == ODPH_IPPROTO_AH) {
+	if (pkt_hdr->input_flags.ipsec_ah) {
 		const odph_ahhdr_t *ahhdr = (const odph_ahhdr_t *)pkt_addr;
 
 		spi = odp_be_to_cpu_32(ahhdr->spi);
-	} else if (pkt_hdr->l4_protocol == ODPH_IPPROTO_ESP) {
+	} else if (pkt_hdr->input_flags.ipsec_esp) {
 		const odph_esphdr_t *esphdr = (const odph_esphdr_t *)pkt_addr;
 
 		spi = odp_be_to_cpu_32(esphdr->spi);
diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h
index 93a92a0..508adf8 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -64,8 +64,12 @@  typedef union {
 		uint32_t ip_mcast:1;  /**< IP multicast */
 		uint32_t ipfrag:1;    /**< IP fragment */
 		uint32_t ipopt:1;     /**< IP optional headers */
-		uint32_t ipsec:1;     /**< IPSec decryption may be needed */
 
+		uint32_t ipsec:1;     /**< IPSec packet. Required by the
+					   odp_packet_has_ipsec_set() func. */
+		uint32_t ipsec_ah:1;  /**< IPSec authentication header */
+		uint32_t ipsec_esp:1; /**< IPSec encapsulating security
+					   payload */
 		uint32_t udp:1;       /**< UDP */
 		uint32_t tcp:1;       /**< TCP */
 		uint32_t tcpopt:1;    /**< TCP options present */
@@ -141,9 +145,7 @@  typedef struct {
 
 	uint32_t vlan_s_tag;     /**< Parsed 1st VLAN header (S-TAG) */
 	uint32_t vlan_c_tag;     /**< Parsed 2nd VLAN header (C-TAG) */
-	uint32_t l3_protocol;    /**< Parsed L3 protocol */
 	uint32_t l3_len;         /**< Layer 3 length */
-	uint32_t l4_protocol;    /**< Parsed L4 protocol */
 	uint32_t l4_len;         /**< Layer 4 length */
 
 	uint32_t frame_len;
@@ -184,9 +186,7 @@  static inline void copy_packet_parser_metadata(odp_packet_hdr_t *src_hdr,
 
 	dst_hdr->vlan_s_tag     = src_hdr->vlan_s_tag;
 	dst_hdr->vlan_c_tag     = src_hdr->vlan_c_tag;
-	dst_hdr->l3_protocol    = src_hdr->l3_protocol;
 	dst_hdr->l3_len         = src_hdr->l3_len;
-	dst_hdr->l4_protocol    = src_hdr->l4_protocol;
 	dst_hdr->l4_len         = src_hdr->l4_len;
 }
 
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index b002492..8681c08 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -44,8 +44,6 @@  void packet_parse_reset(odp_packet_hdr_t *pkt_hdr)
 	pkt_hdr->payload_offset   = ODP_PACKET_OFFSET_INVALID;
 	pkt_hdr->vlan_s_tag       = 0;
 	pkt_hdr->vlan_c_tag       = 0;
-	pkt_hdr->l3_protocol      = 0;
-	pkt_hdr->l4_protocol      = 0;
 }
 
 /**
@@ -1242,7 +1240,6 @@  int _odp_parse_common(odp_packet_hdr_t *pkt_hdr, const uint8_t *ptr)
 	/* Set l3_offset+flag only for known ethtypes */
 	pkt_hdr->input_flags.l3 = 1;
 	pkt_hdr->l3_offset = offset;
-	pkt_hdr->l3_protocol = ethtype;
 
 	/* Parse Layer 3 headers */
 	switch (ethtype) {
@@ -1270,7 +1267,6 @@  int _odp_parse_common(odp_packet_hdr_t *pkt_hdr, const uint8_t *ptr)
 	/* Set l4_offset+flag only for known ip_proto */
 	pkt_hdr->input_flags.l4 = 1;
 	pkt_hdr->l4_offset = offset;
-	pkt_hdr->l4_protocol = ip_proto;
 
 	/* Parse Layer 4 headers */
 	switch (ip_proto) {
@@ -1289,8 +1285,13 @@  int _odp_parse_common(odp_packet_hdr_t *pkt_hdr, const uint8_t *ptr)
 		break;
 
 	case ODPH_IPPROTO_AH:
+		pkt_hdr->input_flags.ipsec = 1;
+		pkt_hdr->input_flags.ipsec_ah = 1;
+		break;
+
 	case ODPH_IPPROTO_ESP:
 		pkt_hdr->input_flags.ipsec = 1;
+		pkt_hdr->input_flags.ipsec_esp = 1;
 		break;
 
 	default: