* [dpdk-dev] [PATCH] net: add missing endianness annotations
@ 2019-09-27 11:58 David Marchand
2019-10-18 8:43 ` Olivier Matz
0 siblings, 1 reply; 6+ messages in thread
From: David Marchand @ 2019-09-27 11:58 UTC (permalink / raw)
To: dev; +Cc: ian.stokes, i.maximets, ktraynor, Olivier Matz
OVS currently maintains a copy of those headers with the right endianness
annotations so that sparse checks can pass.
We introduced rte_beXX_t for better readibility in v17.08.
Let's make use of them, OVS then only needs to override those rte_beXX_t
types by exposing a tweaked rte_byteorder.h header.
Other existing dpdk users won't be affected since rte_beXX_t types are
mapped to uintXX_t types.
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
lib/librte_net/rte_icmp.h | 12 +++++++-----
lib/librte_net/rte_ip.h | 28 ++++++++++++++--------------
lib/librte_net/rte_sctp.h | 10 ++++++----
lib/librte_net/rte_tcp.h | 20 +++++++++++---------
lib/librte_net/rte_udp.h | 10 ++++++----
5 files changed, 44 insertions(+), 36 deletions(-)
diff --git a/lib/librte_net/rte_icmp.h b/lib/librte_net/rte_icmp.h
index 3f8100a..e0aeed4 100644
--- a/lib/librte_net/rte_icmp.h
+++ b/lib/librte_net/rte_icmp.h
@@ -16,6 +16,8 @@
#include <stdint.h>
+#include <rte_byteorder.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -24,11 +26,11 @@ extern "C" {
* ICMP Header
*/
struct rte_icmp_hdr {
- uint8_t icmp_type; /* ICMP packet type. */
- uint8_t icmp_code; /* ICMP packet code. */
- uint16_t icmp_cksum; /* ICMP packet checksum. */
- uint16_t icmp_ident; /* ICMP packet identifier. */
- uint16_t icmp_seq_nb; /* ICMP packet sequence number. */
+ uint8_t icmp_type; /* ICMP packet type. */
+ uint8_t icmp_code; /* ICMP packet code. */
+ rte_be16_t icmp_cksum; /* ICMP packet checksum. */
+ rte_be16_t icmp_ident; /* ICMP packet identifier. */
+ rte_be16_t icmp_seq_nb; /* ICMP packet sequence number. */
} __attribute__((__packed__));
/* ICMP packet types */
diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h
index f82454b..731ee4f 100644
--- a/lib/librte_net/rte_ip.h
+++ b/lib/librte_net/rte_ip.h
@@ -33,14 +33,14 @@ extern "C" {
struct rte_ipv4_hdr {
uint8_t version_ihl; /**< version and header length */
uint8_t type_of_service; /**< type of service */
- uint16_t total_length; /**< length of packet */
- uint16_t packet_id; /**< packet ID */
- uint16_t fragment_offset; /**< fragmentation offset */
+ rte_be16_t total_length; /**< length of packet */
+ rte_be16_t packet_id; /**< packet ID */
+ rte_be16_t fragment_offset; /**< fragmentation offset */
uint8_t time_to_live; /**< time to live */
uint8_t next_proto_id; /**< protocol ID */
- uint16_t hdr_checksum; /**< header checksum */
- uint32_t src_addr; /**< source address */
- uint32_t dst_addr; /**< destination address */
+ rte_be16_t hdr_checksum; /**< header checksum */
+ rte_be32_t src_addr; /**< source address */
+ rte_be32_t dst_addr; /**< destination address */
} __attribute__((__packed__));
/** Create IPv4 address */
@@ -354,12 +354,12 @@ rte_ipv4_udptcp_cksum(const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr)
* IPv6 Header
*/
struct rte_ipv6_hdr {
- uint32_t vtc_flow; /**< IP version, traffic class & flow label. */
- uint16_t payload_len; /**< IP packet length - includes sizeof(ip_header). */
- uint8_t proto; /**< Protocol, next header. */
- uint8_t hop_limits; /**< Hop limits. */
- uint8_t src_addr[16]; /**< IP address of source host. */
- uint8_t dst_addr[16]; /**< IP address of destination host(s). */
+ rte_be32_t vtc_flow; /**< IP version, traffic class & flow label. */
+ rte_be16_t payload_len; /**< IP packet length - includes header size */
+ uint8_t proto; /**< Protocol, next header. */
+ uint8_t hop_limits; /**< Hop limits. */
+ uint8_t src_addr[16]; /**< IP address of source host. */
+ uint8_t dst_addr[16]; /**< IP address of destination host(s). */
} __attribute__((__packed__));
/* IPv6 vtc_flow: IPv / TC / flow_label */
@@ -392,8 +392,8 @@ rte_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags)
{
uint32_t sum;
struct {
- uint32_t len; /* L4 length. */
- uint32_t proto; /* L4 protocol - top 3 bytes must be zero */
+ rte_be32_t len; /* L4 length. */
+ rte_be32_t proto; /* L4 protocol - top 3 bytes must be zero */
} psd_hdr;
psd_hdr.proto = (uint32_t)(ipv6_hdr->proto << 24);
diff --git a/lib/librte_net/rte_sctp.h b/lib/librte_net/rte_sctp.h
index b3661b0..ab38be7 100644
--- a/lib/librte_net/rte_sctp.h
+++ b/lib/librte_net/rte_sctp.h
@@ -20,14 +20,16 @@ extern "C" {
#include <stdint.h>
+#include <rte_byteorder.h>
+
/**
* SCTP Header
*/
struct rte_sctp_hdr {
- uint16_t src_port; /**< Source port. */
- uint16_t dst_port; /**< Destin port. */
- uint32_t tag; /**< Validation tag. */
- uint32_t cksum; /**< Checksum. */
+ rte_be16_t src_port; /**< Source port. */
+ rte_be16_t dst_port; /**< Destin port. */
+ rte_be32_t tag; /**< Validation tag. */
+ rte_be32_t cksum; /**< Checksum. */
} __attribute__((__packed__));
#ifdef __cplusplus
diff --git a/lib/librte_net/rte_tcp.h b/lib/librte_net/rte_tcp.h
index 7d649a2..06f623d 100644
--- a/lib/librte_net/rte_tcp.h
+++ b/lib/librte_net/rte_tcp.h
@@ -16,6 +16,8 @@
#include <stdint.h>
+#include <rte_byteorder.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -24,15 +26,15 @@ extern "C" {
* TCP Header
*/
struct rte_tcp_hdr {
- uint16_t src_port; /**< TCP source port. */
- uint16_t dst_port; /**< TCP destination port. */
- uint32_t sent_seq; /**< TX data sequence number. */
- uint32_t recv_ack; /**< RX data acknowledgement sequence number. */
- uint8_t data_off; /**< Data offset. */
- uint8_t tcp_flags; /**< TCP flags */
- uint16_t rx_win; /**< RX flow control window. */
- uint16_t cksum; /**< TCP checksum. */
- uint16_t tcp_urp; /**< TCP urgent pointer, if any. */
+ rte_be16_t src_port; /**< TCP source port. */
+ rte_be16_t dst_port; /**< TCP destination port. */
+ rte_be32_t sent_seq; /**< TX data sequence number. */
+ rte_be32_t recv_ack; /**< RX data acknowledgment sequence number. */
+ uint8_t data_off; /**< Data offset. */
+ uint8_t tcp_flags; /**< TCP flags */
+ rte_be16_t rx_win; /**< RX flow control window. */
+ rte_be16_t cksum; /**< TCP checksum. */
+ rte_be16_t tcp_urp; /**< TCP urgent pointer, if any. */
} __attribute__((__packed__));
/**
diff --git a/lib/librte_net/rte_udp.h b/lib/librte_net/rte_udp.h
index 1c3437c..01c26b3 100644
--- a/lib/librte_net/rte_udp.h
+++ b/lib/librte_net/rte_udp.h
@@ -16,6 +16,8 @@
#include <stdint.h>
+#include <rte_byteorder.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -24,10 +26,10 @@ extern "C" {
* UDP Header
*/
struct rte_udp_hdr {
- uint16_t src_port; /**< UDP source port. */
- uint16_t dst_port; /**< UDP destination port. */
- uint16_t dgram_len; /**< UDP datagram length */
- uint16_t dgram_cksum; /**< UDP datagram checksum */
+ rte_be16_t src_port; /**< UDP source port. */
+ rte_be16_t dst_port; /**< UDP destination port. */
+ rte_be16_t dgram_len; /**< UDP datagram length */
+ rte_be16_t dgram_cksum; /**< UDP datagram checksum */
} __attribute__((__packed__));
#ifdef __cplusplus
--
1.8.3.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] net: add missing endianness annotations
2019-09-27 11:58 [dpdk-dev] [PATCH] net: add missing endianness annotations David Marchand
@ 2019-10-18 8:43 ` Olivier Matz
2019-10-18 8:47 ` David Marchand
0 siblings, 1 reply; 6+ messages in thread
From: Olivier Matz @ 2019-10-18 8:43 UTC (permalink / raw)
To: David Marchand; +Cc: dev, ian.stokes, i.maximets, ktraynor
Hi David,
2lOn Fri, Sep 27, 2019 at 01:58:02PM +0200, David Marchand wrote:
> OVS currently maintains a copy of those headers with the right endianness
> annotations so that sparse checks can pass.
>
> We introduced rte_beXX_t for better readibility in v17.08.
> Let's make use of them, OVS then only needs to override those rte_beXX_t
> types by exposing a tweaked rte_byteorder.h header.
>
> Other existing dpdk users won't be affected since rte_beXX_t types are
> mapped to uintXX_t types.
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
> lib/librte_net/rte_icmp.h | 12 +++++++-----
> lib/librte_net/rte_ip.h | 28 ++++++++++++++--------------
> lib/librte_net/rte_sctp.h | 10 ++++++----
> lib/librte_net/rte_tcp.h | 20 +++++++++++---------
> lib/librte_net/rte_udp.h | 10 ++++++----
> 5 files changed, 44 insertions(+), 36 deletions(-)
Is there a reason why you didn't change arp, gre, ... ?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] net: add missing endianness annotations
2019-10-18 8:43 ` Olivier Matz
@ 2019-10-18 8:47 ` David Marchand
2019-10-18 9:23 ` Olivier Matz
0 siblings, 1 reply; 6+ messages in thread
From: David Marchand @ 2019-10-18 8:47 UTC (permalink / raw)
To: Olivier Matz; +Cc: dev, Ian Stokes, Ilya Maximets, Kevin Traynor
On Fri, Oct 18, 2019 at 10:43 AM Olivier Matz <olivier.matz@6wind.com> wrote:
>
> Hi David,
>
> 2lOn Fri, Sep 27, 2019 at 01:58:02PM +0200, David Marchand wrote:
> > OVS currently maintains a copy of those headers with the right endianness
> > annotations so that sparse checks can pass.
> >
> > We introduced rte_beXX_t for better readibility in v17.08.
> > Let's make use of them, OVS then only needs to override those rte_beXX_t
> > types by exposing a tweaked rte_byteorder.h header.
> >
> > Other existing dpdk users won't be affected since rte_beXX_t types are
> > mapped to uintXX_t types.
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
> > ---
> > lib/librte_net/rte_icmp.h | 12 +++++++-----
> > lib/librte_net/rte_ip.h | 28 ++++++++++++++--------------
> > lib/librte_net/rte_sctp.h | 10 ++++++----
> > lib/librte_net/rte_tcp.h | 20 +++++++++++---------
> > lib/librte_net/rte_udp.h | 10 ++++++----
> > 5 files changed, 44 insertions(+), 36 deletions(-)
>
> Is there a reason why you didn't change arp, gre, ... ?
Let me look at the other headers, I had focused on what OVS used.
Is this current patch ok?
--
David Marchand
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] net: add missing endianness annotations
2019-10-18 8:47 ` David Marchand
@ 2019-10-18 9:23 ` Olivier Matz
2019-10-18 17:00 ` Ferruh Yigit
0 siblings, 1 reply; 6+ messages in thread
From: Olivier Matz @ 2019-10-18 9:23 UTC (permalink / raw)
To: David Marchand; +Cc: dev, Ian Stokes, Ilya Maximets, Kevin Traynor
On Fri, Oct 18, 2019 at 10:47:37AM +0200, David Marchand wrote:
> On Fri, Oct 18, 2019 at 10:43 AM Olivier Matz <olivier.matz@6wind.com> wrote:
> >
> > Hi David,
> >
> > 2lOn Fri, Sep 27, 2019 at 01:58:02PM +0200, David Marchand wrote:
> > > OVS currently maintains a copy of those headers with the right endianness
> > > annotations so that sparse checks can pass.
> > >
> > > We introduced rte_beXX_t for better readibility in v17.08.
> > > Let's make use of them, OVS then only needs to override those rte_beXX_t
> > > types by exposing a tweaked rte_byteorder.h header.
> > >
> > > Other existing dpdk users won't be affected since rte_beXX_t types are
> > > mapped to uintXX_t types.
> > >
> > > Signed-off-by: David Marchand <david.marchand@redhat.com>
> > > ---
> > > lib/librte_net/rte_icmp.h | 12 +++++++-----
> > > lib/librte_net/rte_ip.h | 28 ++++++++++++++--------------
> > > lib/librte_net/rte_sctp.h | 10 ++++++----
> > > lib/librte_net/rte_tcp.h | 20 +++++++++++---------
> > > lib/librte_net/rte_udp.h | 10 ++++++----
> > > 5 files changed, 44 insertions(+), 36 deletions(-)
> >
> > Is there a reason why you didn't change arp, gre, ... ?
>
> Let me look at the other headers, I had focused on what OVS used.
>
> Is this current patch ok?
Yes, it looks good to me.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] net: add missing endianness annotations
2019-10-18 9:23 ` Olivier Matz
@ 2019-10-18 17:00 ` Ferruh Yigit
2019-10-18 17:08 ` Ferruh Yigit
0 siblings, 1 reply; 6+ messages in thread
From: Ferruh Yigit @ 2019-10-18 17:00 UTC (permalink / raw)
To: Olivier Matz, David Marchand
Cc: dev, Ian Stokes, Ilya Maximets, Kevin Traynor
On 10/18/2019 10:23 AM, Olivier Matz wrote:
> On Fri, Oct 18, 2019 at 10:47:37AM +0200, David Marchand wrote:
>> On Fri, Oct 18, 2019 at 10:43 AM Olivier Matz <olivier.matz@6wind.com> wrote:
>>>
>>> Hi David,
>>>
>>> 2lOn Fri, Sep 27, 2019 at 01:58:02PM +0200, David Marchand wrote:
>>>> OVS currently maintains a copy of those headers with the right endianness
>>>> annotations so that sparse checks can pass.
>>>>
>>>> We introduced rte_beXX_t for better readibility in v17.08.
>>>> Let's make use of them, OVS then only needs to override those rte_beXX_t
>>>> types by exposing a tweaked rte_byteorder.h header.
>>>>
>>>> Other existing dpdk users won't be affected since rte_beXX_t types are
>>>> mapped to uintXX_t types.
>>>>
>>>> Signed-off-by: David Marchand <david.marchand@redhat.com>
>>>> ---
>>>> lib/librte_net/rte_icmp.h | 12 +++++++-----
>>>> lib/librte_net/rte_ip.h | 28 ++++++++++++++--------------
>>>> lib/librte_net/rte_sctp.h | 10 ++++++----
>>>> lib/librte_net/rte_tcp.h | 20 +++++++++++---------
>>>> lib/librte_net/rte_udp.h | 10 ++++++----
>>>> 5 files changed, 44 insertions(+), 36 deletions(-)
>>>
>>> Is there a reason why you didn't change arp, gre, ... ?
>>
>> Let me look at the other headers, I had focused on what OVS used.
>>
>> Is this current patch ok?
>
> Yes, it looks good to me.
>
Converting to an explicit ack J
Acked-by: Olivier Matz <olivier.matz@6wind.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH] net: add missing endianness annotations
2019-10-18 17:00 ` Ferruh Yigit
@ 2019-10-18 17:08 ` Ferruh Yigit
0 siblings, 0 replies; 6+ messages in thread
From: Ferruh Yigit @ 2019-10-18 17:08 UTC (permalink / raw)
To: Olivier Matz, David Marchand
Cc: dev, Ian Stokes, Ilya Maximets, Kevin Traynor
On 10/18/2019 6:00 PM, Ferruh Yigit wrote:
> On 10/18/2019 10:23 AM, Olivier Matz wrote:
>> On Fri, Oct 18, 2019 at 10:47:37AM +0200, David Marchand wrote:
>>> On Fri, Oct 18, 2019 at 10:43 AM Olivier Matz <olivier.matz@6wind.com> wrote:
>>>>
>>>> Hi David,
>>>>
>>>> 2lOn Fri, Sep 27, 2019 at 01:58:02PM +0200, David Marchand wrote:
>>>>> OVS currently maintains a copy of those headers with the right endianness
>>>>> annotations so that sparse checks can pass.
>>>>>
>>>>> We introduced rte_beXX_t for better readibility in v17.08.
>>>>> Let's make use of them, OVS then only needs to override those rte_beXX_t
>>>>> types by exposing a tweaked rte_byteorder.h header.
>>>>>
>>>>> Other existing dpdk users won't be affected since rte_beXX_t types are
>>>>> mapped to uintXX_t types.
>>>>>
>>>>> Signed-off-by: David Marchand <david.marchand@redhat.com>
>>>>> ---
>>>>> lib/librte_net/rte_icmp.h | 12 +++++++-----
>>>>> lib/librte_net/rte_ip.h | 28 ++++++++++++++--------------
>>>>> lib/librte_net/rte_sctp.h | 10 ++++++----
>>>>> lib/librte_net/rte_tcp.h | 20 +++++++++++---------
>>>>> lib/librte_net/rte_udp.h | 10 ++++++----
>>>>> 5 files changed, 44 insertions(+), 36 deletions(-)
>>>>
>>>> Is there a reason why you didn't change arp, gre, ... ?
>>>
>>> Let me look at the other headers, I had focused on what OVS used.
>>>
>>> Is this current patch ok?
>>
>> Yes, it looks good to me.
>>
>
> Converting to an explicit ack J
> Acked-by: Olivier Matz <olivier.matz@6wind.com>
>
Applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-10-18 17:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-27 11:58 [dpdk-dev] [PATCH] net: add missing endianness annotations David Marchand
2019-10-18 8:43 ` Olivier Matz
2019-10-18 8:47 ` David Marchand
2019-10-18 9:23 ` Olivier Matz
2019-10-18 17:00 ` Ferruh Yigit
2019-10-18 17:08 ` Ferruh Yigit
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).