[v4] net: add bit fields to IPv6 header definition
Checks
Commit Message
DPDK IPv6 header definition combined the `version`, `traffic class`
and `flow label` header fields into a single 32 bits structure member
`vtc_flow`.
The patch expands IPv6 header definition with dedicated structure
members for the `version`, `traffic class` and `flow label` fields.
The `traffic class` is also separated into DS and ECN fields.
The patch also preserves existing `vtc_flow` structure member for
backward compatibility.
Signed-off-by: Gregory Etelson <getelson@nvidia.com>
---
v2:
Replace uint32_t with rte_be32_t.
Split traffic_class into DS and ECN bits.
v3:
Define both traffic_class and DS + ECN fields.
v4:
The `packed` attribute works on bytes only.
Back to v2.
---
lib/net/rte_ip.h | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
Comments
> From: Gregory Etelson [mailto:getelson@nvidia.com]
>
> DPDK IPv6 header definition combined the `version`, `traffic class`
> and `flow label` header fields into a single 32 bits structure member
> `vtc_flow`.
>
> The patch expands IPv6 header definition with dedicated structure
> members for the `version`, `traffic class` and `flow label` fields.
> The `traffic class` is also separated into DS and ECN fields.
>
> The patch also preserves existing `vtc_flow` structure member for
> backward compatibility.
>
> Signed-off-by: Gregory Etelson <getelson@nvidia.com>
> ---
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
On Tue, Jun 18, 2024 at 2:44 PM Morten Brørup <mb@smartsharesystems.com> wrote:
> > From: Gregory Etelson [mailto:getelson@nvidia.com]
> >
> > DPDK IPv6 header definition combined the `version`, `traffic class`
> > and `flow label` header fields into a single 32 bits structure member
> > `vtc_flow`.
> >
> > The patch expands IPv6 header definition with dedicated structure
> > members for the `version`, `traffic class` and `flow label` fields.
> > The `traffic class` is also separated into DS and ECN fields.
> >
> > The patch also preserves existing `vtc_flow` structure member for
> > backward compatibility.
> >
> > Signed-off-by: Gregory Etelson <getelson@nvidia.com>
> Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
Applied, thanks.
@@ -524,7 +524,23 @@ rte_ipv4_udptcp_cksum_mbuf_verify(const struct rte_mbuf *m,
* IPv6 Header
*/
struct rte_ipv6_hdr {
- rte_be32_t vtc_flow; /**< IP version, traffic class & flow label. */
+ union {
+ rte_be32_t vtc_flow; /**< IP version, traffic class & flow label. */
+ __extension__
+ struct {
+#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
+ rte_be32_t flow_label:20; /**< flow label */
+ rte_be32_t ecn:2; /**< ECN */
+ rte_be32_t ds:6; /**< differentiated services */
+ rte_be32_t version:4; /**< version */
+#elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
+ rte_be32_t version:4; /**< version */
+ rte_be32_t ds:6; /**< differentiated services */
+ rte_be32_t ecn:2; /**< ECN */
+ rte_be32_t flow_label:20; /**< flow label */
+#endif
+ };
+ };
rte_be16_t payload_len; /**< IP payload size, including ext. headers */
uint8_t proto; /**< Protocol, next header. */
uint8_t hop_limits; /**< Hop limits. */