iucv.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  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 (Alan_Altmark@us.ibm.com)
  8. * Xenia Tkatschow (xenia@us.ibm.com)
  9. * Rewritten for af_iucv:
  10. * Martin Schwidefsky <schwidefsky@de.ibm.com>
  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. #include <linux/types.h>
  30. #include <asm/debug.h>
  31. /*
  32. * IUCV option flags usable by device drivers:
  33. *
  34. * IUCV_IPRMDATA Indicates that your program can handle a message in the
  35. * parameter list / a message is sent in the parameter list.
  36. * Used for iucv_path_accept, iucv_path_connect,
  37. * iucv_message_reply, iucv_message_send, iucv_message_send2way.
  38. * IUCV_IPQUSCE Indicates that you do not want to receive messages on this
  39. * path until an iucv_path_resume is issued.
  40. * Used for iucv_path_accept, iucv_path_connect.
  41. * IUCV_IPBUFLST Indicates that an address list is used for the message data.
  42. * Used for iucv_message_receive, iucv_message_send,
  43. * iucv_message_send2way.
  44. * IUCV_IPPRTY Specifies that you want to send priority messages.
  45. * Used for iucv_path_accept, iucv_path_connect,
  46. * iucv_message_reply, iucv_message_send, iucv_message_send2way.
  47. * IUCV_IPSYNC Indicates a synchronous send request.
  48. * Used for iucv_message_send, iucv_message_send2way.
  49. * IUCV_IPANSLST Indicates that an address list is used for the reply data.
  50. * Used for iucv_message_reply, iucv_message_send2way.
  51. * IUCV_IPLOCAL Specifies that the communication partner has to be on the
  52. * local system. If local is specified no target class can be
  53. * specified.
  54. * Used for iucv_path_connect.
  55. *
  56. * All flags are defined in the input field IPFLAGS1 of each function
  57. * and can be found in CP Programming Services.
  58. */
  59. #define IUCV_IPRMDATA 0x80
  60. #define IUCV_IPQUSCE 0x40
  61. #define IUCV_IPBUFLST 0x40
  62. #define IUCV_IPPRTY 0x20
  63. #define IUCV_IPANSLST 0x08
  64. #define IUCV_IPSYNC 0x04
  65. #define IUCV_IPLOCAL 0x01
  66. /*
  67. * iucv_array : Defines buffer array.
  68. * Inside the array may be 31- bit addresses and 31-bit lengths.
  69. * Use a pointer to an iucv_array as the buffer, reply or answer
  70. * parameter on iucv_message_send, iucv_message_send2way, iucv_message_receive
  71. * and iucv_message_reply if IUCV_IPBUFLST or IUCV_IPANSLST are used.
  72. */
  73. struct iucv_array {
  74. u32 address;
  75. u32 length;
  76. } __attribute__ ((aligned (8)));
  77. extern struct bus_type iucv_bus;
  78. extern struct device *iucv_root;
  79. /*
  80. * struct iucv_path
  81. * pathid: 16 bit path identification
  82. * msglim: 16 bit message limit
  83. * flags: properties of the path: IPRMDATA, IPQUSCE, IPPRTY
  84. * handler: address of iucv handler structure
  85. * private: private information of the handler associated with the path
  86. * list: list_head for the iucv_handler path list.
  87. */
  88. struct iucv_path {
  89. u16 pathid;
  90. u16 msglim;
  91. u8 flags;
  92. void *private;
  93. struct iucv_handler *handler;
  94. struct list_head list;
  95. };
  96. /*
  97. * struct iucv_message
  98. * id: 32 bit message id
  99. * audit: 32 bit error information of purged or replied messages
  100. * class: 32 bit target class of a message (source class for replies)
  101. * tag: 32 bit tag to be associated with the message
  102. * length: 32 bit length of the message / reply
  103. * reply_size: 32 bit maximum allowed length of the reply
  104. * rmmsg: 8 byte inline message
  105. * flags: message properties (IUCV_IPPRTY)
  106. */
  107. struct iucv_message {
  108. u32 id;
  109. u32 audit;
  110. u32 class;
  111. u32 tag;
  112. u32 length;
  113. u32 reply_size;
  114. u8 rmmsg[8];
  115. u8 flags;
  116. };
  117. /*
  118. * struct iucv_handler
  119. *
  120. * A vector of functions that handle IUCV interrupts. Each functions gets
  121. * a parameter area as defined by the CP Programming Services and private
  122. * pointer that is provided by the user of the interface.
  123. */
  124. struct iucv_handler {
  125. /*
  126. * The path_pending function is called after an iucv interrupt
  127. * type 0x01 has been received. The base code allocates a path
  128. * structure and "asks" the handler if this path belongs to the
  129. * handler. To accept the path the path_pending function needs
  130. * to call iucv_path_accept and return 0. If the callback returns
  131. * a value != 0 the iucv base code will continue with the next
  132. * handler. The order in which the path_pending functions are
  133. * called is the order of the registration of the iucv handlers
  134. * to the base code.
  135. */
  136. int (*path_pending)(struct iucv_path *, u8 ipvmid[8], u8 ipuser[16]);
  137. /*
  138. * The path_complete function is called after an iucv interrupt
  139. * type 0x02 has been received for a path that has been established
  140. * for this handler with iucv_path_connect and got accepted by the
  141. * peer with iucv_path_accept.
  142. */
  143. void (*path_complete)(struct iucv_path *, u8 ipuser[16]);
  144. /*
  145. * The path_severed function is called after an iucv interrupt
  146. * type 0x03 has been received. The communication peer shutdown
  147. * his end of the communication path. The path still exists and
  148. * remaining messages can be received until a iucv_path_sever
  149. * shuts down the other end of the path as well.
  150. */
  151. void (*path_severed)(struct iucv_path *, u8 ipuser[16]);
  152. /*
  153. * The path_quiesced function is called after an icuv interrupt
  154. * type 0x04 has been received. The communication peer has quiesced
  155. * the path. Delivery of messages is stopped until iucv_path_resume
  156. * has been called.
  157. */
  158. void (*path_quiesced)(struct iucv_path *, u8 ipuser[16]);
  159. /*
  160. * The path_resumed function is called after an icuv interrupt
  161. * type 0x05 has been received. The communication peer has resumed
  162. * the path.
  163. */
  164. void (*path_resumed)(struct iucv_path *, u8 ipuser[16]);
  165. /*
  166. * The message_pending function is called after an icuv interrupt
  167. * type 0x06 or type 0x07 has been received. A new message is
  168. * availabe and can be received with iucv_message_receive.
  169. */
  170. void (*message_pending)(struct iucv_path *, struct iucv_message *);
  171. /*
  172. * The message_complete function is called after an icuv interrupt
  173. * type 0x08 or type 0x09 has been received. A message send with
  174. * iucv_message_send2way has been replied to. The reply can be
  175. * received with iucv_message_receive.
  176. */
  177. void (*message_complete)(struct iucv_path *, struct iucv_message *);
  178. struct list_head list;
  179. struct list_head paths;
  180. };
  181. /**
  182. * iucv_register:
  183. * @handler: address of iucv handler structure
  184. * @smp: != 0 indicates that the handler can deal with out of order messages
  185. *
  186. * Registers a driver with IUCV.
  187. *
  188. * Returns 0 on success, -ENOMEM if the memory allocation for the pathid
  189. * table failed, or -EIO if IUCV_DECLARE_BUFFER failed on all cpus.
  190. */
  191. int iucv_register(struct iucv_handler *handler, int smp);
  192. /**
  193. * iucv_unregister
  194. * @handler: address of iucv handler structure
  195. * @smp: != 0 indicates that the handler can deal with out of order messages
  196. *
  197. * Unregister driver from IUCV.
  198. */
  199. void iucv_unregister(struct iucv_handler *handle, int smp);
  200. /**
  201. * iucv_path_alloc
  202. * @msglim: initial message limit
  203. * @flags: initial flags
  204. * @gfp: kmalloc allocation flag
  205. *
  206. * Allocate a new path structure for use with iucv_connect.
  207. *
  208. * Returns NULL if the memory allocation failed or a pointer to the
  209. * path structure.
  210. */
  211. static inline struct iucv_path *iucv_path_alloc(u16 msglim, u8 flags, gfp_t gfp)
  212. {
  213. struct iucv_path *path;
  214. path = kzalloc(sizeof(struct iucv_path), gfp);
  215. if (path) {
  216. path->msglim = msglim;
  217. path->flags = flags;
  218. }
  219. return path;
  220. }
  221. /**
  222. * iucv_path_free
  223. * @path: address of iucv path structure
  224. *
  225. * Frees a path structure.
  226. */
  227. static inline void iucv_path_free(struct iucv_path *path)
  228. {
  229. kfree(path);
  230. }
  231. /**
  232. * iucv_path_accept
  233. * @path: address of iucv path structure
  234. * @handler: address of iucv handler structure
  235. * @userdata: 16 bytes of data reflected to the communication partner
  236. * @private: private data passed to interrupt handlers for this path
  237. *
  238. * This function is issued after the user received a connection pending
  239. * external interrupt and now wishes to complete the IUCV communication path.
  240. *
  241. * Returns the result of the CP IUCV call.
  242. */
  243. int iucv_path_accept(struct iucv_path *path, struct iucv_handler *handler,
  244. u8 userdata[16], void *private);
  245. /**
  246. * iucv_path_connect
  247. * @path: address of iucv path structure
  248. * @handler: address of iucv handler structure
  249. * @userid: 8-byte user identification
  250. * @system: 8-byte target system identification
  251. * @userdata: 16 bytes of data reflected to the communication partner
  252. * @private: private data passed to interrupt handlers for this path
  253. *
  254. * This function establishes an IUCV path. Although the connect may complete
  255. * successfully, you are not able to use the path until you receive an IUCV
  256. * Connection Complete external interrupt.
  257. *
  258. * Returns the result of the CP IUCV call.
  259. */
  260. int iucv_path_connect(struct iucv_path *path, struct iucv_handler *handler,
  261. u8 userid[8], u8 system[8], u8 userdata[16],
  262. void *private);
  263. /**
  264. * iucv_path_quiesce:
  265. * @path: address of iucv path structure
  266. * @userdata: 16 bytes of data reflected to the communication partner
  267. *
  268. * This function temporarily suspends incoming messages on an IUCV path.
  269. * You can later reactivate the path by invoking the iucv_resume function.
  270. *
  271. * Returns the result from the CP IUCV call.
  272. */
  273. int iucv_path_quiesce(struct iucv_path *path, u8 userdata[16]);
  274. /**
  275. * iucv_path_resume:
  276. * @path: address of iucv path structure
  277. * @userdata: 16 bytes of data reflected to the communication partner
  278. *
  279. * This function resumes incoming messages on an IUCV path that has
  280. * been stopped with iucv_path_quiesce.
  281. *
  282. * Returns the result from the CP IUCV call.
  283. */
  284. int iucv_path_resume(struct iucv_path *path, u8 userdata[16]);
  285. /**
  286. * iucv_path_sever
  287. * @path: address of iucv path structure
  288. * @userdata: 16 bytes of data reflected to the communication partner
  289. *
  290. * This function terminates an IUCV path.
  291. *
  292. * Returns the result from the CP IUCV call.
  293. */
  294. int iucv_path_sever(struct iucv_path *path, u8 userdata[16]);
  295. /**
  296. * iucv_message_purge
  297. * @path: address of iucv path structure
  298. * @msg: address of iucv msg structure
  299. * @srccls: source class of message
  300. *
  301. * Cancels a message you have sent.
  302. *
  303. * Returns the result from the CP IUCV call.
  304. */
  305. int iucv_message_purge(struct iucv_path *path, struct iucv_message *msg,
  306. u32 srccls);
  307. /**
  308. * iucv_message_receive
  309. * @path: address of iucv path structure
  310. * @msg: address of iucv msg structure
  311. * @flags: flags that affect how the message is received (IUCV_IPBUFLST)
  312. * @buffer: address of data buffer or address of struct iucv_array
  313. * @size: length of data buffer
  314. * @residual:
  315. *
  316. * This function receives messages that are being sent to you over
  317. * established paths. This function will deal with RMDATA messages
  318. * embedded in struct iucv_message as well.
  319. *
  320. * Locking: local_bh_enable/local_bh_disable
  321. *
  322. * Returns the result from the CP IUCV call.
  323. */
  324. int iucv_message_receive(struct iucv_path *path, struct iucv_message *msg,
  325. u8 flags, void *buffer, size_t size, size_t *residual);
  326. /**
  327. * __iucv_message_receive
  328. * @path: address of iucv path structure
  329. * @msg: address of iucv msg structure
  330. * @flags: flags that affect how the message is received (IUCV_IPBUFLST)
  331. * @buffer: address of data buffer or address of struct iucv_array
  332. * @size: length of data buffer
  333. * @residual:
  334. *
  335. * This function receives messages that are being sent to you over
  336. * established paths. This function will deal with RMDATA messages
  337. * embedded in struct iucv_message as well.
  338. *
  339. * Locking: no locking.
  340. *
  341. * Returns the result from the CP IUCV call.
  342. */
  343. int __iucv_message_receive(struct iucv_path *path, struct iucv_message *msg,
  344. u8 flags, void *buffer, size_t size,
  345. size_t *residual);
  346. /**
  347. * iucv_message_reject
  348. * @path: address of iucv path structure
  349. * @msg: address of iucv msg structure
  350. *
  351. * The reject function refuses a specified message. Between the time you
  352. * are notified of a message and the time that you complete the message,
  353. * the message may be rejected.
  354. *
  355. * Returns the result from the CP IUCV call.
  356. */
  357. int iucv_message_reject(struct iucv_path *path, struct iucv_message *msg);
  358. /**
  359. * iucv_message_reply
  360. * @path: address of iucv path structure
  361. * @msg: address of iucv msg structure
  362. * @flags: how the reply is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
  363. * @reply: address of data buffer or address of struct iucv_array
  364. * @size: length of reply data buffer
  365. *
  366. * This function responds to the two-way messages that you receive. You
  367. * must identify completely the message to which you wish to reply. ie,
  368. * pathid, msgid, and trgcls. Prmmsg signifies the data is moved into
  369. * the parameter list.
  370. *
  371. * Returns the result from the CP IUCV call.
  372. */
  373. int iucv_message_reply(struct iucv_path *path, struct iucv_message *msg,
  374. u8 flags, void *reply, size_t size);
  375. /**
  376. * iucv_message_send
  377. * @path: address of iucv path structure
  378. * @msg: address of iucv msg structure
  379. * @flags: how the message is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
  380. * @srccls: source class of message
  381. * @buffer: address of data buffer or address of struct iucv_array
  382. * @size: length of send buffer
  383. *
  384. * This function transmits data to another application. Data to be
  385. * transmitted is in a buffer and this is a one-way message and the
  386. * receiver will not reply to the message.
  387. *
  388. * Locking: local_bh_enable/local_bh_disable
  389. *
  390. * Returns the result from the CP IUCV call.
  391. */
  392. int iucv_message_send(struct iucv_path *path, struct iucv_message *msg,
  393. u8 flags, u32 srccls, void *buffer, size_t size);
  394. /**
  395. * __iucv_message_send
  396. * @path: address of iucv path structure
  397. * @msg: address of iucv msg structure
  398. * @flags: how the message is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
  399. * @srccls: source class of message
  400. * @buffer: address of data buffer or address of struct iucv_array
  401. * @size: length of send buffer
  402. *
  403. * This function transmits data to another application. Data to be
  404. * transmitted is in a buffer and this is a one-way message and the
  405. * receiver will not reply to the message.
  406. *
  407. * Locking: no locking.
  408. *
  409. * Returns the result from the CP IUCV call.
  410. */
  411. int __iucv_message_send(struct iucv_path *path, struct iucv_message *msg,
  412. u8 flags, u32 srccls, void *buffer, size_t size);
  413. /**
  414. * iucv_message_send2way
  415. * @path: address of iucv path structure
  416. * @msg: address of iucv msg structure
  417. * @flags: how the message is sent and the reply is received
  418. * (IUCV_IPRMDATA, IUCV_IPBUFLST, IUCV_IPPRTY, IUCV_ANSLST)
  419. * @srccls: source class of message
  420. * @buffer: address of data buffer or address of struct iucv_array
  421. * @size: length of send buffer
  422. * @ansbuf: address of answer buffer or address of struct iucv_array
  423. * @asize: size of reply buffer
  424. *
  425. * This function transmits data to another application. Data to be
  426. * transmitted is in a buffer. The receiver of the send is expected to
  427. * reply to the message and a buffer is provided into which IUCV moves
  428. * the reply to this message.
  429. *
  430. * Returns the result from the CP IUCV call.
  431. */
  432. int iucv_message_send2way(struct iucv_path *path, struct iucv_message *msg,
  433. u8 flags, u32 srccls, void *buffer, size_t size,
  434. void *answer, size_t asize, size_t *residual);