162306a36Sopenharmony_ci#ifndef LLC_C_EV_H
262306a36Sopenharmony_ci#define LLC_C_EV_H
362306a36Sopenharmony_ci/*
462306a36Sopenharmony_ci * Copyright (c) 1997 by Procom Technology,Inc.
562306a36Sopenharmony_ci *		 2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * This program can be redistributed or modified under the terms of the
862306a36Sopenharmony_ci * GNU General Public License as published by the Free Software Foundation.
962306a36Sopenharmony_ci * This program is distributed without any warranty or implied warranty
1062306a36Sopenharmony_ci * of merchantability or fitness for a particular purpose.
1162306a36Sopenharmony_ci *
1262306a36Sopenharmony_ci * See the GNU General Public License for more details.
1362306a36Sopenharmony_ci */
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#include <net/sock.h>
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci/* Connection component state transition event qualifiers */
1862306a36Sopenharmony_ci/* Types of events (possible values in 'ev->type') */
1962306a36Sopenharmony_ci#define LLC_CONN_EV_TYPE_SIMPLE		 1
2062306a36Sopenharmony_ci#define LLC_CONN_EV_TYPE_CONDITION	 2
2162306a36Sopenharmony_ci#define LLC_CONN_EV_TYPE_PRIM		 3
2262306a36Sopenharmony_ci#define LLC_CONN_EV_TYPE_PDU		 4	/* command/response PDU */
2362306a36Sopenharmony_ci#define LLC_CONN_EV_TYPE_ACK_TMR	 5
2462306a36Sopenharmony_ci#define LLC_CONN_EV_TYPE_P_TMR		 6
2562306a36Sopenharmony_ci#define LLC_CONN_EV_TYPE_REJ_TMR	 7
2662306a36Sopenharmony_ci#define LLC_CONN_EV_TYPE_BUSY_TMR	 8
2762306a36Sopenharmony_ci#define LLC_CONN_EV_TYPE_RPT_STATUS	 9
2862306a36Sopenharmony_ci#define LLC_CONN_EV_TYPE_SENDACK_TMR	10
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci#define NBR_CONN_EV		   5
3162306a36Sopenharmony_ci/* Connection events which cause state transitions when fully qualified */
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#define LLC_CONN_EV_CONN_REQ				 1
3462306a36Sopenharmony_ci#define LLC_CONN_EV_CONN_RESP				 2
3562306a36Sopenharmony_ci#define LLC_CONN_EV_DATA_REQ				 3
3662306a36Sopenharmony_ci#define LLC_CONN_EV_DISC_REQ				 4
3762306a36Sopenharmony_ci#define LLC_CONN_EV_RESET_REQ				 5
3862306a36Sopenharmony_ci#define LLC_CONN_EV_RESET_RESP				 6
3962306a36Sopenharmony_ci#define LLC_CONN_EV_LOCAL_BUSY_DETECTED			 7
4062306a36Sopenharmony_ci#define LLC_CONN_EV_LOCAL_BUSY_CLEARED			 8
4162306a36Sopenharmony_ci#define LLC_CONN_EV_RX_BAD_PDU				 9
4262306a36Sopenharmony_ci#define LLC_CONN_EV_RX_DISC_CMD_Pbit_SET_X		10
4362306a36Sopenharmony_ci#define LLC_CONN_EV_RX_DM_RSP_Fbit_SET_X		11
4462306a36Sopenharmony_ci#define LLC_CONN_EV_RX_FRMR_RSP_Fbit_SET_X		12
4562306a36Sopenharmony_ci#define LLC_CONN_EV_RX_I_CMD_Pbit_SET_X			13
4662306a36Sopenharmony_ci#define LLC_CONN_EV_RX_I_CMD_Pbit_SET_X_UNEXPD_Ns	14
4762306a36Sopenharmony_ci#define LLC_CONN_EV_RX_I_CMD_Pbit_SET_X_INVAL_Ns	15
4862306a36Sopenharmony_ci#define LLC_CONN_EV_RX_I_RSP_Fbit_SET_X			16
4962306a36Sopenharmony_ci#define LLC_CONN_EV_RX_I_RSP_Fbit_SET_X_UNEXPD_Ns	17
5062306a36Sopenharmony_ci#define LLC_CONN_EV_RX_I_RSP_Fbit_SET_X_INVAL_Ns	18
5162306a36Sopenharmony_ci#define LLC_CONN_EV_RX_REJ_CMD_Pbit_SET_X		19
5262306a36Sopenharmony_ci#define LLC_CONN_EV_RX_REJ_RSP_Fbit_SET_X		20
5362306a36Sopenharmony_ci#define LLC_CONN_EV_RX_RNR_CMD_Pbit_SET_X		21
5462306a36Sopenharmony_ci#define LLC_CONN_EV_RX_RNR_RSP_Fbit_SET_X		22
5562306a36Sopenharmony_ci#define LLC_CONN_EV_RX_RR_CMD_Pbit_SET_X		23
5662306a36Sopenharmony_ci#define LLC_CONN_EV_RX_RR_RSP_Fbit_SET_X		24
5762306a36Sopenharmony_ci#define LLC_CONN_EV_RX_SABME_CMD_Pbit_SET_X		25
5862306a36Sopenharmony_ci#define LLC_CONN_EV_RX_UA_RSP_Fbit_SET_X		26
5962306a36Sopenharmony_ci#define LLC_CONN_EV_RX_XXX_CMD_Pbit_SET_X		27
6062306a36Sopenharmony_ci#define LLC_CONN_EV_RX_XXX_RSP_Fbit_SET_X		28
6162306a36Sopenharmony_ci#define LLC_CONN_EV_RX_XXX_YYY				29
6262306a36Sopenharmony_ci#define LLC_CONN_EV_RX_ZZZ_CMD_Pbit_SET_X_INVAL_Nr	30
6362306a36Sopenharmony_ci#define LLC_CONN_EV_RX_ZZZ_RSP_Fbit_SET_X_INVAL_Nr	31
6462306a36Sopenharmony_ci#define LLC_CONN_EV_P_TMR_EXP				32
6562306a36Sopenharmony_ci#define LLC_CONN_EV_ACK_TMR_EXP				33
6662306a36Sopenharmony_ci#define LLC_CONN_EV_REJ_TMR_EXP				34
6762306a36Sopenharmony_ci#define LLC_CONN_EV_BUSY_TMR_EXP			35
6862306a36Sopenharmony_ci#define LLC_CONN_EV_RX_XXX_CMD_Pbit_SET_1		36
6962306a36Sopenharmony_ci#define LLC_CONN_EV_RX_XXX_CMD_Pbit_SET_0		37
7062306a36Sopenharmony_ci#define LLC_CONN_EV_RX_I_CMD_Pbit_SET_0_UNEXPD_Ns	38
7162306a36Sopenharmony_ci#define LLC_CONN_EV_RX_I_RSP_Fbit_SET_0_UNEXPD_Ns	39
7262306a36Sopenharmony_ci#define LLC_CONN_EV_RX_I_RSP_Fbit_SET_1_UNEXPD_Ns	40
7362306a36Sopenharmony_ci#define LLC_CONN_EV_RX_I_CMD_Pbit_SET_1_UNEXPD_Ns	41
7462306a36Sopenharmony_ci#define LLC_CONN_EV_RX_I_CMD_Pbit_SET_0			42
7562306a36Sopenharmony_ci#define LLC_CONN_EV_RX_I_RSP_Fbit_SET_0			43
7662306a36Sopenharmony_ci#define LLC_CONN_EV_RX_I_CMD_Pbit_SET_1			44
7762306a36Sopenharmony_ci#define LLC_CONN_EV_RX_RR_CMD_Pbit_SET_0		45
7862306a36Sopenharmony_ci#define LLC_CONN_EV_RX_RR_RSP_Fbit_SET_0		46
7962306a36Sopenharmony_ci#define LLC_CONN_EV_RX_RR_RSP_Fbit_SET_1		47
8062306a36Sopenharmony_ci#define LLC_CONN_EV_RX_RR_CMD_Pbit_SET_1		48
8162306a36Sopenharmony_ci#define LLC_CONN_EV_RX_RNR_CMD_Pbit_SET_0		49
8262306a36Sopenharmony_ci#define LLC_CONN_EV_RX_RNR_RSP_Fbit_SET_0		50
8362306a36Sopenharmony_ci#define LLC_CONN_EV_RX_RNR_RSP_Fbit_SET_1		51
8462306a36Sopenharmony_ci#define LLC_CONN_EV_RX_RNR_CMD_Pbit_SET_1		52
8562306a36Sopenharmony_ci#define LLC_CONN_EV_RX_REJ_CMD_Pbit_SET_0		53
8662306a36Sopenharmony_ci#define LLC_CONN_EV_RX_REJ_RSP_Fbit_SET_0		54
8762306a36Sopenharmony_ci#define LLC_CONN_EV_RX_REJ_CMD_Pbit_SET_1		55
8862306a36Sopenharmony_ci#define LLC_CONN_EV_RX_I_RSP_Fbit_SET_1			56
8962306a36Sopenharmony_ci#define LLC_CONN_EV_RX_REJ_RSP_Fbit_SET_1		57
9062306a36Sopenharmony_ci#define LLC_CONN_EV_RX_XXX_RSP_Fbit_SET_1		58
9162306a36Sopenharmony_ci#define LLC_CONN_EV_TX_BUFF_FULL			59
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci#define LLC_CONN_EV_INIT_P_F_CYCLE			100
9462306a36Sopenharmony_ci/*
9562306a36Sopenharmony_ci * Connection event qualifiers; for some events a certain combination of
9662306a36Sopenharmony_ci * these qualifiers must be TRUE before event recognized valid for state;
9762306a36Sopenharmony_ci * these constants act as indexes into the Event Qualifier function
9862306a36Sopenharmony_ci * table
9962306a36Sopenharmony_ci */
10062306a36Sopenharmony_ci#define LLC_CONN_EV_QFY_DATA_FLAG_EQ_1		 1
10162306a36Sopenharmony_ci#define LLC_CONN_EV_QFY_DATA_FLAG_EQ_0		 2
10262306a36Sopenharmony_ci#define LLC_CONN_EV_QFY_DATA_FLAG_EQ_2		 3
10362306a36Sopenharmony_ci#define LLC_CONN_EV_QFY_P_FLAG_EQ_1		 4
10462306a36Sopenharmony_ci#define LLC_CONN_EV_QFY_P_FLAG_EQ_0		 5
10562306a36Sopenharmony_ci#define LLC_CONN_EV_QFY_P_FLAG_EQ_Fbit		 6
10662306a36Sopenharmony_ci#define LLC_CONN_EV_QFY_REMOTE_BUSY_EQ_0	 7
10762306a36Sopenharmony_ci#define LLC_CONN_EV_QFY_RETRY_CNT_LT_N2		 8
10862306a36Sopenharmony_ci#define LLC_CONN_EV_QFY_RETRY_CNT_GTE_N2	 9
10962306a36Sopenharmony_ci#define LLC_CONN_EV_QFY_S_FLAG_EQ_1		10
11062306a36Sopenharmony_ci#define LLC_CONN_EV_QFY_S_FLAG_EQ_0		11
11162306a36Sopenharmony_ci#define LLC_CONN_EV_QFY_INIT_P_F_CYCLE		12
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_cistruct llc_conn_state_ev {
11462306a36Sopenharmony_ci	u8 type;
11562306a36Sopenharmony_ci	u8 prim;
11662306a36Sopenharmony_ci	u8 prim_type;
11762306a36Sopenharmony_ci	u8 reason;
11862306a36Sopenharmony_ci	u8 status;
11962306a36Sopenharmony_ci	u8 ind_prim;
12062306a36Sopenharmony_ci	u8 cfm_prim;
12162306a36Sopenharmony_ci};
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_cistatic __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
12462306a36Sopenharmony_ci{
12562306a36Sopenharmony_ci	return (struct llc_conn_state_ev *)skb->cb;
12662306a36Sopenharmony_ci}
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_citypedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
12962306a36Sopenharmony_citypedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_ciint llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
13262306a36Sopenharmony_ciint llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
13362306a36Sopenharmony_ciint llc_conn_ev_disc_req(struct sock *sk, struct sk_buff *skb);
13462306a36Sopenharmony_ciint llc_conn_ev_rst_req(struct sock *sk, struct sk_buff *skb);
13562306a36Sopenharmony_ciint llc_conn_ev_local_busy_detected(struct sock *sk, struct sk_buff *skb);
13662306a36Sopenharmony_ciint llc_conn_ev_local_busy_cleared(struct sock *sk, struct sk_buff *skb);
13762306a36Sopenharmony_ciint llc_conn_ev_rx_bad_pdu(struct sock *sk, struct sk_buff *skb);
13862306a36Sopenharmony_ciint llc_conn_ev_rx_disc_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb);
13962306a36Sopenharmony_ciint llc_conn_ev_rx_dm_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb);
14062306a36Sopenharmony_ciint llc_conn_ev_rx_frmr_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb);
14162306a36Sopenharmony_ciint llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns(struct sock *sk,
14262306a36Sopenharmony_ci					     struct sk_buff *skb);
14362306a36Sopenharmony_ciint llc_conn_ev_rx_i_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb);
14462306a36Sopenharmony_ciint llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns(struct sock *sk,
14562306a36Sopenharmony_ci					      struct sk_buff *skb);
14662306a36Sopenharmony_ciint llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns(struct sock *sk,
14762306a36Sopenharmony_ci					     struct sk_buff *skb);
14862306a36Sopenharmony_ciint llc_conn_ev_rx_rej_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb);
14962306a36Sopenharmony_ciint llc_conn_ev_rx_sabme_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb);
15062306a36Sopenharmony_ciint llc_conn_ev_rx_ua_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb);
15162306a36Sopenharmony_ciint llc_conn_ev_rx_xxx_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb);
15262306a36Sopenharmony_ciint llc_conn_ev_rx_xxx_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb);
15362306a36Sopenharmony_ciint llc_conn_ev_rx_zzz_cmd_pbit_set_x_inval_nr(struct sock *sk,
15462306a36Sopenharmony_ci					       struct sk_buff *skb);
15562306a36Sopenharmony_ciint llc_conn_ev_rx_zzz_rsp_fbit_set_x_inval_nr(struct sock *sk,
15662306a36Sopenharmony_ci					       struct sk_buff *skb);
15762306a36Sopenharmony_ciint llc_conn_ev_p_tmr_exp(struct sock *sk, struct sk_buff *skb);
15862306a36Sopenharmony_ciint llc_conn_ev_ack_tmr_exp(struct sock *sk, struct sk_buff *skb);
15962306a36Sopenharmony_ciint llc_conn_ev_rej_tmr_exp(struct sock *sk, struct sk_buff *skb);
16062306a36Sopenharmony_ciint llc_conn_ev_busy_tmr_exp(struct sock *sk, struct sk_buff *skb);
16162306a36Sopenharmony_ci/* NOT_USED functions and their variations */
16262306a36Sopenharmony_ciint llc_conn_ev_rx_xxx_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb);
16362306a36Sopenharmony_ciint llc_conn_ev_rx_xxx_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb);
16462306a36Sopenharmony_ciint llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns(struct sock *sk,
16562306a36Sopenharmony_ci					      struct sk_buff *skb);
16662306a36Sopenharmony_ciint llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns(struct sock *sk,
16762306a36Sopenharmony_ci					      struct sk_buff *skb);
16862306a36Sopenharmony_ciint llc_conn_ev_rx_i_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb);
16962306a36Sopenharmony_ciint llc_conn_ev_rx_i_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb);
17062306a36Sopenharmony_ciint llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns(struct sock *sk,
17162306a36Sopenharmony_ci					      struct sk_buff *skb);
17262306a36Sopenharmony_ciint llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns(struct sock *sk,
17362306a36Sopenharmony_ci					      struct sk_buff *skb);
17462306a36Sopenharmony_ciint llc_conn_ev_rx_i_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb);
17562306a36Sopenharmony_ciint llc_conn_ev_rx_i_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb);
17662306a36Sopenharmony_ciint llc_conn_ev_rx_rr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb);
17762306a36Sopenharmony_ciint llc_conn_ev_rx_rr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb);
17862306a36Sopenharmony_ciint llc_conn_ev_rx_rr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb);
17962306a36Sopenharmony_ciint llc_conn_ev_rx_rr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb);
18062306a36Sopenharmony_ciint llc_conn_ev_rx_rnr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb);
18162306a36Sopenharmony_ciint llc_conn_ev_rx_rnr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb);
18262306a36Sopenharmony_ciint llc_conn_ev_rx_rnr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb);
18362306a36Sopenharmony_ciint llc_conn_ev_rx_rnr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb);
18462306a36Sopenharmony_ciint llc_conn_ev_rx_rej_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb);
18562306a36Sopenharmony_ciint llc_conn_ev_rx_rej_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb);
18662306a36Sopenharmony_ciint llc_conn_ev_rx_rej_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb);
18762306a36Sopenharmony_ciint llc_conn_ev_rx_rej_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb);
18862306a36Sopenharmony_ciint llc_conn_ev_rx_any_frame(struct sock *sk, struct sk_buff *skb);
18962306a36Sopenharmony_ciint llc_conn_ev_tx_buffer_full(struct sock *sk, struct sk_buff *skb);
19062306a36Sopenharmony_ciint llc_conn_ev_init_p_f_cycle(struct sock *sk, struct sk_buff *skb);
19162306a36Sopenharmony_ci
19262306a36Sopenharmony_ci/* Available connection action qualifiers */
19362306a36Sopenharmony_ciint llc_conn_ev_qlfy_data_flag_eq_1(struct sock *sk, struct sk_buff *skb);
19462306a36Sopenharmony_ciint llc_conn_ev_qlfy_data_flag_eq_0(struct sock *sk, struct sk_buff *skb);
19562306a36Sopenharmony_ciint llc_conn_ev_qlfy_data_flag_eq_2(struct sock *sk, struct sk_buff *skb);
19662306a36Sopenharmony_ciint llc_conn_ev_qlfy_p_flag_eq_1(struct sock *sk, struct sk_buff *skb);
19762306a36Sopenharmony_ciint llc_conn_ev_qlfy_last_frame_eq_1(struct sock *sk, struct sk_buff *skb);
19862306a36Sopenharmony_ciint llc_conn_ev_qlfy_last_frame_eq_0(struct sock *sk, struct sk_buff *skb);
19962306a36Sopenharmony_ciint llc_conn_ev_qlfy_p_flag_eq_0(struct sock *sk, struct sk_buff *skb);
20062306a36Sopenharmony_ciint llc_conn_ev_qlfy_p_flag_eq_f(struct sock *sk, struct sk_buff *skb);
20162306a36Sopenharmony_ciint llc_conn_ev_qlfy_remote_busy_eq_0(struct sock *sk, struct sk_buff *skb);
20262306a36Sopenharmony_ciint llc_conn_ev_qlfy_remote_busy_eq_1(struct sock *sk, struct sk_buff *skb);
20362306a36Sopenharmony_ciint llc_conn_ev_qlfy_retry_cnt_lt_n2(struct sock *sk, struct sk_buff *skb);
20462306a36Sopenharmony_ciint llc_conn_ev_qlfy_retry_cnt_gte_n2(struct sock *sk, struct sk_buff *skb);
20562306a36Sopenharmony_ciint llc_conn_ev_qlfy_s_flag_eq_1(struct sock *sk, struct sk_buff *skb);
20662306a36Sopenharmony_ciint llc_conn_ev_qlfy_s_flag_eq_0(struct sock *sk, struct sk_buff *skb);
20762306a36Sopenharmony_ciint llc_conn_ev_qlfy_cause_flag_eq_1(struct sock *sk, struct sk_buff *skb);
20862306a36Sopenharmony_ciint llc_conn_ev_qlfy_cause_flag_eq_0(struct sock *sk, struct sk_buff *skb);
20962306a36Sopenharmony_ciint llc_conn_ev_qlfy_set_status_conn(struct sock *sk, struct sk_buff *skb);
21062306a36Sopenharmony_ciint llc_conn_ev_qlfy_set_status_disc(struct sock *sk, struct sk_buff *skb);
21162306a36Sopenharmony_ciint llc_conn_ev_qlfy_set_status_failed(struct sock *sk, struct sk_buff *skb);
21262306a36Sopenharmony_ciint llc_conn_ev_qlfy_set_status_remote_busy(struct sock *sk,
21362306a36Sopenharmony_ci					    struct sk_buff *skb);
21462306a36Sopenharmony_ciint llc_conn_ev_qlfy_set_status_refuse(struct sock *sk, struct sk_buff *skb);
21562306a36Sopenharmony_ciint llc_conn_ev_qlfy_set_status_conflict(struct sock *sk, struct sk_buff *skb);
21662306a36Sopenharmony_ciint llc_conn_ev_qlfy_set_status_rst_done(struct sock *sk, struct sk_buff *skb);
21762306a36Sopenharmony_ci
21862306a36Sopenharmony_cistatic __inline__ int llc_conn_space(struct sock *sk, struct sk_buff *skb)
21962306a36Sopenharmony_ci{
22062306a36Sopenharmony_ci	return atomic_read(&sk->sk_rmem_alloc) + skb->truesize <
22162306a36Sopenharmony_ci	       (unsigned int)sk->sk_rcvbuf;
22262306a36Sopenharmony_ci}
22362306a36Sopenharmony_ci#endif /* LLC_C_EV_H */
224