nfsd: track last inode only in use_wgather case
[safe/jmp/linux-2.6] / include / net / llc_c_ev.h
1 #ifndef LLC_C_EV_H
2 #define LLC_C_EV_H
3 /*
4  * Copyright (c) 1997 by Procom Technology,Inc.
5  *               2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
6  *
7  * This program can be redistributed or modified under the terms of the
8  * GNU General Public License as published by the Free Software Foundation.
9  * This program is distributed without any warranty or implied warranty
10  * of merchantability or fitness for a particular purpose.
11  *
12  * See the GNU General Public License for more details.
13  */
14
15 #include <net/sock.h>
16
17 /* Connection component state transition event qualifiers */
18 /* Types of events (possible values in 'ev->type') */
19 #define LLC_CONN_EV_TYPE_SIMPLE          1
20 #define LLC_CONN_EV_TYPE_CONDITION       2
21 #define LLC_CONN_EV_TYPE_PRIM            3
22 #define LLC_CONN_EV_TYPE_PDU             4      /* command/response PDU */
23 #define LLC_CONN_EV_TYPE_ACK_TMR         5
24 #define LLC_CONN_EV_TYPE_P_TMR           6
25 #define LLC_CONN_EV_TYPE_REJ_TMR         7
26 #define LLC_CONN_EV_TYPE_BUSY_TMR        8
27 #define LLC_CONN_EV_TYPE_RPT_STATUS      9
28 #define LLC_CONN_EV_TYPE_SENDACK_TMR    10
29
30 #define NBR_CONN_EV                5
31 /* Connection events which cause state transitions when fully qualified */
32
33 #define LLC_CONN_EV_CONN_REQ                             1
34 #define LLC_CONN_EV_CONN_RESP                            2
35 #define LLC_CONN_EV_DATA_REQ                             3
36 #define LLC_CONN_EV_DISC_REQ                             4
37 #define LLC_CONN_EV_RESET_REQ                            5
38 #define LLC_CONN_EV_RESET_RESP                           6
39 #define LLC_CONN_EV_LOCAL_BUSY_DETECTED                  7
40 #define LLC_CONN_EV_LOCAL_BUSY_CLEARED                   8
41 #define LLC_CONN_EV_RX_BAD_PDU                           9
42 #define LLC_CONN_EV_RX_DISC_CMD_Pbit_SET_X              10
43 #define LLC_CONN_EV_RX_DM_RSP_Fbit_SET_X                11
44 #define LLC_CONN_EV_RX_FRMR_RSP_Fbit_SET_X              12
45 #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_X                 13
46 #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_X_UNEXPD_Ns       14
47 #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_X_INVAL_Ns        15
48 #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_X                 16
49 #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_X_UNEXPD_Ns       17
50 #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_X_INVAL_Ns        18
51 #define LLC_CONN_EV_RX_REJ_CMD_Pbit_SET_X               19
52 #define LLC_CONN_EV_RX_REJ_RSP_Fbit_SET_X               20
53 #define LLC_CONN_EV_RX_RNR_CMD_Pbit_SET_X               21
54 #define LLC_CONN_EV_RX_RNR_RSP_Fbit_SET_X               22
55 #define LLC_CONN_EV_RX_RR_CMD_Pbit_SET_X                23
56 #define LLC_CONN_EV_RX_RR_RSP_Fbit_SET_X                24
57 #define LLC_CONN_EV_RX_SABME_CMD_Pbit_SET_X             25
58 #define LLC_CONN_EV_RX_UA_RSP_Fbit_SET_X                26
59 #define LLC_CONN_EV_RX_XXX_CMD_Pbit_SET_X               27
60 #define LLC_CONN_EV_RX_XXX_RSP_Fbit_SET_X               28
61 #define LLC_CONN_EV_RX_XXX_YYY                          29
62 #define LLC_CONN_EV_RX_ZZZ_CMD_Pbit_SET_X_INVAL_Nr      30
63 #define LLC_CONN_EV_RX_ZZZ_RSP_Fbit_SET_X_INVAL_Nr      31
64 #define LLC_CONN_EV_P_TMR_EXP                           32
65 #define LLC_CONN_EV_ACK_TMR_EXP                         33
66 #define LLC_CONN_EV_REJ_TMR_EXP                         34
67 #define LLC_CONN_EV_BUSY_TMR_EXP                        35
68 #define LLC_CONN_EV_RX_XXX_CMD_Pbit_SET_1               36
69 #define LLC_CONN_EV_RX_XXX_CMD_Pbit_SET_0               37
70 #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_0_UNEXPD_Ns       38
71 #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_0_UNEXPD_Ns       39
72 #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_1_UNEXPD_Ns       40
73 #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_1_UNEXPD_Ns       41
74 #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_0                 42
75 #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_0                 43
76 #define LLC_CONN_EV_RX_I_CMD_Pbit_SET_1                 44
77 #define LLC_CONN_EV_RX_RR_CMD_Pbit_SET_0                45
78 #define LLC_CONN_EV_RX_RR_RSP_Fbit_SET_0                46
79 #define LLC_CONN_EV_RX_RR_RSP_Fbit_SET_1                47
80 #define LLC_CONN_EV_RX_RR_CMD_Pbit_SET_1                48
81 #define LLC_CONN_EV_RX_RNR_CMD_Pbit_SET_0               49
82 #define LLC_CONN_EV_RX_RNR_RSP_Fbit_SET_0               50
83 #define LLC_CONN_EV_RX_RNR_RSP_Fbit_SET_1               51
84 #define LLC_CONN_EV_RX_RNR_CMD_Pbit_SET_1               52
85 #define LLC_CONN_EV_RX_REJ_CMD_Pbit_SET_0               53
86 #define LLC_CONN_EV_RX_REJ_RSP_Fbit_SET_0               54
87 #define LLC_CONN_EV_RX_REJ_CMD_Pbit_SET_1               55
88 #define LLC_CONN_EV_RX_I_RSP_Fbit_SET_1                 56
89 #define LLC_CONN_EV_RX_REJ_RSP_Fbit_SET_1               57
90 #define LLC_CONN_EV_RX_XXX_RSP_Fbit_SET_1               58
91 #define LLC_CONN_EV_TX_BUFF_FULL                        59
92
93 #define LLC_CONN_EV_INIT_P_F_CYCLE                      100
94 /*
95  * Connection event qualifiers; for some events a certain combination of
96  * these qualifiers must be TRUE before event recognized valid for state;
97  * these constants act as indexes into the Event Qualifier function
98  * table
99  */
100 #define LLC_CONN_EV_QFY_DATA_FLAG_EQ_1           1
101 #define LLC_CONN_EV_QFY_DATA_FLAG_EQ_0           2
102 #define LLC_CONN_EV_QFY_DATA_FLAG_EQ_2           3
103 #define LLC_CONN_EV_QFY_P_FLAG_EQ_1              4
104 #define LLC_CONN_EV_QFY_P_FLAG_EQ_0              5
105 #define LLC_CONN_EV_QFY_P_FLAG_EQ_Fbit           6
106 #define LLC_CONN_EV_QFY_REMOTE_BUSY_EQ_0         7
107 #define LLC_CONN_EV_QFY_RETRY_CNT_LT_N2          8
108 #define LLC_CONN_EV_QFY_RETRY_CNT_GTE_N2         9
109 #define LLC_CONN_EV_QFY_S_FLAG_EQ_1             10
110 #define LLC_CONN_EV_QFY_S_FLAG_EQ_0             11
111 #define LLC_CONN_EV_QFY_INIT_P_F_CYCLE          12
112
113 struct llc_conn_state_ev {
114         u8 type;
115         u8 prim;
116         u8 prim_type;
117         u8 reason;
118         u8 status;
119         u8 ind_prim;
120         u8 cfm_prim;
121 };
122
123 static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
124 {
125         return (struct llc_conn_state_ev *)skb->cb;
126 }
127
128 typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
129 typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
130
131 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
132 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
133 extern int llc_conn_ev_disc_req(struct sock *sk, struct sk_buff *skb);
134 extern int llc_conn_ev_rst_req(struct sock *sk, struct sk_buff *skb);
135 extern int llc_conn_ev_local_busy_detected(struct sock *sk,
136                                            struct sk_buff *skb);
137 extern int llc_conn_ev_local_busy_cleared(struct sock *sk, struct sk_buff *skb);
138 extern int llc_conn_ev_rx_bad_pdu(struct sock *sk, struct sk_buff *skb);
139 extern int llc_conn_ev_rx_disc_cmd_pbit_set_x(struct sock *sk,
140                                               struct sk_buff *skb);
141 extern int llc_conn_ev_rx_dm_rsp_fbit_set_x(struct sock *sk,
142                                             struct sk_buff *skb);
143 extern int llc_conn_ev_rx_frmr_rsp_fbit_set_x(struct sock *sk,
144                                               struct sk_buff *skb);
145 extern int llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns(struct sock *sk,
146                                                     struct sk_buff *skb);
147 extern int llc_conn_ev_rx_i_rsp_fbit_set_x(struct sock *sk,
148                                            struct sk_buff *skb);
149 extern int llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns(struct sock *sk,
150                                                   struct sk_buff *skb);
151 extern int llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns(struct sock *sk,
152                                                   struct sk_buff *skb);
153 extern int llc_conn_ev_rx_rej_rsp_fbit_set_x(struct sock *sk,
154                                              struct sk_buff *skb);
155 extern int llc_conn_ev_rx_sabme_cmd_pbit_set_x(struct sock *sk,
156                                                struct sk_buff *skb);
157 extern int llc_conn_ev_rx_ua_rsp_fbit_set_x(struct sock *sk,
158                                             struct sk_buff *skb);
159 extern int llc_conn_ev_rx_xxx_cmd_pbit_set_x(struct sock *sk,
160                                              struct sk_buff *skb);
161 extern int llc_conn_ev_rx_xxx_rsp_fbit_set_x(struct sock *sk,
162                                              struct sk_buff *skb);
163 extern int llc_conn_ev_rx_zzz_cmd_pbit_set_x_inval_nr(struct sock *sk,
164                                                       struct sk_buff *skb);
165 extern int llc_conn_ev_rx_zzz_rsp_fbit_set_x_inval_nr(struct sock *sk,
166                                                       struct sk_buff *skb);
167 extern int llc_conn_ev_p_tmr_exp(struct sock *sk, struct sk_buff *skb);
168 extern int llc_conn_ev_ack_tmr_exp(struct sock *sk, struct sk_buff *skb);
169 extern int llc_conn_ev_rej_tmr_exp(struct sock *sk, struct sk_buff *skb);
170 extern int llc_conn_ev_busy_tmr_exp(struct sock *sk, struct sk_buff *skb);
171 extern int llc_conn_ev_sendack_tmr_exp(struct sock *sk, struct sk_buff *skb);
172 /* NOT_USED functions and their variations */
173 extern int llc_conn_ev_rx_xxx_cmd_pbit_set_1(struct sock *sk,
174                                              struct sk_buff *skb);
175 extern int llc_conn_ev_rx_xxx_rsp_fbit_set_1(struct sock *sk,
176                                              struct sk_buff *skb);
177 extern int llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns(struct sock *sk,
178                                                   struct sk_buff *skb);
179 extern int llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns(struct sock *sk,
180                                                   struct sk_buff *skb);
181 extern int llc_conn_ev_rx_i_cmd_pbit_set_0(struct sock *sk,
182                                            struct sk_buff *skb);
183 extern int llc_conn_ev_rx_i_cmd_pbit_set_1(struct sock *sk,
184                                            struct sk_buff *skb);
185 extern int llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns(struct sock *sk,
186                                                   struct sk_buff *skb);
187 extern int llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns(struct sock *sk,
188                                                   struct sk_buff *skb);
189 extern int llc_conn_ev_rx_i_rsp_fbit_set_0(struct sock *sk,
190                                            struct sk_buff *skb);
191 extern int llc_conn_ev_rx_i_rsp_fbit_set_1(struct sock *sk,
192                                            struct sk_buff *skb);
193 extern int llc_conn_ev_rx_rr_cmd_pbit_set_0(struct sock *sk,
194                                             struct sk_buff *skb);
195 extern int llc_conn_ev_rx_rr_cmd_pbit_set_1(struct sock *sk,
196                                             struct sk_buff *skb);
197 extern int llc_conn_ev_rx_rr_rsp_fbit_set_0(struct sock *sk,
198                                             struct sk_buff *skb);
199 extern int llc_conn_ev_rx_rr_rsp_fbit_set_1(struct sock *sk,
200                                             struct sk_buff *skb);
201 extern int llc_conn_ev_rx_rnr_cmd_pbit_set_0(struct sock *sk,
202                                              struct sk_buff *skb);
203 extern int llc_conn_ev_rx_rnr_cmd_pbit_set_1(struct sock *sk,
204                                              struct sk_buff *skb);
205 extern int llc_conn_ev_rx_rnr_rsp_fbit_set_0(struct sock *sk,
206                                              struct sk_buff *skb);
207 extern int llc_conn_ev_rx_rnr_rsp_fbit_set_1(struct sock *sk,
208                                              struct sk_buff *skb);
209 extern int llc_conn_ev_rx_rej_cmd_pbit_set_0(struct sock *sk,
210                                              struct sk_buff *skb);
211 extern int llc_conn_ev_rx_rej_cmd_pbit_set_1(struct sock *sk,
212                                              struct sk_buff *skb);
213 extern int llc_conn_ev_rx_rej_rsp_fbit_set_0(struct sock *sk,
214                                              struct sk_buff *skb);
215 extern int llc_conn_ev_rx_rej_rsp_fbit_set_1(struct sock *sk,
216                                              struct sk_buff *skb);
217 extern int llc_conn_ev_rx_any_frame(struct sock *sk, struct sk_buff *skb);
218 extern int llc_conn_ev_tx_buffer_full(struct sock *sk, struct sk_buff *skb);
219 extern int llc_conn_ev_init_p_f_cycle(struct sock *sk, struct sk_buff *skb);
220
221 /* Available connection action qualifiers */
222 extern int llc_conn_ev_qlfy_data_flag_eq_1(struct sock *sk,
223                                            struct sk_buff *skb);
224 extern int llc_conn_ev_qlfy_data_flag_eq_0(struct sock *sk,
225                                            struct sk_buff *skb);
226 extern int llc_conn_ev_qlfy_data_flag_eq_2(struct sock *sk,
227                                            struct sk_buff *skb);
228 extern int llc_conn_ev_qlfy_p_flag_eq_1(struct sock *sk, struct sk_buff *skb);
229 extern int llc_conn_ev_qlfy_last_frame_eq_1(struct sock *sk,
230                                             struct sk_buff *skb);
231 extern int llc_conn_ev_qlfy_last_frame_eq_0(struct sock *sk,
232                                             struct sk_buff *skb);
233 extern int llc_conn_ev_qlfy_p_flag_eq_0(struct sock *sk, struct sk_buff *skb);
234 extern int llc_conn_ev_qlfy_p_flag_eq_f(struct sock *sk, struct sk_buff *skb);
235 extern int llc_conn_ev_qlfy_remote_busy_eq_0(struct sock *sk,
236                                              struct sk_buff *skb);
237 extern int llc_conn_ev_qlfy_remote_busy_eq_1(struct sock *sk,
238                                              struct sk_buff *skb);
239 extern int llc_conn_ev_qlfy_retry_cnt_lt_n2(struct sock *sk,
240                                             struct sk_buff *skb);
241 extern int llc_conn_ev_qlfy_retry_cnt_gte_n2(struct sock *sk,
242                                              struct sk_buff *skb);
243 extern int llc_conn_ev_qlfy_s_flag_eq_1(struct sock *sk, struct sk_buff *skb);
244 extern int llc_conn_ev_qlfy_s_flag_eq_0(struct sock *sk, struct sk_buff *skb);
245 extern int llc_conn_ev_qlfy_cause_flag_eq_1(struct sock *sk,
246                                             struct sk_buff *skb);
247 extern int llc_conn_ev_qlfy_cause_flag_eq_0(struct sock *sk,
248                                             struct sk_buff *skb);
249 extern int llc_conn_ev_qlfy_set_status_conn(struct sock *sk,
250                                             struct sk_buff *skb);
251 extern int llc_conn_ev_qlfy_set_status_disc(struct sock *sk,
252                                             struct sk_buff *skb);
253 extern int llc_conn_ev_qlfy_set_status_failed(struct sock *sk,
254                                               struct sk_buff *skb);
255 extern int llc_conn_ev_qlfy_set_status_remote_busy(struct sock *sk,
256                                                   struct sk_buff *skb);
257 extern int llc_conn_ev_qlfy_set_status_refuse(struct sock *sk,
258                                               struct sk_buff *skb);
259 extern int llc_conn_ev_qlfy_set_status_conflict(struct sock *sk,
260                                                 struct sk_buff *skb);
261 extern int llc_conn_ev_qlfy_set_status_rst_done(struct sock *sk,
262                                                 struct sk_buff *skb);
263
264 static __inline__ int llc_conn_space(struct sock *sk, struct sk_buff *skb)
265 {
266         return atomic_read(&sk->sk_rmem_alloc) + skb->truesize <
267                (unsigned)sk->sk_rcvbuf;
268 }
269 #endif /* LLC_C_EV_H */