aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/9p/client.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/9p/client.h')
-rw-r--r--include/net/9p/client.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/include/net/9p/client.h b/include/net/9p/client.h
index c35fb548e7cf..140cf1d58452 100644
--- a/include/net/9p/client.h
+++ b/include/net/9p/client.h
@@ -26,6 +26,9 @@
26#ifndef NET_9P_CLIENT_H 26#ifndef NET_9P_CLIENT_H
27#define NET_9P_CLIENT_H 27#define NET_9P_CLIENT_H
28 28
29/* Number of requests per row */
30#define P9_ROW_MAXTAG 255
31
29/** 32/**
30 * enum p9_trans_status - different states of underlying transports 33 * enum p9_trans_status - different states of underlying transports
31 * @Connected: transport is connected and healthy 34 * @Connected: transport is connected and healthy
@@ -43,6 +46,62 @@ enum p9_trans_status {
43}; 46};
44 47
45/** 48/**
49 * enum p9_req_status_t - virtio request status
50 * @REQ_STATUS_IDLE: request slot unused
51 * @REQ_STATUS_ALLOC: request has been allocated but not sent
52 * @REQ_STATUS_SENT: request sent to server
53 * @REQ_STATUS_FLSH: a flush has been sent for this request
54 * @REQ_STATUS_RCVD: response received from server
55 * @REQ_STATUS_FLSHD: request has been flushed
56 * @REQ_STATUS_ERR: request encountered an error on the client side
57 *
58 * The @REQ_STATUS_IDLE state is used to mark a request slot as unused
59 * but use is actually tracked by the idpool structure which handles tag
60 * id allocation.
61 *
62 */
63
64enum p9_req_status_t {
65 REQ_STATUS_IDLE,
66 REQ_STATUS_ALLOC,
67 REQ_STATUS_SENT,
68 REQ_STATUS_FLSH,
69 REQ_STATUS_RCVD,
70 REQ_STATUS_FLSHD,
71 REQ_STATUS_ERROR,
72};
73
74/**
75 * struct p9_req_t - request slots
76 * @status: status of this request slot
77 * @t_err: transport error
78 * @wq: wait_queue for the client to block on for this request
79 * @tc: the request fcall structure
80 * @rc: the response fcall structure
81 * @aux: transport specific data (provided for trans_fd migration)
82 *
83 * Transport use an array to track outstanding requests
84 * instead of a list. While this may incurr overhead during initial
85 * allocation or expansion, it makes request lookup much easier as the
86 * tag id is a index into an array. (We use tag+1 so that we can accomodate
87 * the -1 tag for the T_VERSION request).
88 * This also has the nice effect of only having to allocate wait_queues
89 * once, instead of constantly allocating and freeing them. Its possible
90 * other resources could benefit from this scheme as well.
91 *
92 */
93
94struct p9_req_t {
95 int status;
96 int t_err;
97 wait_queue_head_t *wq;
98 struct p9_fcall *tc;
99 struct p9_fcall *rc;
100 u16 flush_tag;
101 void *aux;
102};
103
104/**
46 * struct p9_client - per client instance state 105 * struct p9_client - per client instance state
47 * @lock: protect @fidlist 106 * @lock: protect @fidlist
48 * @msize: maximum data size negotiated by protocol 107 * @msize: maximum data size negotiated by protocol
@@ -52,9 +111,20 @@ enum p9_trans_status {
52 * @conn: connection state information used by trans_fd 111 * @conn: connection state information used by trans_fd
53 * @fidpool: fid handle accounting for session 112 * @fidpool: fid handle accounting for session
54 * @fidlist: List of active fid handles 113 * @fidlist: List of active fid handles
114 * @tagpool - transaction id accounting for session
115 * @reqs - 2D array of requests
116 * @max_tag - current maximum tag id allocated
55 * 117 *
56 * The client structure is used to keep track of various per-client 118 * The client structure is used to keep track of various per-client
57 * state that has been instantiated. 119 * state that has been instantiated.
120 * In order to minimize per-transaction overhead we use a
121 * simple array to lookup requests instead of a hash table
122 * or linked list. In order to support larger number of
123 * transactions, we make this a 2D array, allocating new rows
124 * when we need to grow the total number of the transactions.
125 *
126 * Each row is 256 requests and we'll support up to 256 rows for
127 * a total of 64k concurrent requests per session.
58 * 128 *
59 * Bugs: duplicated data and potentially unnecessary elements. 129 * Bugs: duplicated data and potentially unnecessary elements.
60 */ 130 */
@@ -70,6 +140,10 @@ struct p9_client {
70 140
71 struct p9_idpool *fidpool; 141 struct p9_idpool *fidpool;
72 struct list_head fidlist; 142 struct list_head fidlist;
143
144 struct p9_idpool *tagpool;
145 struct p9_req_t *reqs[P9_ROW_MAXTAG];
146 int max_tag;
73}; 147};
74 148
75/** 149/**
@@ -131,4 +205,7 @@ struct p9_stat *p9_client_stat(struct p9_fid *fid);
131int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst); 205int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst);
132struct p9_stat *p9_client_dirread(struct p9_fid *fid, u64 offset); 206struct p9_stat *p9_client_dirread(struct p9_fid *fid, u64 offset);
133 207
208struct p9_req_t *p9_tag_alloc(struct p9_client *, u16);
209struct p9_req_t *p9_tag_lookup(struct p9_client *, u16);
210
134#endif /* NET_9P_CLIENT_H */ 211#endif /* NET_9P_CLIENT_H */