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> 173881ac44SUrsula 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_DISCONN, 31561e0360SJennifer Hunt IUCV_CLOSING, 32eac3731bSJennifer Hunt IUCV_CLOSED 33eac3731bSJennifer Hunt }; 34eac3731bSJennifer Hunt 35eac3731bSJennifer Hunt #define IUCV_QUEUELEN_DEFAULT 65535 363881ac44SUrsula Braun #define IUCV_HIPER_MSGLIM_DEFAULT 128 37eac3731bSJennifer Hunt #define IUCV_CONN_TIMEOUT (HZ * 40) 38eac3731bSJennifer Hunt #define IUCV_DISCONN_TIMEOUT (HZ * 2) 39eac3731bSJennifer Hunt #define IUCV_CONN_IDLE_TIMEOUT (HZ * 60) 40eac3731bSJennifer Hunt #define IUCV_BUFSIZE_DEFAULT 32768 41eac3731bSJennifer Hunt 42eac3731bSJennifer Hunt /* IUCV socket address */ 43eac3731bSJennifer Hunt struct sockaddr_iucv { 44eac3731bSJennifer Hunt sa_family_t siucv_family; 45eac3731bSJennifer Hunt unsigned short siucv_port; /* Reserved */ 46eac3731bSJennifer Hunt unsigned int siucv_addr; /* Reserved */ 47eac3731bSJennifer Hunt char siucv_nodeid[8]; /* Reserved */ 48eac3731bSJennifer Hunt char siucv_user_id[8]; /* Guest User Id */ 49eac3731bSJennifer Hunt char siucv_name[8]; /* Application Name */ 50eac3731bSJennifer Hunt }; 51eac3731bSJennifer Hunt 52eac3731bSJennifer Hunt 53eac3731bSJennifer Hunt /* Common socket structures and functions */ 54f0703c80SUrsula Braun struct sock_msg_q { 55f0703c80SUrsula Braun struct iucv_path *path; 56f0703c80SUrsula Braun struct iucv_message msg; 57f0703c80SUrsula Braun struct list_head list; 58f0703c80SUrsula Braun spinlock_t lock; 59f0703c80SUrsula Braun }; 60eac3731bSJennifer Hunt 613881ac44SUrsula Braun #define AF_IUCV_FLAG_ACK 0x1 623881ac44SUrsula Braun #define AF_IUCV_FLAG_SYN 0x2 633881ac44SUrsula Braun #define AF_IUCV_FLAG_FIN 0x4 643881ac44SUrsula Braun #define AF_IUCV_FLAG_WIN 0x8 6582492a35SUrsula Braun #define AF_IUCV_FLAG_SHT 0x10 663881ac44SUrsula Braun 673881ac44SUrsula Braun struct af_iucv_trans_hdr { 683881ac44SUrsula Braun u16 magic; 693881ac44SUrsula Braun u8 version; 703881ac44SUrsula Braun u8 flags; 713881ac44SUrsula Braun u16 window; 723881ac44SUrsula Braun char destNodeID[8]; 733881ac44SUrsula Braun char destUserID[8]; 743881ac44SUrsula Braun char destAppName[16]; 753881ac44SUrsula Braun char srcNodeID[8]; 763881ac44SUrsula Braun char srcUserID[8]; 773881ac44SUrsula Braun char srcAppName[16]; /* => 70 bytes */ 783881ac44SUrsula Braun struct iucv_message iucv_hdr; /* => 33 bytes */ 793881ac44SUrsula Braun u8 pad; /* total 104 bytes */ 803881ac44SUrsula Braun } __packed; 813881ac44SUrsula Braun 823881ac44SUrsula Braun enum iucv_tx_notify { 833881ac44SUrsula Braun /* transmission of skb is completed and was successful */ 843881ac44SUrsula Braun TX_NOTIFY_OK = 0, 853881ac44SUrsula Braun /* target is unreachable */ 863881ac44SUrsula Braun TX_NOTIFY_UNREACHABLE = 1, 873881ac44SUrsula Braun /* transfer pending queue full */ 883881ac44SUrsula Braun TX_NOTIFY_TPQFULL = 2, 893881ac44SUrsula Braun /* general error */ 903881ac44SUrsula Braun TX_NOTIFY_GENERALERROR = 3, 913881ac44SUrsula Braun /* transmission of skb is pending - may interleave 923881ac44SUrsula Braun * with TX_NOTIFY_DELAYED_* */ 933881ac44SUrsula Braun TX_NOTIFY_PENDING = 4, 943881ac44SUrsula Braun /* transmission of skb was done successfully (delayed) */ 953881ac44SUrsula Braun TX_NOTIFY_DELAYED_OK = 5, 963881ac44SUrsula Braun /* target unreachable (detected delayed) */ 973881ac44SUrsula Braun TX_NOTIFY_DELAYED_UNREACHABLE = 6, 983881ac44SUrsula Braun /* general error (detected delayed) */ 993881ac44SUrsula Braun TX_NOTIFY_DELAYED_GENERALERROR = 7, 1003881ac44SUrsula Braun }; 1013881ac44SUrsula Braun 102eac3731bSJennifer Hunt #define iucv_sk(__sk) ((struct iucv_sock *) __sk) 103eac3731bSJennifer Hunt 1043881ac44SUrsula Braun #define AF_IUCV_TRANS_IUCV 0 1053881ac44SUrsula Braun #define AF_IUCV_TRANS_HIPER 1 1063881ac44SUrsula 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; 117800c5eb7SUrsula Braun struct net_device *hs_dev; 118eac3731bSJennifer Hunt struct sk_buff_head send_skb_q; 119561e0360SJennifer Hunt struct sk_buff_head backlog_skb_q; 120f0703c80SUrsula Braun struct sock_msg_q message_q; 121eac3731bSJennifer Hunt unsigned int send_tag; 1229d5c5d8fSHendrik Brueckner u8 flags; 12309488e2eSHendrik Brueckner u16 msglimit; 1243881ac44SUrsula Braun u16 msglimit_peer; 1253881ac44SUrsula Braun atomic_t msg_sent; 1263881ac44SUrsula Braun atomic_t msg_recv; 1273881ac44SUrsula Braun atomic_t pendings; 1283881ac44SUrsula Braun int transport; 1293881ac44SUrsula Braun void (*sk_txnotify)(struct sk_buff *skb, 1303881ac44SUrsula Braun enum iucv_tx_notify n); 131eac3731bSJennifer Hunt }; 132eac3731bSJennifer Hunt 133*f9c41a62SUrsula Braun struct iucv_skb_cb { 134*f9c41a62SUrsula Braun u32 class; /* target class of message */ 135*f9c41a62SUrsula Braun u32 tag; /* tag associated with message */ 136*f9c41a62SUrsula Braun u32 offset; /* offset for skb receival */ 137*f9c41a62SUrsula Braun }; 138*f9c41a62SUrsula Braun 139*f9c41a62SUrsula Braun #define IUCV_SKB_CB(__skb) ((struct iucv_skb_cb *)&((__skb)->cb[0])) 140*f9c41a62SUrsula Braun 1419d5c5d8fSHendrik Brueckner /* iucv socket options (SOL_IUCV) */ 1429d5c5d8fSHendrik Brueckner #define SO_IPRMDATA_MSG 0x0080 /* send/recv IPRM_DATA msgs */ 14309488e2eSHendrik Brueckner #define SO_MSGLIMIT 0x1000 /* get/set IUCV MSGLIMIT */ 14451363b87SUrsula Braun #define SO_MSGSIZE 0x0800 /* get maximum msgsize */ 1459d5c5d8fSHendrik Brueckner 14644b1e6b5SHendrik Brueckner /* iucv related control messages (scm) */ 14744b1e6b5SHendrik Brueckner #define SCM_IUCV_TRGCLS 0x0001 /* target class control message */ 14844b1e6b5SHendrik Brueckner 149eac3731bSJennifer Hunt struct iucv_sock_list { 150eac3731bSJennifer Hunt struct hlist_head head; 151eac3731bSJennifer Hunt rwlock_t lock; 152eac3731bSJennifer Hunt atomic_t autobind_name; 153eac3731bSJennifer Hunt }; 154eac3731bSJennifer Hunt 155eac3731bSJennifer Hunt unsigned int iucv_sock_poll(struct file *file, struct socket *sock, 156eac3731bSJennifer Hunt poll_table *wait); 157eac3731bSJennifer Hunt void iucv_sock_link(struct iucv_sock_list *l, struct sock *s); 158eac3731bSJennifer Hunt void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *s); 159eac3731bSJennifer Hunt void iucv_accept_enqueue(struct sock *parent, struct sock *sk); 160eac3731bSJennifer Hunt void iucv_accept_unlink(struct sock *sk); 161eac3731bSJennifer Hunt struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock); 162eac3731bSJennifer Hunt 163eac3731bSJennifer Hunt #endif /* __IUCV_H */ 164