[dpdk-dev,1/2] lib/net: add IPv6 header fields macros

Message ID 07cfe9a606927b551c3530a2b910ef88547d9118.1514705637.git.shacharbe@mellanox.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Shachar Beiser Dec. 31, 2017, 7:34 a.m. UTC
  Support IPv6 header vtc_flow fields : tc , flow_label

Signed-off-by: Shachar Beiser <shacharbe@mellanox.com>
---
 lib/librte_net/rte_ip.h | 6 ++++++
 1 file changed, 6 insertions(+)
  

Comments

Stephen Hemminger Dec. 31, 2017, 5:37 p.m. UTC | #1
On Sun, 31 Dec 2017 07:34:29 +0000
Shachar Beiser <shacharbe@mellanox.com> wrote:

> +/* IPv6 vtc_flow: IPv / TC / flow_label */
> +#define IPV6_HDR_FL_SHIFT (0)
> +#define IPV6_HDR_TC_SHIFT (20)

No parenthesis needed around simple numeric values.

> +#define IPV6_HDR_FL_MASK ((1 << IPV6_HDR_TC_SHIFT) - 1)

If you use ((1u << IPV6_HDR_TC_SHFIT - 1)
then the mask will be unsigned which probably what you want.

> +#define IPV6_HDR_TC_MASK (0xf << IPV6_HDR_TC_SHIFT)
  

Patch

diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h
index 73ec398..75b9cc3 100644
--- a/lib/librte_net/rte_ip.h
+++ b/lib/librte_net/rte_ip.h
@@ -406,6 +406,12 @@  struct ipv6_hdr {
 	uint8_t  dst_addr[16]; /**< IP address of destination host(s). */
 } __attribute__((__packed__));
 
+/* IPv6 vtc_flow: IPv / TC / flow_label */
+#define IPV6_HDR_FL_SHIFT (0)
+#define IPV6_HDR_TC_SHIFT (20)
+#define IPV6_HDR_FL_MASK ((1 << IPV6_HDR_TC_SHIFT) - 1)
+#define IPV6_HDR_TC_MASK (0xf << IPV6_HDR_TC_SHIFT)
+
 /**
  * Process the pseudo-header checksum of an IPv6 header.
  *