diff options
author | Ben Pfaff <blp@nicira.com> | 2011-10-05 10:42:34 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2011-10-12 16:27:09 -0700 |
commit | 9ea0bccc83a84458d934966eae15c78f3ee2bac8 (patch) | |
tree | ecf1a6b0e0667ab14a8d8a8af3ab007114468448 /include/openvswitch | |
parent | 09ded0ad489630236210a02f2d315816e558d701 (diff) | |
download | openvswitch-9ea0bccc83a84458d934966eae15c78f3ee2bac8.tar.gz |
datapath-protocol: Use Linux kernel types directly.
We want datapath-protocol.h to be acceptable as a Linux kernel header, so
it must use Linux kernel types and must not have references to Open vSwitch
symbols or header files. This commit primarily makes that change to
datapath-protocol.h.
At the same time, at least for now we also want datapath-protocol.h to be
usable on non-Linux platforms, so we need some kind of compatiblity. Thus,
this commit also introduces a <linux/types.h> header file that defines the
necessary Linux kernel types on non-Linux platforms.
In turn, this requires openvswitch/types.h to use the Linux types directly
for ovs_be<N>; otherwise, sparse complains because now __be<N> and
ovs_be<N> are incompatible from its perspective, so this commit makes that
change too.
I don't have a non-Linux kernel platform readily available, so I only
tested the non-Linux part of the linux/types.h substitute by forcing that
case to be triggered with #if 0. It worked, except for errors in actual
Linux kernel headers included explicitly from OVS source files, so I think
it's likely to work in practice.
Bug #7559.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
Diffstat (limited to 'include/openvswitch')
-rw-r--r-- | include/openvswitch/datapath-protocol.h | 97 | ||||
-rw-r--r-- | include/openvswitch/types.h | 12 |
2 files changed, 52 insertions, 57 deletions
diff --git a/include/openvswitch/datapath-protocol.h b/include/openvswitch/datapath-protocol.h index b522edc9a..07435beba 100644 --- a/include/openvswitch/datapath-protocol.h +++ b/include/openvswitch/datapath-protocol.h @@ -40,15 +40,8 @@ #ifndef OPENVSWITCH_DATAPATH_PROTOCOL_H #define OPENVSWITCH_DATAPATH_PROTOCOL_H 1 -#ifdef __KERNEL__ #include <linux/types.h> -#define ovs_be16 __be16 -#define ovs_be32 __be32 -#define ovs_be64 __be64 -#else -#include "openvswitch/types.h" -#endif - + /* datapaths. */ #define OVS_DATAPATH_FAMILY "ovs_datapath" @@ -119,26 +112,26 @@ enum ovs_datapath_frag { }; struct ovs_dp_stats { - uint64_t n_frags; /* Number of dropped IP fragments. */ - uint64_t n_hit; /* Number of flow table matches. */ - uint64_t n_missed; /* Number of flow table misses. */ - uint64_t n_lost; /* Number of misses not sent to userspace. */ - uint64_t n_flows; /* Number of flows present */ + __u64 n_frags; /* Number of dropped IP fragments. */ + __u64 n_hit; /* Number of flow table matches. */ + __u64 n_missed; /* Number of flow table misses. */ + __u64 n_lost; /* Number of misses not sent to userspace. */ + __u64 n_flows; /* Number of flows present */ }; struct ovs_vport_stats { - uint64_t rx_packets; /* total packets received */ - uint64_t tx_packets; /* total packets transmitted */ - uint64_t rx_bytes; /* total bytes received */ - uint64_t tx_bytes; /* total bytes transmitted */ - uint64_t rx_errors; /* bad packets received */ - uint64_t tx_errors; /* packet transmit problems */ - uint64_t rx_dropped; /* no space in linux buffers */ - uint64_t tx_dropped; /* no space available in linux */ + __u64 rx_packets; /* total packets received */ + __u64 tx_packets; /* total packets transmitted */ + __u64 rx_bytes; /* total bytes received */ + __u64 tx_bytes; /* total bytes transmitted */ + __u64 rx_errors; /* bad packets received */ + __u64 tx_errors; /* packet transmit problems */ + __u64 rx_dropped; /* no space in linux buffers */ + __u64 tx_dropped; /* no space available in linux */ }; /* Logical ports. */ -#define OVSP_LOCAL ((uint16_t)0) +#define OVSP_LOCAL ((__u16)0) #define OVS_PACKET_FAMILY "ovs_packet" @@ -273,8 +266,8 @@ enum ovs_flow_cmd { }; struct ovs_flow_stats { - uint64_t n_packets; /* Number of matched packets. */ - uint64_t n_bytes; /* Number of matched bytes. */ + __u64 n_packets; /* Number of matched packets. */ + __u64 n_bytes; /* Number of matched bytes. */ }; enum ovs_key_attr { @@ -298,61 +291,61 @@ enum ovs_key_attr { #define OVS_KEY_ATTR_MAX (__OVS_KEY_ATTR_MAX - 1) struct ovs_key_ethernet { - uint8_t eth_src[6]; - uint8_t eth_dst[6]; + __u8 eth_src[6]; + __u8 eth_dst[6]; }; struct ovs_key_8021q { - ovs_be16 q_tpid; - ovs_be16 q_tci; + __be16 q_tpid; + __be16 q_tci; }; struct ovs_key_ipv4 { - ovs_be32 ipv4_src; - ovs_be32 ipv4_dst; - uint8_t ipv4_proto; - uint8_t ipv4_tos; + __be32 ipv4_src; + __be32 ipv4_dst; + __u8 ipv4_proto; + __u8 ipv4_tos; }; struct ovs_key_ipv6 { - ovs_be32 ipv6_src[4]; - ovs_be32 ipv6_dst[4]; - uint8_t ipv6_proto; - uint8_t ipv6_tos; + __be32 ipv6_src[4]; + __be32 ipv6_dst[4]; + __u8 ipv6_proto; + __u8 ipv6_tos; }; struct ovs_key_tcp { - ovs_be16 tcp_src; - ovs_be16 tcp_dst; + __be16 tcp_src; + __be16 tcp_dst; }; struct ovs_key_udp { - ovs_be16 udp_src; - ovs_be16 udp_dst; + __be16 udp_src; + __be16 udp_dst; }; struct ovs_key_icmp { - uint8_t icmp_type; - uint8_t icmp_code; + __u8 icmp_type; + __u8 icmp_code; }; struct ovs_key_icmpv6 { - uint8_t icmpv6_type; - uint8_t icmpv6_code; + __u8 icmpv6_type; + __u8 icmpv6_code; }; struct ovs_key_arp { - ovs_be32 arp_sip; - ovs_be32 arp_tip; - ovs_be16 arp_op; - uint8_t arp_sha[6]; - uint8_t arp_tha[6]; + __be32 arp_sip; + __be32 arp_tip; + __be16 arp_op; + __u8 arp_sha[6]; + __u8 arp_tha[6]; }; struct ovs_key_nd { - uint32_t nd_target[4]; - uint8_t nd_sll[6]; - uint8_t nd_tll[6]; + __u32 nd_target[4]; + __u8 nd_sll[6]; + __u8 nd_tll[6]; }; /** diff --git a/include/openvswitch/types.h b/include/openvswitch/types.h index 4d2a1e9a2..90a32f55d 100644 --- a/include/openvswitch/types.h +++ b/include/openvswitch/types.h @@ -17,6 +17,7 @@ #ifndef OPENVSWITCH_TYPES_H #define OPENVSWITCH_TYPES_H 1 +#include <linux/types.h> #include <sys/types.h> #include <stdint.h> @@ -31,11 +32,12 @@ /* The ovs_be<N> types indicate that an object is in big-endian, not * native-endian, byte order. They are otherwise equivalent to uint<N>_t. * - * The OVS_BITWISE annotation allows the sparse checker to issue warnings - * for incorrect use of values in network byte order. */ -typedef uint16_t OVS_BITWISE ovs_be16; -typedef uint32_t OVS_BITWISE ovs_be32; -typedef uint64_t OVS_BITWISE ovs_be64; + * We bootstrap these from the Linux __be<N> types. If we instead define our + * own independently then __be<N> and ovs_be<N> become mutually + * incompatible. */ +typedef __be16 ovs_be16; +typedef __be32 ovs_be32; +typedef __be64 ovs_be64; /* Netlink and OpenFlow both contain 64-bit values that are only guaranteed to * be aligned on 32-bit boundaries. These types help. |