1*b2441318SGreg 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 833881ac44SUrsula Braun enum iucv_tx_notify { 843881ac44SUrsula Braun /* transmission of skb is completed and was successful */ 853881ac44SUrsula Braun TX_NOTIFY_OK = 0, 863881ac44SUrsula Braun /* target is unreachable */ 873881ac44SUrsula Braun TX_NOTIFY_UNREACHABLE = 1, 883881ac44SUrsula Braun /* transfer pending queue full */ 893881ac44SUrsula Braun TX_NOTIFY_TPQFULL = 2, 903881ac44SUrsula Braun /* general error */ 913881ac44SUrsula Braun TX_NOTIFY_GENERALERROR = 3, 923881ac44SUrsula Braun /* transmission of skb is pending - may interleave 933881ac44SUrsula Braun * with TX_NOTIFY_DELAYED_* */ 943881ac44SUrsula Braun TX_NOTIFY_PENDING = 4, 953881ac44SUrsula Braun /* transmission of skb was done successfully (delayed) */ 963881ac44SUrsula Braun TX_NOTIFY_DELAYED_OK = 5, 973881ac44SUrsula Braun /* target unreachable (detected delayed) */ 983881ac44SUrsula Braun TX_NOTIFY_DELAYED_UNREACHABLE = 6, 993881ac44SUrsula Braun /* general error (detected delayed) */ 1003881ac44SUrsula Braun TX_NOTIFY_DELAYED_GENERALERROR = 7, 1013881ac44SUrsula Braun }; 1023881ac44SUrsula Braun 103eac3731bSJennifer Hunt #define iucv_sk(__sk) ((struct iucv_sock *) __sk) 104eac3731bSJennifer Hunt 1053881ac44SUrsula Braun #define AF_IUCV_TRANS_IUCV 0 1063881ac44SUrsula Braun #define AF_IUCV_TRANS_HIPER 1 1073881ac44SUrsula Braun 108eac3731bSJennifer Hunt struct iucv_sock { 109eac3731bSJennifer Hunt struct sock sk; 110eac3731bSJennifer Hunt char src_user_id[8]; 111eac3731bSJennifer Hunt char src_name[8]; 112eac3731bSJennifer Hunt char dst_user_id[8]; 113eac3731bSJennifer Hunt char dst_name[8]; 114eac3731bSJennifer Hunt struct list_head accept_q; 115febca281SUrsula Braun spinlock_t accept_q_lock; 116eac3731bSJennifer Hunt struct sock *parent; 117eac3731bSJennifer Hunt struct iucv_path *path; 118800c5eb7SUrsula Braun struct net_device *hs_dev; 119eac3731bSJennifer Hunt struct sk_buff_head send_skb_q; 120561e0360SJennifer Hunt struct sk_buff_head backlog_skb_q; 121f0703c80SUrsula Braun struct sock_msg_q message_q; 122eac3731bSJennifer Hunt unsigned int send_tag; 1239d5c5d8fSHendrik Brueckner u8 flags; 12409488e2eSHendrik Brueckner u16 msglimit; 1253881ac44SUrsula Braun u16 msglimit_peer; 1263881ac44SUrsula Braun atomic_t msg_sent; 1273881ac44SUrsula Braun atomic_t msg_recv; 1283881ac44SUrsula Braun atomic_t pendings; 1293881ac44SUrsula Braun int transport; 1303881ac44SUrsula Braun void (*sk_txnotify)(struct sk_buff *skb, 1313881ac44SUrsula Braun enum iucv_tx_notify n); 132eac3731bSJennifer Hunt }; 133eac3731bSJennifer Hunt 134f9c41a62SUrsula Braun struct iucv_skb_cb { 135f9c41a62SUrsula Braun u32 class; /* target class of message */ 136f9c41a62SUrsula Braun u32 tag; /* tag associated with message */ 137f9c41a62SUrsula Braun u32 offset; /* offset for skb receival */ 138f9c41a62SUrsula Braun }; 139f9c41a62SUrsula Braun 140f9c41a62SUrsula Braun #define IUCV_SKB_CB(__skb) ((struct iucv_skb_cb *)&((__skb)->cb[0])) 141f9c41a62SUrsula Braun 1429d5c5d8fSHendrik Brueckner /* iucv socket options (SOL_IUCV) */ 1439d5c5d8fSHendrik Brueckner #define SO_IPRMDATA_MSG 0x0080 /* send/recv IPRM_DATA msgs */ 14409488e2eSHendrik Brueckner #define SO_MSGLIMIT 0x1000 /* get/set IUCV MSGLIMIT */ 14551363b87SUrsula Braun #define SO_MSGSIZE 0x0800 /* get maximum msgsize */ 1469d5c5d8fSHendrik Brueckner 14744b1e6b5SHendrik Brueckner /* iucv related control messages (scm) */ 14844b1e6b5SHendrik Brueckner #define SCM_IUCV_TRGCLS 0x0001 /* target class control message */ 14944b1e6b5SHendrik Brueckner 150eac3731bSJennifer Hunt struct iucv_sock_list { 151eac3731bSJennifer Hunt struct hlist_head head; 152eac3731bSJennifer Hunt rwlock_t lock; 153eac3731bSJennifer Hunt atomic_t autobind_name; 154eac3731bSJennifer Hunt }; 155eac3731bSJennifer Hunt 156eac3731bSJennifer Hunt unsigned int iucv_sock_poll(struct file *file, struct socket *sock, 157eac3731bSJennifer Hunt poll_table *wait); 158eac3731bSJennifer Hunt void iucv_sock_link(struct iucv_sock_list *l, struct sock *s); 159eac3731bSJennifer Hunt void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *s); 160eac3731bSJennifer Hunt void iucv_accept_enqueue(struct sock *parent, struct sock *sk); 161eac3731bSJennifer Hunt void iucv_accept_unlink(struct sock *sk); 162eac3731bSJennifer Hunt struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock); 163eac3731bSJennifer Hunt 164eac3731bSJennifer Hunt #endif /* __IUCV_H */ 165