From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Eric Dumazet <edumazet@google.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
netdev <netdev@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Subject: Re: [PATCH] tcp: don't use __constant_cpu_to_be32
Date: Fri, 15 Mar 2019 10:20:12 +0900 [thread overview]
Message-ID: <20190315012012.GA748@jagdpanzerIV> (raw)
In-Reply-To: <CANn89iJMFfh1Pkvk9LOn3FwgAfpVjwS7q5x_8Y9zo2rzpy7w9g@mail.gmail.com>
On (03/14/19 05:42), Eric Dumazet wrote:
> > cpu_to_be32() is capable enough to detect __builtin_constant_p()
> > and to use an appropriate compile time ___constant_swahb32()
> > function.
> >
> > So we can use cpu_to_be32() instead of __constant_cpu_to_be32().
>
>
> I dunno, this is uapi, this might break user space for some funky compiler ?
> I do not even know if cpu_to_be32() _is_ uapi.
Hmm, excellent point.
Looking at
if_pppox.h:#define PTT_EOL __cpu_to_be16(0x0000)
if_pppox.h:#define PTT_SRV_NAME __cpu_to_be16(0x0101)
if_pppox.h:#define PTT_AC_NAME __cpu_to_be16(0x0102)
if_pppox.h:#define PTT_HOST_UNIQ __cpu_to_be16(0x0103)
if_pppox.h:#define PTT_AC_COOKIE __cpu_to_be16(0x0104)
if_pppox.h:#define PTT_VENDOR __cpu_to_be16(0x0105)
if_pppox.h:#define PTT_RELAY_SID __cpu_to_be16(0x0110)
if_pppox.h:#define PTT_SRV_ERR __cpu_to_be16(0x0201)
if_pppox.h:#define PTT_SYS_ERR __cpu_to_be16(0x0202)
if_pppox.h:#define PTT_GEN_ERR __cpu_to_be16(0x0203)
if_tunnel.h:#define GRE_CSUM __cpu_to_be16(0x8000)
if_tunnel.h:#define GRE_ROUTING __cpu_to_be16(0x4000)
if_tunnel.h:#define GRE_KEY __cpu_to_be16(0x2000)
if_tunnel.h:#define GRE_SEQ __cpu_to_be16(0x1000)
if_tunnel.h:#define GRE_STRICT __cpu_to_be16(0x0800)
if_tunnel.h:#define GRE_REC __cpu_to_be16(0x0700)
if_tunnel.h:#define GRE_ACK __cpu_to_be16(0x0080)
if_tunnel.h:#define GRE_FLAGS __cpu_to_be16(0x0078)
if_tunnel.h:#define GRE_VERSION __cpu_to_be16(0x0007)
if_tunnel.h:#define GRE_VERSION_0 __cpu_to_be16(0x0000)
if_tunnel.h:#define GRE_VERSION_1 __cpu_to_be16(0x0001)
if_tunnel.h:#define GRE_PROTO_PPP __cpu_to_be16(0x880b)
You are right, probably would need __cpu_to_be32, which also does
the constant folding.
=-=-=-=-=
Subject: [PATCH] tcp: don't use __constant_cpu_to_be32
__cpu_to_be32() can detect __builtin_constant_p() at compile time.
So we can use __cpu_to_be32() instead of __constant_cpu_to_be32().
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
include/uapi/linux/tcp.h | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h
index 8bb6cc5f3235..cf9c246a59c8 100644
--- a/include/uapi/linux/tcp.h
+++ b/include/uapi/linux/tcp.h
@@ -70,16 +70,16 @@ union tcp_word_hdr {
#define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3])
enum {
- TCP_FLAG_CWR = __constant_cpu_to_be32(0x00800000),
- TCP_FLAG_ECE = __constant_cpu_to_be32(0x00400000),
- TCP_FLAG_URG = __constant_cpu_to_be32(0x00200000),
- TCP_FLAG_ACK = __constant_cpu_to_be32(0x00100000),
- TCP_FLAG_PSH = __constant_cpu_to_be32(0x00080000),
- TCP_FLAG_RST = __constant_cpu_to_be32(0x00040000),
- TCP_FLAG_SYN = __constant_cpu_to_be32(0x00020000),
- TCP_FLAG_FIN = __constant_cpu_to_be32(0x00010000),
- TCP_RESERVED_BITS = __constant_cpu_to_be32(0x0F000000),
- TCP_DATA_OFFSET = __constant_cpu_to_be32(0xF0000000)
+ TCP_FLAG_CWR = __cpu_to_be32(0x00800000),
+ TCP_FLAG_ECE = __cpu_to_be32(0x00400000),
+ TCP_FLAG_URG = __cpu_to_be32(0x00200000),
+ TCP_FLAG_ACK = __cpu_to_be32(0x00100000),
+ TCP_FLAG_PSH = __cpu_to_be32(0x00080000),
+ TCP_FLAG_RST = __cpu_to_be32(0x00040000),
+ TCP_FLAG_SYN = __cpu_to_be32(0x00020000),
+ TCP_FLAG_FIN = __cpu_to_be32(0x00010000),
+ TCP_RESERVED_BITS = __cpu_to_be32(0x0F000000),
+ TCP_DATA_OFFSET = __cpu_to_be32(0xF0000000)
};
/*
--
2.21.0
next prev parent reply other threads:[~2019-03-15 1:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-14 6:15 [PATCH] tcp: don't use __constant_cpu_to_be32 Sergey Senozhatsky
2019-03-14 12:42 ` Eric Dumazet
2019-03-15 1:20 ` Sergey Senozhatsky [this message]
2019-03-15 17:24 ` Stanislav Fomichev
2019-03-16 5:19 ` Sergey Senozhatsky
2019-03-16 7:18 ` Sergey Senozhatsky
2019-03-16 14:26 ` Sergey Senozhatsky
2019-03-18 16:32 ` Stanislav Fomichev
2019-03-19 1:29 ` Sergey Senozhatsky
2019-03-18 16:28 ` Stanislav Fomichev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190315012012.GA748@jagdpanzerIV \
--to=sergey.senozhatsky.work@gmail.com \
--cc=edumazet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sergey.senozhatsky@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).