Commit 2d8a9726 authored by Al Viro's avatar Al Viro Committed by Linus Torvalds

SUNRPC endianness annotations

rpcrdma stuff lacks endianness annotations for on-the-wire data.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7a78a172
...@@ -41,17 +41,17 @@ ...@@ -41,17 +41,17 @@
#define _LINUX_SUNRPC_RPC_RDMA_H #define _LINUX_SUNRPC_RPC_RDMA_H
struct rpcrdma_segment { struct rpcrdma_segment {
uint32_t rs_handle; /* Registered memory handle */ __be32 rs_handle; /* Registered memory handle */
uint32_t rs_length; /* Length of the chunk in bytes */ __be32 rs_length; /* Length of the chunk in bytes */
uint64_t rs_offset; /* Chunk virtual address or offset */ __be64 rs_offset; /* Chunk virtual address or offset */
}; };
/* /*
* read chunk(s), encoded as a linked list. * read chunk(s), encoded as a linked list.
*/ */
struct rpcrdma_read_chunk { struct rpcrdma_read_chunk {
uint32_t rc_discrim; /* 1 indicates presence */ __be32 rc_discrim; /* 1 indicates presence */
uint32_t rc_position; /* Position in XDR stream */ __be32 rc_position; /* Position in XDR stream */
struct rpcrdma_segment rc_target; struct rpcrdma_segment rc_target;
}; };
...@@ -66,29 +66,29 @@ struct rpcrdma_write_chunk { ...@@ -66,29 +66,29 @@ struct rpcrdma_write_chunk {
* write chunk(s), encoded as a counted array. * write chunk(s), encoded as a counted array.
*/ */
struct rpcrdma_write_array { struct rpcrdma_write_array {
uint32_t wc_discrim; /* 1 indicates presence */ __be32 wc_discrim; /* 1 indicates presence */
uint32_t wc_nchunks; /* Array count */ __be32 wc_nchunks; /* Array count */
struct rpcrdma_write_chunk wc_array[0]; struct rpcrdma_write_chunk wc_array[0];
}; };
struct rpcrdma_msg { struct rpcrdma_msg {
uint32_t rm_xid; /* Mirrors the RPC header xid */ __be32 rm_xid; /* Mirrors the RPC header xid */
uint32_t rm_vers; /* Version of this protocol */ __be32 rm_vers; /* Version of this protocol */
uint32_t rm_credit; /* Buffers requested/granted */ __be32 rm_credit; /* Buffers requested/granted */
uint32_t rm_type; /* Type of message (enum rpcrdma_proc) */ __be32 rm_type; /* Type of message (enum rpcrdma_proc) */
union { union {
struct { /* no chunks */ struct { /* no chunks */
uint32_t rm_empty[3]; /* 3 empty chunk lists */ __be32 rm_empty[3]; /* 3 empty chunk lists */
} rm_nochunks; } rm_nochunks;
struct { /* no chunks and padded */ struct { /* no chunks and padded */
uint32_t rm_align; /* Padding alignment */ __be32 rm_align; /* Padding alignment */
uint32_t rm_thresh; /* Padding threshold */ __be32 rm_thresh; /* Padding threshold */
uint32_t rm_pempty[3]; /* 3 empty chunk lists */ __be32 rm_pempty[3]; /* 3 empty chunk lists */
} rm_padded; } rm_padded;
uint32_t rm_chunks[0]; /* read, write and reply chunks */ __be32 rm_chunks[0]; /* read, write and reply chunks */
} rm_body; } rm_body;
}; };
......
...@@ -181,7 +181,7 @@ rpcrdma_create_chunks(struct rpc_rqst *rqst, struct xdr_buf *target, ...@@ -181,7 +181,7 @@ rpcrdma_create_chunks(struct rpc_rqst *rqst, struct xdr_buf *target,
struct rpcrdma_read_chunk *cur_rchunk = NULL; struct rpcrdma_read_chunk *cur_rchunk = NULL;
struct rpcrdma_write_array *warray = NULL; struct rpcrdma_write_array *warray = NULL;
struct rpcrdma_write_chunk *cur_wchunk = NULL; struct rpcrdma_write_chunk *cur_wchunk = NULL;
u32 *iptr = headerp->rm_body.rm_chunks; __be32 *iptr = headerp->rm_body.rm_chunks;
if (type == rpcrdma_readch || type == rpcrdma_areadch) { if (type == rpcrdma_readch || type == rpcrdma_areadch) {
/* a read chunk - server will RDMA Read our memory */ /* a read chunk - server will RDMA Read our memory */
...@@ -217,7 +217,7 @@ rpcrdma_create_chunks(struct rpc_rqst *rqst, struct xdr_buf *target, ...@@ -217,7 +217,7 @@ rpcrdma_create_chunks(struct rpc_rqst *rqst, struct xdr_buf *target,
cur_rchunk->rc_target.rs_handle = htonl(seg->mr_rkey); cur_rchunk->rc_target.rs_handle = htonl(seg->mr_rkey);
cur_rchunk->rc_target.rs_length = htonl(seg->mr_len); cur_rchunk->rc_target.rs_length = htonl(seg->mr_len);
xdr_encode_hyper( xdr_encode_hyper(
(u32 *)&cur_rchunk->rc_target.rs_offset, (__be32 *)&cur_rchunk->rc_target.rs_offset,
seg->mr_base); seg->mr_base);
dprintk("RPC: %s: read chunk " dprintk("RPC: %s: read chunk "
"elem %d@0x%llx:0x%x pos %d (%s)\n", __func__, "elem %d@0x%llx:0x%x pos %d (%s)\n", __func__,
...@@ -229,7 +229,7 @@ rpcrdma_create_chunks(struct rpc_rqst *rqst, struct xdr_buf *target, ...@@ -229,7 +229,7 @@ rpcrdma_create_chunks(struct rpc_rqst *rqst, struct xdr_buf *target,
cur_wchunk->wc_target.rs_handle = htonl(seg->mr_rkey); cur_wchunk->wc_target.rs_handle = htonl(seg->mr_rkey);
cur_wchunk->wc_target.rs_length = htonl(seg->mr_len); cur_wchunk->wc_target.rs_length = htonl(seg->mr_len);
xdr_encode_hyper( xdr_encode_hyper(
(u32 *)&cur_wchunk->wc_target.rs_offset, (__be32 *)&cur_wchunk->wc_target.rs_offset,
seg->mr_base); seg->mr_base);
dprintk("RPC: %s: %s chunk " dprintk("RPC: %s: %s chunk "
"elem %d@0x%llx:0x%x (%s)\n", __func__, "elem %d@0x%llx:0x%x (%s)\n", __func__,
...@@ -257,14 +257,14 @@ rpcrdma_create_chunks(struct rpc_rqst *rqst, struct xdr_buf *target, ...@@ -257,14 +257,14 @@ rpcrdma_create_chunks(struct rpc_rqst *rqst, struct xdr_buf *target,
* finish off header. If write, marshal discrim and nchunks. * finish off header. If write, marshal discrim and nchunks.
*/ */
if (cur_rchunk) { if (cur_rchunk) {
iptr = (u32 *) cur_rchunk; iptr = (__be32 *) cur_rchunk;
*iptr++ = xdr_zero; /* finish the read chunk list */ *iptr++ = xdr_zero; /* finish the read chunk list */
*iptr++ = xdr_zero; /* encode a NULL write chunk list */ *iptr++ = xdr_zero; /* encode a NULL write chunk list */
*iptr++ = xdr_zero; /* encode a NULL reply chunk */ *iptr++ = xdr_zero; /* encode a NULL reply chunk */
} else { } else {
warray->wc_discrim = xdr_one; warray->wc_discrim = xdr_one;
warray->wc_nchunks = htonl(nchunks); warray->wc_nchunks = htonl(nchunks);
iptr = (u32 *) cur_wchunk; iptr = (__be32 *) cur_wchunk;
if (type == rpcrdma_writech) { if (type == rpcrdma_writech) {
*iptr++ = xdr_zero; /* finish the write chunk list */ *iptr++ = xdr_zero; /* finish the write chunk list */
*iptr++ = xdr_zero; /* encode a NULL reply chunk */ *iptr++ = xdr_zero; /* encode a NULL reply chunk */
...@@ -559,7 +559,7 @@ rpcrdma_marshal_req(struct rpc_rqst *rqst) ...@@ -559,7 +559,7 @@ rpcrdma_marshal_req(struct rpc_rqst *rqst)
* RDMA'd by server. See map at rpcrdma_create_chunks()! :-) * RDMA'd by server. See map at rpcrdma_create_chunks()! :-)
*/ */
static int static int
rpcrdma_count_chunks(struct rpcrdma_rep *rep, int max, int wrchunk, u32 **iptrp) rpcrdma_count_chunks(struct rpcrdma_rep *rep, int max, int wrchunk, __be32 **iptrp)
{ {
unsigned int i, total_len; unsigned int i, total_len;
struct rpcrdma_write_chunk *cur_wchunk; struct rpcrdma_write_chunk *cur_wchunk;
...@@ -573,7 +573,7 @@ rpcrdma_count_chunks(struct rpcrdma_rep *rep, int max, int wrchunk, u32 **iptrp) ...@@ -573,7 +573,7 @@ rpcrdma_count_chunks(struct rpcrdma_rep *rep, int max, int wrchunk, u32 **iptrp)
struct rpcrdma_segment *seg = &cur_wchunk->wc_target; struct rpcrdma_segment *seg = &cur_wchunk->wc_target;
ifdebug(FACILITY) { ifdebug(FACILITY) {
u64 off; u64 off;
xdr_decode_hyper((u32 *)&seg->rs_offset, &off); xdr_decode_hyper((__be32 *)&seg->rs_offset, &off);
dprintk("RPC: %s: chunk %d@0x%llx:0x%x\n", dprintk("RPC: %s: chunk %d@0x%llx:0x%x\n",
__func__, __func__,
ntohl(seg->rs_length), ntohl(seg->rs_length),
...@@ -585,7 +585,7 @@ rpcrdma_count_chunks(struct rpcrdma_rep *rep, int max, int wrchunk, u32 **iptrp) ...@@ -585,7 +585,7 @@ rpcrdma_count_chunks(struct rpcrdma_rep *rep, int max, int wrchunk, u32 **iptrp)
} }
/* check and adjust for properly terminated write chunk */ /* check and adjust for properly terminated write chunk */
if (wrchunk) { if (wrchunk) {
u32 *w = (u32 *) cur_wchunk; __be32 *w = (__be32 *) cur_wchunk;
if (*w++ != xdr_zero) if (*w++ != xdr_zero)
return -1; return -1;
cur_wchunk = (struct rpcrdma_write_chunk *) w; cur_wchunk = (struct rpcrdma_write_chunk *) w;
...@@ -593,7 +593,7 @@ rpcrdma_count_chunks(struct rpcrdma_rep *rep, int max, int wrchunk, u32 **iptrp) ...@@ -593,7 +593,7 @@ rpcrdma_count_chunks(struct rpcrdma_rep *rep, int max, int wrchunk, u32 **iptrp)
if ((char *) cur_wchunk > rep->rr_base + rep->rr_len) if ((char *) cur_wchunk > rep->rr_base + rep->rr_len)
return -1; return -1;
*iptrp = (u32 *) cur_wchunk; *iptrp = (__be32 *) cur_wchunk;
return total_len; return total_len;
} }
...@@ -721,7 +721,7 @@ rpcrdma_reply_handler(struct rpcrdma_rep *rep) ...@@ -721,7 +721,7 @@ rpcrdma_reply_handler(struct rpcrdma_rep *rep)
struct rpc_rqst *rqst; struct rpc_rqst *rqst;
struct rpc_xprt *xprt = rep->rr_xprt; struct rpc_xprt *xprt = rep->rr_xprt;
struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt); struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
u32 *iptr; __be32 *iptr;
int i, rdmalen, status; int i, rdmalen, status;
/* Check status. If bad, signal disconnect and return rep to pool */ /* Check status. If bad, signal disconnect and return rep to pool */
...@@ -801,7 +801,7 @@ rpcrdma_reply_handler(struct rpcrdma_rep *rep) ...@@ -801,7 +801,7 @@ rpcrdma_reply_handler(struct rpcrdma_rep *rep)
r_xprt->rx_stats.total_rdma_reply += rdmalen; r_xprt->rx_stats.total_rdma_reply += rdmalen;
} else { } else {
/* else ordinary inline */ /* else ordinary inline */
iptr = (u32 *)((unsigned char *)headerp + 28); iptr = (__be32 *)((unsigned char *)headerp + 28);
rep->rr_len -= 28; /*sizeof *headerp;*/ rep->rr_len -= 28; /*sizeof *headerp;*/
status = rep->rr_len; status = rep->rr_len;
} }
...@@ -816,7 +816,7 @@ rpcrdma_reply_handler(struct rpcrdma_rep *rep) ...@@ -816,7 +816,7 @@ rpcrdma_reply_handler(struct rpcrdma_rep *rep)
headerp->rm_body.rm_chunks[2] != xdr_one || headerp->rm_body.rm_chunks[2] != xdr_one ||
req->rl_nchunks == 0) req->rl_nchunks == 0)
goto badheader; goto badheader;
iptr = (u32 *)((unsigned char *)headerp + 28); iptr = (__be32 *)((unsigned char *)headerp + 28);
rdmalen = rpcrdma_count_chunks(rep, req->rl_nchunks, 0, &iptr); rdmalen = rpcrdma_count_chunks(rep, req->rl_nchunks, 0, &iptr);
if (rdmalen < 0) if (rdmalen < 0)
goto badheader; goto badheader;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment