1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2eac3731bSJennifer Hunt /* 3eac3731bSJennifer Hunt * Copyright 2006 IBM Corporation 4eac3731bSJennifer Hunt * IUCV protocol stack for Linux on zSeries 5eac3731bSJennifer Hunt * Version 1.0 6eac3731bSJennifer Hunt * Author(s): Jennifer Hunt <jenhunt@us.ibm.com> 7eac3731bSJennifer Hunt * 8eac3731bSJennifer Hunt */ 9eac3731bSJennifer Hunt 10eac3731bSJennifer Hunt #ifndef __AFIUCV_H 11eac3731bSJennifer Hunt #define __AFIUCV_H 12eac3731bSJennifer Hunt 13eac3731bSJennifer Hunt #include <asm/types.h> 14eac3731bSJennifer Hunt #include <asm/byteorder.h> 15eac3731bSJennifer Hunt #include <linux/list.h> 16eac3731bSJennifer Hunt #include <linux/poll.h> 17eac3731bSJennifer Hunt #include <linux/socket.h> 183881ac44SUrsula Braun #include <net/iucv/iucv.h> 19eac3731bSJennifer Hunt 20eac3731bSJennifer Hunt #ifndef AF_IUCV 21eac3731bSJennifer Hunt #define AF_IUCV 32 22eac3731bSJennifer Hunt #define PF_IUCV AF_IUCV 23eac3731bSJennifer Hunt #endif 24eac3731bSJennifer Hunt 25eac3731bSJennifer Hunt /* Connection and socket states */ 26eac3731bSJennifer Hunt enum { 27eac3731bSJennifer Hunt IUCV_CONNECTED = 1, 28eac3731bSJennifer Hunt IUCV_OPEN, 29eac3731bSJennifer Hunt IUCV_BOUND, 30eac3731bSJennifer Hunt IUCV_LISTEN, 31eac3731bSJennifer Hunt IUCV_DISCONN, 32561e0360SJennifer Hunt IUCV_CLOSING, 33eac3731bSJennifer Hunt IUCV_CLOSED 34eac3731bSJennifer Hunt }; 35eac3731bSJennifer Hunt 36eac3731bSJennifer Hunt #define IUCV_QUEUELEN_DEFAULT 65535 373881ac44SUrsula 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 623881ac44SUrsula Braun #define AF_IUCV_FLAG_ACK 0x1 633881ac44SUrsula Braun #define AF_IUCV_FLAG_SYN 0x2 643881ac44SUrsula Braun #define AF_IUCV_FLAG_FIN 0x4 653881ac44SUrsula Braun #define AF_IUCV_FLAG_WIN 0x8 6682492a35SUrsula Braun #define AF_IUCV_FLAG_SHT 0x10 673881ac44SUrsula Braun 683881ac44SUrsula Braun struct af_iucv_trans_hdr { 693881ac44SUrsula Braun u16 magic; 703881ac44SUrsula Braun u8 version; 713881ac44SUrsula Braun u8 flags; 723881ac44SUrsula Braun u16 window; 733881ac44SUrsula Braun char destNodeID[8]; 743881ac44SUrsula Braun char destUserID[8]; 753881ac44SUrsula Braun char destAppName[16]; 763881ac44SUrsula Braun char srcNodeID[8]; 773881ac44SUrsula Braun char srcUserID[8]; 783881ac44SUrsula Braun char srcAppName[16]; /* => 70 bytes */ 793881ac44SUrsula Braun struct iucv_message iucv_hdr; /* => 33 bytes */ 803881ac44SUrsula Braun u8 pad; /* total 104 bytes */ 813881ac44SUrsula Braun } __packed; 823881ac44SUrsula Braun 83*cd11d112SJulian Wiedmann static inline struct af_iucv_trans_hdr *iucv_trans_hdr(struct sk_buff *skb) 84*cd11d112SJulian Wiedmann { 85*cd11d112SJulian Wiedmann return (struct af_iucv_trans_hdr *)skb_network_header(skb); 86*cd11d112SJulian Wiedmann } 87*cd11d112SJulian Wiedmann 883881ac44SUrsula Braun enum iucv_tx_notify { 893881ac44SUrsula Braun /* transmission of skb is completed and was successful */ 903881ac44SUrsula Braun TX_NOTIFY_OK = 0, 913881ac44SUrsula Braun /* target is unreachable */ 923881ac44SUrsula Braun TX_NOTIFY_UNREACHABLE = 1, 933881ac44SUrsula Braun /* transfer pending queue full */ 943881ac44SUrsula Braun TX_NOTIFY_TPQFULL = 2, 953881ac44SUrsula Braun /* general error */ 963881ac44SUrsula Braun TX_NOTIFY_GENERALERROR = 3, 973881ac44SUrsula Braun /* transmission of skb is pending - may interleave 983881ac44SUrsula Braun * with TX_NOTIFY_DELAYED_* */ 993881ac44SUrsula Braun TX_NOTIFY_PENDING = 4, 1003881ac44SUrsula Braun /* transmission of skb was done successfully (delayed) */ 1013881ac44SUrsula Braun TX_NOTIFY_DELAYED_OK = 5, 1023881ac44SUrsula Braun /* target unreachable (detected delayed) */ 1033881ac44SUrsula Braun TX_NOTIFY_DELAYED_UNREACHABLE = 6, 1043881ac44SUrsula Braun /* general error (detected delayed) */ 1053881ac44SUrsula Braun TX_NOTIFY_DELAYED_GENERALERROR = 7, 1063881ac44SUrsula Braun }; 1073881ac44SUrsula Braun 108eac3731bSJennifer Hunt #define iucv_sk(__sk) ((struct iucv_sock *) __sk) 109eac3731bSJennifer Hunt 1103881ac44SUrsula Braun #define AF_IUCV_TRANS_IUCV 0 1113881ac44SUrsula Braun #define AF_IUCV_TRANS_HIPER 1 1123881ac44SUrsula Braun 113eac3731bSJennifer Hunt struct iucv_sock { 114eac3731bSJennifer Hunt struct sock sk; 115eac3731bSJennifer Hunt char src_user_id[8]; 116eac3731bSJennifer Hunt char src_name[8]; 117eac3731bSJennifer Hunt char dst_user_id[8]; 118eac3731bSJennifer Hunt char dst_name[8]; 119eac3731bSJennifer Hunt struct list_head accept_q; 120febca281SUrsula Braun spinlock_t accept_q_lock; 121eac3731bSJennifer Hunt struct sock *parent; 122eac3731bSJennifer Hunt struct iucv_path *path; 123800c5eb7SUrsula Braun struct net_device *hs_dev; 124eac3731bSJennifer Hunt struct sk_buff_head send_skb_q; 125561e0360SJennifer Hunt struct sk_buff_head backlog_skb_q; 126f0703c80SUrsula Braun struct sock_msg_q message_q; 127eac3731bSJennifer Hunt unsigned int send_tag; 1289d5c5d8fSHendrik Brueckner u8 flags; 12909488e2eSHendrik Brueckner u16 msglimit; 1303881ac44SUrsula Braun u16 msglimit_peer; 1313881ac44SUrsula Braun atomic_t msg_sent; 1323881ac44SUrsula Braun atomic_t msg_recv; 1333881ac44SUrsula Braun atomic_t pendings; 1343881ac44SUrsula Braun int transport; 1353881ac44SUrsula Braun void (*sk_txnotify)(struct sk_buff *skb, 1363881ac44SUrsula Braun enum iucv_tx_notify n); 137eac3731bSJennifer Hunt }; 138eac3731bSJennifer Hunt 139f9c41a62SUrsula Braun struct iucv_skb_cb { 140f9c41a62SUrsula Braun u32 class; /* target class of message */ 141f9c41a62SUrsula Braun u32 tag; /* tag associated with message */ 142f9c41a62SUrsula Braun u32 offset; /* offset for skb receival */ 143f9c41a62SUrsula Braun }; 144f9c41a62SUrsula Braun 145f9c41a62SUrsula Braun #define IUCV_SKB_CB(__skb) ((struct iucv_skb_cb *)&((__skb)->cb[0])) 146f9c41a62SUrsula Braun 1479d5c5d8fSHendrik Brueckner /* iucv socket options (SOL_IUCV) */ 1489d5c5d8fSHendrik Brueckner #define SO_IPRMDATA_MSG 0x0080 /* send/recv IPRM_DATA msgs */ 14909488e2eSHendrik Brueckner #define SO_MSGLIMIT 0x1000 /* get/set IUCV MSGLIMIT */ 15051363b87SUrsula Braun #define SO_MSGSIZE 0x0800 /* get maximum msgsize */ 1519d5c5d8fSHendrik Brueckner 15244b1e6b5SHendrik Brueckner /* iucv related control messages (scm) */ 15344b1e6b5SHendrik Brueckner #define SCM_IUCV_TRGCLS 0x0001 /* target class control message */ 15444b1e6b5SHendrik Brueckner 155eac3731bSJennifer Hunt struct iucv_sock_list { 156eac3731bSJennifer Hunt struct hlist_head head; 157eac3731bSJennifer Hunt rwlock_t lock; 158eac3731bSJennifer Hunt atomic_t autobind_name; 159eac3731bSJennifer Hunt }; 160eac3731bSJennifer Hunt 161a11e1d43SLinus Torvalds __poll_t iucv_sock_poll(struct file *file, struct socket *sock, 162a11e1d43SLinus Torvalds poll_table *wait); 163eac3731bSJennifer Hunt void iucv_sock_link(struct iucv_sock_list *l, struct sock *s); 164eac3731bSJennifer Hunt void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *s); 165eac3731bSJennifer Hunt void iucv_accept_enqueue(struct sock *parent, struct sock *sk); 166eac3731bSJennifer Hunt void iucv_accept_unlink(struct sock *sk); 167eac3731bSJennifer Hunt struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock); 168eac3731bSJennifer Hunt 169eac3731bSJennifer Hunt #endif /* __IUCV_H */ 170