xref: /openbmc/linux/include/net/iucv/af_iucv.h (revision 3881ac441f642d56503818123446f7298442236b)
1eac3731bSJennifer Hunt /*
2eac3731bSJennifer Hunt  * Copyright 2006 IBM Corporation
3eac3731bSJennifer Hunt  * IUCV protocol stack for Linux on zSeries
4eac3731bSJennifer Hunt  * Version 1.0
5eac3731bSJennifer Hunt  * Author(s): Jennifer Hunt <jenhunt@us.ibm.com>
6eac3731bSJennifer Hunt  *
7eac3731bSJennifer Hunt  */
8eac3731bSJennifer Hunt 
9eac3731bSJennifer Hunt #ifndef __AFIUCV_H
10eac3731bSJennifer Hunt #define __AFIUCV_H
11eac3731bSJennifer Hunt 
12eac3731bSJennifer Hunt #include <asm/types.h>
13eac3731bSJennifer Hunt #include <asm/byteorder.h>
14eac3731bSJennifer Hunt #include <linux/list.h>
15eac3731bSJennifer Hunt #include <linux/poll.h>
16eac3731bSJennifer Hunt #include <linux/socket.h>
17*3881ac44SUrsula Braun #include <net/iucv/iucv.h>
18eac3731bSJennifer Hunt 
19eac3731bSJennifer Hunt #ifndef AF_IUCV
20eac3731bSJennifer Hunt #define AF_IUCV		32
21eac3731bSJennifer Hunt #define PF_IUCV		AF_IUCV
22eac3731bSJennifer Hunt #endif
23eac3731bSJennifer Hunt 
24eac3731bSJennifer Hunt /* Connection and socket states */
25eac3731bSJennifer Hunt enum {
26eac3731bSJennifer Hunt 	IUCV_CONNECTED = 1,
27eac3731bSJennifer Hunt 	IUCV_OPEN,
28eac3731bSJennifer Hunt 	IUCV_BOUND,
29eac3731bSJennifer Hunt 	IUCV_LISTEN,
30eac3731bSJennifer Hunt 	IUCV_SEVERED,
31eac3731bSJennifer Hunt 	IUCV_DISCONN,
32561e0360SJennifer Hunt 	IUCV_CLOSING,
33eac3731bSJennifer Hunt 	IUCV_CLOSED
34eac3731bSJennifer Hunt };
35eac3731bSJennifer Hunt 
36eac3731bSJennifer Hunt #define IUCV_QUEUELEN_DEFAULT	65535
37*3881ac44SUrsula Braun #define IUCV_HIPER_MSGLIM_DEFAULT	128
38eac3731bSJennifer Hunt #define IUCV_CONN_TIMEOUT	(HZ * 40)
39eac3731bSJennifer Hunt #define IUCV_DISCONN_TIMEOUT	(HZ * 2)
40eac3731bSJennifer Hunt #define IUCV_CONN_IDLE_TIMEOUT	(HZ * 60)
41eac3731bSJennifer Hunt #define IUCV_BUFSIZE_DEFAULT	32768
42eac3731bSJennifer Hunt 
43eac3731bSJennifer Hunt /* IUCV socket address */
44eac3731bSJennifer Hunt struct sockaddr_iucv {
45eac3731bSJennifer Hunt 	sa_family_t	siucv_family;
46eac3731bSJennifer Hunt 	unsigned short	siucv_port;		/* Reserved */
47eac3731bSJennifer Hunt 	unsigned int	siucv_addr;		/* Reserved */
48eac3731bSJennifer Hunt 	char		siucv_nodeid[8];	/* Reserved */
49eac3731bSJennifer Hunt 	char		siucv_user_id[8];	/* Guest User Id */
50eac3731bSJennifer Hunt 	char		siucv_name[8];		/* Application Name */
51eac3731bSJennifer Hunt };
52eac3731bSJennifer Hunt 
53eac3731bSJennifer Hunt 
54eac3731bSJennifer Hunt /* Common socket structures and functions */
55f0703c80SUrsula Braun struct sock_msg_q {
56f0703c80SUrsula Braun 	struct iucv_path	*path;
57f0703c80SUrsula Braun 	struct iucv_message	msg;
58f0703c80SUrsula Braun 	struct list_head	list;
59f0703c80SUrsula Braun 	spinlock_t		lock;
60f0703c80SUrsula Braun };
61eac3731bSJennifer Hunt 
62*3881ac44SUrsula Braun #define AF_IUCV_FLAG_ACK 0x1
63*3881ac44SUrsula Braun #define AF_IUCV_FLAG_SYN 0x2
64*3881ac44SUrsula Braun #define AF_IUCV_FLAG_FIN 0x4
65*3881ac44SUrsula Braun #define AF_IUCV_FLAG_WIN 0x8
66*3881ac44SUrsula Braun 
67*3881ac44SUrsula Braun struct af_iucv_trans_hdr {
68*3881ac44SUrsula Braun 	u16 magic;
69*3881ac44SUrsula Braun 	u8 version;
70*3881ac44SUrsula Braun 	u8 flags;
71*3881ac44SUrsula Braun 	u16 window;
72*3881ac44SUrsula Braun 	char destNodeID[8];
73*3881ac44SUrsula Braun 	char destUserID[8];
74*3881ac44SUrsula Braun 	char destAppName[16];
75*3881ac44SUrsula Braun 	char srcNodeID[8];
76*3881ac44SUrsula Braun 	char srcUserID[8];
77*3881ac44SUrsula Braun 	char srcAppName[16];             /* => 70 bytes */
78*3881ac44SUrsula Braun 	struct iucv_message iucv_hdr;    /* => 33 bytes */
79*3881ac44SUrsula Braun 	u8 pad;                          /* total 104 bytes */
80*3881ac44SUrsula Braun } __packed;
81*3881ac44SUrsula Braun 
82*3881ac44SUrsula Braun enum iucv_tx_notify {
83*3881ac44SUrsula Braun 	/* transmission of skb is completed and was successful */
84*3881ac44SUrsula Braun 	TX_NOTIFY_OK = 0,
85*3881ac44SUrsula Braun 	/* target is unreachable */
86*3881ac44SUrsula Braun 	TX_NOTIFY_UNREACHABLE = 1,
87*3881ac44SUrsula Braun 	/* transfer pending queue full */
88*3881ac44SUrsula Braun 	TX_NOTIFY_TPQFULL = 2,
89*3881ac44SUrsula Braun 	/* general error */
90*3881ac44SUrsula Braun 	TX_NOTIFY_GENERALERROR = 3,
91*3881ac44SUrsula Braun 	/* transmission of skb is pending - may interleave
92*3881ac44SUrsula Braun 	 * with TX_NOTIFY_DELAYED_* */
93*3881ac44SUrsula Braun 	TX_NOTIFY_PENDING = 4,
94*3881ac44SUrsula Braun 	/* transmission of skb was done successfully (delayed) */
95*3881ac44SUrsula Braun 	TX_NOTIFY_DELAYED_OK = 5,
96*3881ac44SUrsula Braun 	/* target unreachable (detected delayed) */
97*3881ac44SUrsula Braun 	TX_NOTIFY_DELAYED_UNREACHABLE = 6,
98*3881ac44SUrsula Braun 	/* general error (detected delayed) */
99*3881ac44SUrsula Braun 	TX_NOTIFY_DELAYED_GENERALERROR = 7,
100*3881ac44SUrsula Braun };
101*3881ac44SUrsula Braun 
102eac3731bSJennifer Hunt #define iucv_sk(__sk) ((struct iucv_sock *) __sk)
103eac3731bSJennifer Hunt 
104*3881ac44SUrsula Braun #define AF_IUCV_TRANS_IUCV 0
105*3881ac44SUrsula Braun #define AF_IUCV_TRANS_HIPER 1
106*3881ac44SUrsula Braun 
107eac3731bSJennifer Hunt struct iucv_sock {
108eac3731bSJennifer Hunt 	struct sock		sk;
109eac3731bSJennifer Hunt 	char			src_user_id[8];
110eac3731bSJennifer Hunt 	char			src_name[8];
111eac3731bSJennifer Hunt 	char			dst_user_id[8];
112eac3731bSJennifer Hunt 	char			dst_name[8];
113eac3731bSJennifer Hunt 	struct list_head	accept_q;
114febca281SUrsula Braun 	spinlock_t		accept_q_lock;
115eac3731bSJennifer Hunt 	struct sock		*parent;
116eac3731bSJennifer Hunt 	struct iucv_path	*path;
117eac3731bSJennifer Hunt 	struct sk_buff_head	send_skb_q;
118561e0360SJennifer Hunt 	struct sk_buff_head	backlog_skb_q;
119f0703c80SUrsula Braun 	struct sock_msg_q	message_q;
120eac3731bSJennifer Hunt 	unsigned int		send_tag;
1219d5c5d8fSHendrik Brueckner 	u8			flags;
12209488e2eSHendrik Brueckner 	u16			msglimit;
123*3881ac44SUrsula Braun 	u16			msglimit_peer;
124*3881ac44SUrsula Braun 	atomic_t		msg_sent;
125*3881ac44SUrsula Braun 	atomic_t		msg_recv;
126*3881ac44SUrsula Braun 	atomic_t		pendings;
127*3881ac44SUrsula Braun 	int			transport;
128*3881ac44SUrsula Braun 	void                    (*sk_txnotify)(struct sk_buff *skb,
129*3881ac44SUrsula Braun 					       enum iucv_tx_notify n);
130eac3731bSJennifer Hunt };
131eac3731bSJennifer Hunt 
1329d5c5d8fSHendrik Brueckner /* iucv socket options (SOL_IUCV) */
1339d5c5d8fSHendrik Brueckner #define SO_IPRMDATA_MSG	0x0080		/* send/recv IPRM_DATA msgs */
13409488e2eSHendrik Brueckner #define SO_MSGLIMIT	0x1000		/* get/set IUCV MSGLIMIT */
1359d5c5d8fSHendrik Brueckner 
13644b1e6b5SHendrik Brueckner /* iucv related control messages (scm) */
13744b1e6b5SHendrik Brueckner #define SCM_IUCV_TRGCLS	0x0001		/* target class control message */
13844b1e6b5SHendrik Brueckner 
139eac3731bSJennifer Hunt struct iucv_sock_list {
140eac3731bSJennifer Hunt 	struct hlist_head head;
141eac3731bSJennifer Hunt 	rwlock_t	  lock;
142eac3731bSJennifer Hunt 	atomic_t	  autobind_name;
143eac3731bSJennifer Hunt };
144eac3731bSJennifer Hunt 
145eac3731bSJennifer Hunt unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
146eac3731bSJennifer Hunt 			    poll_table *wait);
147eac3731bSJennifer Hunt void iucv_sock_link(struct iucv_sock_list *l, struct sock *s);
148eac3731bSJennifer Hunt void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *s);
149eac3731bSJennifer Hunt int  iucv_sock_wait_cnt(struct sock *sk, unsigned long timeo);
150eac3731bSJennifer Hunt void iucv_accept_enqueue(struct sock *parent, struct sock *sk);
151eac3731bSJennifer Hunt void iucv_accept_unlink(struct sock *sk);
152eac3731bSJennifer Hunt struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock);
153eac3731bSJennifer Hunt 
154eac3731bSJennifer Hunt #endif /* __IUCV_H */
155