Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
iucv.h
Go to the documentation of this file.
1 /*
2  * drivers/s390/net/iucv.h
3  * IUCV base support.
4  *
5  * S390 version
6  * Copyright 2000, 2006 IBM Corporation
7  * Author(s):Alan Altmark ([email protected])
8  * Xenia Tkatschow ([email protected])
9  * Rewritten for af_iucv:
10  * Martin Schwidefsky <[email protected]>
11  *
12  *
13  * Functionality:
14  * To explore any of the IUCV functions, one must first register their
15  * program using iucv_register(). Once your program has successfully
16  * completed a register, it can exploit the other functions.
17  * For furthur reference on all IUCV functionality, refer to the
18  * CP Programming Services book, also available on the web thru
19  * www.vm.ibm.com/pubs, manual # SC24-6084
20  *
21  * Definition of Return Codes
22  * - All positive return codes including zero are reflected back
23  * from CP. The definition of each return code can be found in
24  * CP Programming Services book.
25  * - Return Code of:
26  * -EINVAL: Invalid value
27  * -ENOMEM: storage allocation failed
28  */
29 
30 #include <linux/types.h>
31 #include <linux/slab.h>
32 #include <asm/debug.h>
33 
34 /*
35  * IUCV option flags usable by device drivers:
36  *
37  * IUCV_IPRMDATA Indicates that your program can handle a message in the
38  * parameter list / a message is sent in the parameter list.
39  * Used for iucv_path_accept, iucv_path_connect,
40  * iucv_message_reply, iucv_message_send, iucv_message_send2way.
41  * IUCV_IPQUSCE Indicates that you do not want to receive messages on this
42  * path until an iucv_path_resume is issued.
43  * Used for iucv_path_accept, iucv_path_connect.
44  * IUCV_IPBUFLST Indicates that an address list is used for the message data.
45  * Used for iucv_message_receive, iucv_message_send,
46  * iucv_message_send2way.
47  * IUCV_IPPRTY Specifies that you want to send priority messages.
48  * Used for iucv_path_accept, iucv_path_connect,
49  * iucv_message_reply, iucv_message_send, iucv_message_send2way.
50  * IUCV_IPSYNC Indicates a synchronous send request.
51  * Used for iucv_message_send, iucv_message_send2way.
52  * IUCV_IPANSLST Indicates that an address list is used for the reply data.
53  * Used for iucv_message_reply, iucv_message_send2way.
54  * IUCV_IPLOCAL Specifies that the communication partner has to be on the
55  * local system. If local is specified no target class can be
56  * specified.
57  * Used for iucv_path_connect.
58  *
59  * All flags are defined in the input field IPFLAGS1 of each function
60  * and can be found in CP Programming Services.
61  */
62 #define IUCV_IPRMDATA 0x80
63 #define IUCV_IPQUSCE 0x40
64 #define IUCV_IPBUFLST 0x40
65 #define IUCV_IPPRTY 0x20
66 #define IUCV_IPANSLST 0x08
67 #define IUCV_IPSYNC 0x04
68 #define IUCV_IPLOCAL 0x01
69 
70 /*
71  * iucv_array : Defines buffer array.
72  * Inside the array may be 31- bit addresses and 31-bit lengths.
73  * Use a pointer to an iucv_array as the buffer, reply or answer
74  * parameter on iucv_message_send, iucv_message_send2way, iucv_message_receive
75  * and iucv_message_reply if IUCV_IPBUFLST or IUCV_IPANSLST are used.
76  */
77 struct iucv_array {
80 } __attribute__ ((aligned (8)));
81 
82 extern struct bus_type iucv_bus;
83 extern struct device *iucv_root;
84 
85 /*
86  * struct iucv_path
87  * pathid: 16 bit path identification
88  * msglim: 16 bit message limit
89  * flags: properties of the path: IPRMDATA, IPQUSCE, IPPRTY
90  * handler: address of iucv handler structure
91  * private: private information of the handler associated with the path
92  * list: list_head for the iucv_handler path list.
93  */
94 struct iucv_path {
98  void *private;
100  struct list_head list;
101 };
102 
103 /*
104  * struct iucv_message
105  * id: 32 bit message id
106  * audit: 32 bit error information of purged or replied messages
107  * class: 32 bit target class of a message (source class for replies)
108  * tag: 32 bit tag to be associated with the message
109  * length: 32 bit length of the message / reply
110  * reply_size: 32 bit maximum allowed length of the reply
111  * rmmsg: 8 byte inline message
112  * flags: message properties (IUCV_IPPRTY)
113  */
114 struct iucv_message {
117  u32 class;
121  u8 rmmsg[8];
123 } __packed;
124 
125 /*
126  * struct iucv_handler
127  *
128  * A vector of functions that handle IUCV interrupts. Each functions gets
129  * a parameter area as defined by the CP Programming Services and private
130  * pointer that is provided by the user of the interface.
131  */
132 struct iucv_handler {
133  /*
134  * The path_pending function is called after an iucv interrupt
135  * type 0x01 has been received. The base code allocates a path
136  * structure and "asks" the handler if this path belongs to the
137  * handler. To accept the path the path_pending function needs
138  * to call iucv_path_accept and return 0. If the callback returns
139  * a value != 0 the iucv base code will continue with the next
140  * handler. The order in which the path_pending functions are
141  * called is the order of the registration of the iucv handlers
142  * to the base code.
143  */
144  int (*path_pending)(struct iucv_path *, u8 ipvmid[8], u8 ipuser[16]);
145  /*
146  * The path_complete function is called after an iucv interrupt
147  * type 0x02 has been received for a path that has been established
148  * for this handler with iucv_path_connect and got accepted by the
149  * peer with iucv_path_accept.
150  */
151  void (*path_complete)(struct iucv_path *, u8 ipuser[16]);
152  /*
153  * The path_severed function is called after an iucv interrupt
154  * type 0x03 has been received. The communication peer shutdown
155  * his end of the communication path. The path still exists and
156  * remaining messages can be received until a iucv_path_sever
157  * shuts down the other end of the path as well.
158  */
159  void (*path_severed)(struct iucv_path *, u8 ipuser[16]);
160  /*
161  * The path_quiesced function is called after an icuv interrupt
162  * type 0x04 has been received. The communication peer has quiesced
163  * the path. Delivery of messages is stopped until iucv_path_resume
164  * has been called.
165  */
166  void (*path_quiesced)(struct iucv_path *, u8 ipuser[16]);
167  /*
168  * The path_resumed function is called after an icuv interrupt
169  * type 0x05 has been received. The communication peer has resumed
170  * the path.
171  */
172  void (*path_resumed)(struct iucv_path *, u8 ipuser[16]);
173  /*
174  * The message_pending function is called after an icuv interrupt
175  * type 0x06 or type 0x07 has been received. A new message is
176  * available and can be received with iucv_message_receive.
177  */
178  void (*message_pending)(struct iucv_path *, struct iucv_message *);
179  /*
180  * The message_complete function is called after an icuv interrupt
181  * type 0x08 or type 0x09 has been received. A message send with
182  * iucv_message_send2way has been replied to. The reply can be
183  * received with iucv_message_receive.
184  */
185  void (*message_complete)(struct iucv_path *, struct iucv_message *);
186 
187  struct list_head list;
188  struct list_head paths;
189 };
190 
201 int iucv_register(struct iucv_handler *handler, int smp);
202 
210 void iucv_unregister(struct iucv_handler *handle, int smp);
211 
223 static inline struct iucv_path *iucv_path_alloc(u16 msglim, u8 flags, gfp_t gfp)
224 {
225  struct iucv_path *path;
226 
227  path = kzalloc(sizeof(struct iucv_path), gfp);
228  if (path) {
229  path->msglim = msglim;
230  path->flags = flags;
231  }
232  return path;
233 }
234 
241 static inline void iucv_path_free(struct iucv_path *path)
242 {
243  kfree(path);
244 }
245 
258 int iucv_path_accept(struct iucv_path *path, struct iucv_handler *handler,
259  u8 userdata[16], void *private);
260 
276 int iucv_path_connect(struct iucv_path *path, struct iucv_handler *handler,
277  u8 userid[8], u8 system[8], u8 userdata[16],
278  void *private);
279 
290 int iucv_path_quiesce(struct iucv_path *path, u8 userdata[16]);
291 
302 int iucv_path_resume(struct iucv_path *path, u8 userdata[16]);
303 
313 int iucv_path_sever(struct iucv_path *path, u8 userdata[16]);
314 
325 int iucv_message_purge(struct iucv_path *path, struct iucv_message *msg,
326  u32 srccls);
327 
345 int iucv_message_receive(struct iucv_path *path, struct iucv_message *msg,
346  u8 flags, void *buffer, size_t size, size_t *residual);
347 
365 int __iucv_message_receive(struct iucv_path *path, struct iucv_message *msg,
366  u8 flags, void *buffer, size_t size,
367  size_t *residual);
368 
380 int iucv_message_reject(struct iucv_path *path, struct iucv_message *msg);
381 
397 int iucv_message_reply(struct iucv_path *path, struct iucv_message *msg,
398  u8 flags, void *reply, size_t size);
399 
417 int iucv_message_send(struct iucv_path *path, struct iucv_message *msg,
418  u8 flags, u32 srccls, void *buffer, size_t size);
419 
437 int __iucv_message_send(struct iucv_path *path, struct iucv_message *msg,
438  u8 flags, u32 srccls, void *buffer, size_t size);
439 
459 int iucv_message_send2way(struct iucv_path *path, struct iucv_message *msg,
460  u8 flags, u32 srccls, void *buffer, size_t size,
461  void *answer, size_t asize, size_t *residual);
462 
465  u8 flags, void *buffer, size_t size, size_t *residual);
467  struct iucv_message *msg, u8 flags, void *buffer, size_t size,
468  size_t *residual);
470  u8 flags, void *reply, size_t size);
473  u8 flags, u32 srccls, void *buffer, size_t size);
475  u8 flags, u32 srccls, void *buffer, size_t size);
477  struct iucv_message *msg, u8 flags, u32 srccls, void *buffer,
478  size_t size, void *answer, size_t asize, size_t *residual);
480  u32 srccls);
482  u8 userdata[16], void *private);
484  struct iucv_handler *handler,
485  u8 userid[8], u8 system[8], u8 userdata[16], void *private);
486  int (*path_quiesce)(struct iucv_path *path, u8 userdata[16]);
487  int (*path_resume)(struct iucv_path *path, u8 userdata[16]);
488  int (*path_sever)(struct iucv_path *path, u8 userdata[16]);
491  struct bus_type *bus;
492  struct device *root;
493 };
494 
495 extern struct iucv_interface iucv_if;