Linux NFS development
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: linux-nfs@vger.kernel.org
Cc: simo@redhat.com
Subject: [PATCH RFC 04/10] SUNRPC: Add common byte-swapped RPC header constants
Date: Fri, 01 Feb 2019 14:57:47 -0500	[thread overview]
Message-ID: <20190201195747.11389.75164.stgit@manet.1015granger.net> (raw)
In-Reply-To: <20190201195538.11389.96106.stgit@manet.1015granger.net>

Byte-swapping causes a CPU pipeline bubble on some processors. When
a decoder is comparing an on-the-wire value for equality, byte-
swapping can be avoided by comparing it directly to a pre-byte-
swapped constant value.

The current set of pre-xdr'd constants is missing some common values
used in the RPC header. Fill those out.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 include/linux/sunrpc/auth_gss.h |    5 ++-
 include/linux/sunrpc/xdr.h      |   66 ++++++++++++++++++++++++---------------
 2 files changed, 45 insertions(+), 26 deletions(-)

diff --git a/include/linux/sunrpc/auth_gss.h b/include/linux/sunrpc/auth_gss.h
index 30427b7..adc4be2 100644
--- a/include/linux/sunrpc/auth_gss.h
+++ b/include/linux/sunrpc/auth_gss.h
@@ -19,7 +19,10 @@
 #include <linux/sunrpc/svc.h>
 #include <linux/sunrpc/gss_api.h>
 
-#define RPC_GSS_VERSION		1
+enum {
+	RPC_GSS_VERSION = 1,
+	rpc_gss_version = cpu_to_be32(RPC_GSS_VERSION)
+};
 
 #define MAXSEQ 0x80000000 /* maximum legal sequence number, from rfc 2203 */
 
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index 787939d..69161cb 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -17,6 +17,7 @@
 #include <asm/byteorder.h>
 #include <asm/unaligned.h>
 #include <linux/scatterlist.h>
+#include <linux/sunrpc/msg_prot.h>
 
 struct bio_vec;
 struct rpc_rqst;
@@ -79,31 +80,46 @@ struct xdr_buf {
 	buf->buflen = len;
 }
 
-/*
- * pre-xdr'ed macros.
- */
-
-#define	xdr_zero	cpu_to_be32(0)
-#define	xdr_one		cpu_to_be32(1)
-#define	xdr_two		cpu_to_be32(2)
-
-#define	rpc_success		cpu_to_be32(RPC_SUCCESS)
-#define	rpc_prog_unavail	cpu_to_be32(RPC_PROG_UNAVAIL)
-#define	rpc_prog_mismatch	cpu_to_be32(RPC_PROG_MISMATCH)
-#define	rpc_proc_unavail	cpu_to_be32(RPC_PROC_UNAVAIL)
-#define	rpc_garbage_args	cpu_to_be32(RPC_GARBAGE_ARGS)
-#define	rpc_system_err		cpu_to_be32(RPC_SYSTEM_ERR)
-#define	rpc_drop_reply		cpu_to_be32(RPC_DROP_REPLY)
-
-#define	rpc_auth_ok		cpu_to_be32(RPC_AUTH_OK)
-#define	rpc_autherr_badcred	cpu_to_be32(RPC_AUTH_BADCRED)
-#define	rpc_autherr_rejectedcred cpu_to_be32(RPC_AUTH_REJECTEDCRED)
-#define	rpc_autherr_badverf	cpu_to_be32(RPC_AUTH_BADVERF)
-#define	rpc_autherr_rejectedverf cpu_to_be32(RPC_AUTH_REJECTEDVERF)
-#define	rpc_autherr_tooweak	cpu_to_be32(RPC_AUTH_TOOWEAK)
-#define	rpcsec_gsserr_credproblem	cpu_to_be32(RPCSEC_GSS_CREDPROBLEM)
-#define	rpcsec_gsserr_ctxproblem	cpu_to_be32(RPCSEC_GSS_CTXPROBLEM)
-#define	rpc_autherr_oldseqnum	cpu_to_be32(101)
+enum xdr_be32_equivalents {
+	xdr_zero		= cpu_to_be32(0),
+	xdr_one			= cpu_to_be32(1),
+	xdr_two			= cpu_to_be32(2),
+
+	rpc_version		= cpu_to_be32(RPC_VERSION),
+
+	rpc_auth_null		= cpu_to_be32(RPC_AUTH_NULL),
+	rpc_auth_unix		= cpu_to_be32(RPC_AUTH_UNIX),
+	rpc_auth_short		= cpu_to_be32(RPC_AUTH_SHORT),
+	rpc_auth_des		= cpu_to_be32(RPC_AUTH_DES),
+	rpc_auth_krb		= cpu_to_be32(RPC_AUTH_KRB),
+	rpc_auth_gss		= cpu_to_be32(RPC_AUTH_GSS),
+
+	rpc_call		= cpu_to_be32(RPC_CALL),
+	rpc_reply		= cpu_to_be32(RPC_REPLY),
+
+	rpc_msg_accepted	= cpu_to_be32(RPC_MSG_ACCEPTED),
+	rpc_msg_denied		= cpu_to_be32(RPC_MSG_DENIED),
+
+	rpc_success		= cpu_to_be32(RPC_SUCCESS),
+	rpc_prog_unavail	= cpu_to_be32(RPC_PROG_UNAVAIL),
+	rpc_prog_mismatch	= cpu_to_be32(RPC_PROG_MISMATCH),
+	rpc_proc_unavail	= cpu_to_be32(RPC_PROC_UNAVAIL),
+	rpc_garbage_args	= cpu_to_be32(RPC_GARBAGE_ARGS),
+	rpc_system_err		= cpu_to_be32(RPC_SYSTEM_ERR),
+	rpc_drop_reply		= cpu_to_be32(RPC_DROP_REPLY),
+
+	rpc_mismatch		= cpu_to_be32(RPC_MISMATCH),
+	rpc_auth_error		= cpu_to_be32(RPC_AUTH_ERROR),
+
+	rpc_auth_ok		= cpu_to_be32(RPC_AUTH_OK),
+	rpc_autherr_badcred	= cpu_to_be32(RPC_AUTH_BADCRED),
+	rpc_autherr_rejectedcred = cpu_to_be32(RPC_AUTH_REJECTEDCRED),
+	rpc_autherr_badverf	= cpu_to_be32(RPC_AUTH_BADVERF),
+	rpc_autherr_rejectedverf = cpu_to_be32(RPC_AUTH_REJECTEDVERF),
+	rpc_autherr_tooweak	= cpu_to_be32(RPC_AUTH_TOOWEAK),
+	rpcsec_gsserr_credproblem = cpu_to_be32(RPCSEC_GSS_CREDPROBLEM),
+	rpcsec_gsserr_ctxproblem = cpu_to_be32(RPCSEC_GSS_CTXPROBLEM),
+};
 
 /*
  * Miscellaneous XDR helper functions


  parent reply	other threads:[~2019-02-01 19:57 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-01 19:57 [PATCH RFC 00/10] SUNRPC GSS overhaul Chuck Lever
2019-02-01 19:57 ` [PATCH RFC 01/10] SUNRPC: Remove some dprintk() call sites from auth functions Chuck Lever
2019-02-04 19:04   ` J. Bruce Fields
2019-02-04 19:07     ` Chuck Lever
2019-02-01 19:57 ` [PATCH RFC 02/10] SUNRPC: Remove rpc_xprt::tsh_size Chuck Lever
2019-02-01 19:57 ` [PATCH RFC 03/10] SUNRPC: Add build option to disable support for insecure enctypes Chuck Lever
2019-02-01 19:57 ` Chuck Lever [this message]
2019-02-02  2:30   ` [PATCH RFC 04/10] SUNRPC: Add common byte-swapped RPC header constants Tom Talpey
2019-02-02 22:46     ` Chuck Lever
2019-02-03 15:00       ` Trond Myklebust
2019-02-03 16:49         ` Chuck Lever
2019-02-03 18:58           ` Trond Myklebust
2019-02-02 17:02   ` Christoph Hellwig
2019-02-02 22:49     ` Chuck Lever
2019-02-04  7:53       ` Christoph Hellwig
2019-02-04 14:16         ` Chuck Lever
2019-02-04 14:32           ` Christoph Hellwig
2019-02-04 14:56             ` Chuck Lever
2019-02-04 19:37               ` J. Bruce Fields
2019-02-05  1:57                 ` Tom Talpey
2019-02-01 19:57 ` [PATCH RFC 05/10] SUNRPC: Use struct xdr_stream when constructing RPC Call header Chuck Lever
2019-02-01 19:57 ` [PATCH RFC 06/10] SUNRPC: Clean up rpc_verify_header() Chuck Lever
2019-02-01 19:58 ` [PATCH RFC 07/10] SUNRPC: Use struct xdr_stream when decoding RPC Reply header Chuck Lever
2019-02-01 19:58 ` [PATCH RFC 08/10] SUNRPC: Introduce trace points in rpc_auth_gss.ko Chuck Lever
2019-02-01 19:58 ` [PATCH RFC 09/10] SUNRPC: Remove xdr_buf_trim() Chuck Lever
2019-02-04 19:46   ` J. Bruce Fields
2019-02-04 19:49     ` Chuck Lever
2019-02-04 20:00       ` Bruce Fields
2019-02-04 20:07         ` Chuck Lever
2019-02-04 20:11           ` Bruce Fields
2019-02-01 19:58 ` [PATCH RFC 10/10] SUNRPC: Add SPDX IDs to some net/sunrpc/auth_gss/ files Chuck Lever

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=20190201195747.11389.75164.stgit@manet.1015granger.net \
    --to=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=simo@redhat.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