xref: /openbmc/linux/include/net/iucv/af_iucv.h (revision 44b1e6b5f9a93cc2ba024e09cf137d5f1b5f8426)
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>
17eac3731bSJennifer Hunt 
18eac3731bSJennifer Hunt #ifndef AF_IUCV
19eac3731bSJennifer Hunt #define AF_IUCV		32
20eac3731bSJennifer Hunt #define PF_IUCV		AF_IUCV
21eac3731bSJennifer Hunt #endif
22eac3731bSJennifer Hunt 
23eac3731bSJennifer Hunt /* Connection and socket states */
24eac3731bSJennifer Hunt enum {
25eac3731bSJennifer Hunt 	IUCV_CONNECTED = 1,
26eac3731bSJennifer Hunt 	IUCV_OPEN,
27eac3731bSJennifer Hunt 	IUCV_BOUND,
28eac3731bSJennifer Hunt 	IUCV_LISTEN,
29eac3731bSJennifer Hunt 	IUCV_SEVERED,
30eac3731bSJennifer Hunt 	IUCV_DISCONN,
31561e0360SJennifer Hunt 	IUCV_CLOSING,
32eac3731bSJennifer Hunt 	IUCV_CLOSED
33eac3731bSJennifer Hunt };
34eac3731bSJennifer Hunt 
35eac3731bSJennifer Hunt #define IUCV_QUEUELEN_DEFAULT	65535
36eac3731bSJennifer Hunt #define IUCV_CONN_TIMEOUT	(HZ * 40)
37eac3731bSJennifer Hunt #define IUCV_DISCONN_TIMEOUT	(HZ * 2)
38eac3731bSJennifer Hunt #define IUCV_CONN_IDLE_TIMEOUT	(HZ * 60)
39eac3731bSJennifer Hunt #define IUCV_BUFSIZE_DEFAULT	32768
40eac3731bSJennifer Hunt 
41eac3731bSJennifer Hunt /* IUCV socket address */
42eac3731bSJennifer Hunt struct sockaddr_iucv {
43eac3731bSJennifer Hunt 	sa_family_t	siucv_family;
44eac3731bSJennifer Hunt 	unsigned short	siucv_port;		/* Reserved */
45eac3731bSJennifer Hunt 	unsigned int	siucv_addr;		/* Reserved */
46eac3731bSJennifer Hunt 	char		siucv_nodeid[8];	/* Reserved */
47eac3731bSJennifer Hunt 	char		siucv_user_id[8];	/* Guest User Id */
48eac3731bSJennifer Hunt 	char		siucv_name[8];		/* Application Name */
49eac3731bSJennifer Hunt };
50eac3731bSJennifer Hunt 
51eac3731bSJennifer Hunt 
52eac3731bSJennifer Hunt /* Common socket structures and functions */
53f0703c80SUrsula Braun struct sock_msg_q {
54f0703c80SUrsula Braun 	struct iucv_path	*path;
55f0703c80SUrsula Braun 	struct iucv_message	msg;
56f0703c80SUrsula Braun 	struct list_head	list;
57f0703c80SUrsula Braun 	spinlock_t		lock;
58f0703c80SUrsula Braun };
59eac3731bSJennifer Hunt 
60eac3731bSJennifer Hunt #define iucv_sk(__sk) ((struct iucv_sock *) __sk)
61eac3731bSJennifer Hunt 
62eac3731bSJennifer Hunt struct iucv_sock {
63eac3731bSJennifer Hunt 	struct sock		sk;
64eac3731bSJennifer Hunt 	char			src_user_id[8];
65eac3731bSJennifer Hunt 	char			src_name[8];
66eac3731bSJennifer Hunt 	char			dst_user_id[8];
67eac3731bSJennifer Hunt 	char			dst_name[8];
68eac3731bSJennifer Hunt 	struct list_head	accept_q;
69febca281SUrsula Braun 	spinlock_t		accept_q_lock;
70eac3731bSJennifer Hunt 	struct sock		*parent;
71eac3731bSJennifer Hunt 	struct iucv_path	*path;
72eac3731bSJennifer Hunt 	struct sk_buff_head	send_skb_q;
73561e0360SJennifer Hunt 	struct sk_buff_head	backlog_skb_q;
74f0703c80SUrsula Braun 	struct sock_msg_q	message_q;
75eac3731bSJennifer Hunt 	unsigned int		send_tag;
769d5c5d8fSHendrik Brueckner 	u8			flags;
77eac3731bSJennifer Hunt };
78eac3731bSJennifer Hunt 
799d5c5d8fSHendrik Brueckner /* iucv socket options (SOL_IUCV) */
809d5c5d8fSHendrik Brueckner #define SO_IPRMDATA_MSG	0x0080		/* send/recv IPRM_DATA msgs */
819d5c5d8fSHendrik Brueckner 
82*44b1e6b5SHendrik Brueckner /* iucv related control messages (scm) */
83*44b1e6b5SHendrik Brueckner #define SCM_IUCV_TRGCLS	0x0001		/* target class control message */
84*44b1e6b5SHendrik Brueckner 
85eac3731bSJennifer Hunt struct iucv_sock_list {
86eac3731bSJennifer Hunt 	struct hlist_head head;
87eac3731bSJennifer Hunt 	rwlock_t	  lock;
88eac3731bSJennifer Hunt 	atomic_t	  autobind_name;
89eac3731bSJennifer Hunt };
90eac3731bSJennifer Hunt 
91eac3731bSJennifer Hunt unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
92eac3731bSJennifer Hunt 			    poll_table *wait);
93eac3731bSJennifer Hunt void iucv_sock_link(struct iucv_sock_list *l, struct sock *s);
94eac3731bSJennifer Hunt void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *s);
95eac3731bSJennifer Hunt int  iucv_sock_wait_state(struct sock *sk, int state, int state2,
96eac3731bSJennifer Hunt 			  unsigned long timeo);
97eac3731bSJennifer Hunt int  iucv_sock_wait_cnt(struct sock *sk, unsigned long timeo);
98eac3731bSJennifer Hunt void iucv_accept_enqueue(struct sock *parent, struct sock *sk);
99eac3731bSJennifer Hunt void iucv_accept_unlink(struct sock *sk);
100eac3731bSJennifer Hunt struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock);
101eac3731bSJennifer Hunt 
102eac3731bSJennifer Hunt #endif /* __IUCV_H */
103