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