blob: 68ada0efeb9ba370e69740438cb27087e9ac8deb [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
wdenkbe9c1cb2004-02-24 02:00:03 +00002/*
3 * (C) Masami Komiya <mkomiya@sonare.it> 2004
wdenkbe9c1cb2004-02-24 02:00:03 +00004 */
5
6#ifndef __NFS_H__
7#define __NFS_H__
8
9#define SUNRPC_PORT 111
10
11#define PROG_PORTMAP 100000
12#define PROG_NFS 100003
13#define PROG_MOUNT 100005
14
15#define MSG_CALL 0
16#define MSG_REPLY 1
17
18#define PORTMAP_GETPORT 3
19
20#define MOUNT_ADDENTRY 1
21#define MOUNT_UMOUNTALL 4
22
23#define NFS_LOOKUP 4
24#define NFS_READLINK 5
25#define NFS_READ 6
26
Guillaume GARDET2a4bc832016-07-29 11:31:00 +020027#define NFS3PROC_LOOKUP 3
28
wdenkbe9c1cb2004-02-24 02:00:03 +000029#define NFS_FHSIZE 32
Guillaume GARDET2a4bc832016-07-29 11:31:00 +020030#define NFS3_FHSIZE 64
wdenkbe9c1cb2004-02-24 02:00:03 +000031
32#define NFSERR_PERM 1
33#define NFSERR_NOENT 2
34#define NFSERR_ACCES 13
35#define NFSERR_ISDIR 21
36#define NFSERR_INVAL 22
37
Tom Rinibc274882017-08-20 22:40:01 -040038/*
39 * Block size used for NFS read accesses. A RPC reply packet (including all
wdenkbe9c1cb2004-02-24 02:00:03 +000040 * headers) must fit within a single Ethernet frame to avoid fragmentation.
Tom Rinibc274882017-08-20 22:40:01 -040041 * However, if CONFIG_IP_DEFRAG is set, a bigger value could be used. In any
42 * case, most NFS servers are optimized for a power of 2.
Alessandro Rubini252f04d2009-08-07 13:59:16 +020043 */
Tom Rinibc274882017-08-20 22:40:01 -040044#define NFS_READ_SIZE 1024 /* biggest power of two that fits Ether frame */
Joe Hershbergerdc7e1662018-07-03 19:22:54 -050045#define NFS_MAX_ATTRS 26
wdenkbe9c1cb2004-02-24 02:00:03 +000046
Guillaume GARDET2a4bc832016-07-29 11:31:00 +020047/* Values for Accept State flag on RPC answers (See: rfc1831) */
48enum rpc_accept_stat {
49 NFS_RPC_SUCCESS = 0, /* RPC executed successfully */
50 NFS_RPC_PROG_UNAVAIL = 1, /* remote hasn't exported program */
51 NFS_RPC_PROG_MISMATCH = 2, /* remote can't support version # */
52 NFS_RPC_PROC_UNAVAIL = 3, /* program can't support procedure */
53 NFS_RPC_GARBAGE_ARGS = 4, /* procedure can't decode params */
54 NFS_RPC_SYSTEM_ERR = 5 /* errors like memory allocation failure */
55};
56
wdenkbe9c1cb2004-02-24 02:00:03 +000057struct rpc_t {
58 union {
Joe Hershbergerdc7e1662018-07-03 19:22:54 -050059 uint8_t data[NFS_READ_SIZE + (6 + NFS_MAX_ATTRS) *
60 sizeof(uint32_t)];
wdenkbe9c1cb2004-02-24 02:00:03 +000061 struct {
62 uint32_t id;
63 uint32_t type;
64 uint32_t rpcvers;
65 uint32_t prog;
66 uint32_t vers;
67 uint32_t proc;
68 uint32_t data[1];
69 } call;
70 struct {
71 uint32_t id;
72 uint32_t type;
73 uint32_t rstatus;
74 uint32_t verifier;
75 uint32_t v2;
76 uint32_t astatus;
Joe Hershbergerdc7e1662018-07-03 19:22:54 -050077 uint32_t data[NFS_READ_SIZE / sizeof(uint32_t) +
78 NFS_MAX_ATTRS];
wdenkbe9c1cb2004-02-24 02:00:03 +000079 } reply;
80 } u;
Heinrich Schuchardtad341d72019-09-03 00:05:05 +020081};
Joe Hershberger40d7ca92015-04-08 01:41:10 -050082void nfs_start(void); /* Begin NFS */
wdenkbe9c1cb2004-02-24 02:00:03 +000083
84
85/**********************************************************************/
86
87#endif /* __NFS_H__ */