Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  *  drivers/s390/net/iucv.h
0004  *    IUCV base support.
0005  *
0006  *  S390 version
0007  *    Copyright 2000, 2006 IBM Corporation
0008  *    Author(s):Alan Altmark (Alan_Altmark@us.ibm.com)
0009  *      Xenia Tkatschow (xenia@us.ibm.com)
0010  *    Rewritten for af_iucv:
0011  *  Martin Schwidefsky <schwidefsky@de.ibm.com>
0012  *
0013  *
0014  * Functionality:
0015  * To explore any of the IUCV functions, one must first register their
0016  * program using iucv_register(). Once your program has successfully
0017  * completed a register, it can exploit the other functions.
0018  * For furthur reference on all IUCV functionality, refer to the
0019  * CP Programming Services book, also available on the web thru
0020  * www.vm.ibm.com/pubs, manual # SC24-6084
0021  *
0022  * Definition of Return Codes
0023  * - All positive return codes including zero are reflected back
0024  *   from CP. The definition of each return code can be found in
0025  *   CP Programming Services book.
0026  * - Return Code of:
0027  *   -EINVAL: Invalid value
0028  *   -ENOMEM: storage allocation failed
0029  */
0030 
0031 #include <linux/types.h>
0032 #include <linux/slab.h>
0033 #include <asm/debug.h>
0034 
0035 /*
0036  * IUCV option flags usable by device drivers:
0037  *
0038  * IUCV_IPRMDATA  Indicates that your program can handle a message in the
0039  *        parameter list / a message is sent in the parameter list.
0040  *        Used for iucv_path_accept, iucv_path_connect,
0041  *        iucv_message_reply, iucv_message_send, iucv_message_send2way.
0042  * IUCV_IPQUSCE   Indicates that you do not want to receive messages on this
0043  *        path until an iucv_path_resume is issued.
0044  *        Used for iucv_path_accept, iucv_path_connect.
0045  * IUCV_IPBUFLST  Indicates that an address list is used for the message data.
0046  *        Used for iucv_message_receive, iucv_message_send,
0047  *        iucv_message_send2way.
0048  * IUCV_IPPRTY    Specifies that you want to send priority messages.
0049  *        Used for iucv_path_accept, iucv_path_connect,
0050  *        iucv_message_reply, iucv_message_send, iucv_message_send2way.
0051  * IUCV_IPSYNC    Indicates a synchronous send request.
0052  *        Used for iucv_message_send, iucv_message_send2way.
0053  * IUCV_IPANSLST  Indicates that an address list is used for the reply data.
0054  *        Used for iucv_message_reply, iucv_message_send2way.
0055  * IUCV_IPLOCAL   Specifies that the communication partner has to be on the
0056  *        local system. If local is specified no target class can be
0057  *        specified.
0058  *        Used for iucv_path_connect.
0059  *
0060  * All flags are defined in the input field IPFLAGS1 of each function
0061  * and can be found in CP Programming Services.
0062  */
0063 #define IUCV_IPRMDATA   0x80
0064 #define IUCV_IPQUSCE    0x40
0065 #define IUCV_IPBUFLST   0x40
0066 #define IUCV_IPPRTY 0x20
0067 #define IUCV_IPANSLST   0x08
0068 #define IUCV_IPSYNC 0x04
0069 #define IUCV_IPLOCAL    0x01
0070 
0071 /*
0072  * iucv_array : Defines buffer array.
0073  * Inside the array may be 31- bit addresses and 31-bit lengths.
0074  * Use a pointer to an iucv_array as the buffer, reply or answer
0075  * parameter on iucv_message_send, iucv_message_send2way, iucv_message_receive
0076  * and iucv_message_reply if IUCV_IPBUFLST or IUCV_IPANSLST are used.
0077  */
0078 struct iucv_array {
0079     u32 address;
0080     u32 length;
0081 } __attribute__ ((aligned (8)));
0082 
0083 extern struct bus_type iucv_bus;
0084 extern struct device *iucv_root;
0085 
0086 /*
0087  * struct iucv_path
0088  * pathid: 16 bit path identification
0089  * msglim: 16 bit message limit
0090  * flags: properties of the path: IPRMDATA, IPQUSCE, IPPRTY
0091  * handler:  address of iucv handler structure
0092  * private: private information of the handler associated with the path
0093  * list: list_head for the iucv_handler path list.
0094  */
0095 struct iucv_path {
0096     u16 pathid;
0097     u16 msglim;
0098     u8  flags;
0099     void *private;
0100     struct iucv_handler *handler;
0101     struct list_head list;
0102 };
0103 
0104 /*
0105  * struct iucv_message
0106  * id: 32 bit message id
0107  * audit: 32 bit error information of purged or replied messages
0108  * class: 32 bit target class of a message (source class for replies)
0109  * tag: 32 bit tag to be associated with the message
0110  * length: 32 bit length of the message / reply
0111  * reply_size: 32 bit maximum allowed length of the reply
0112  * rmmsg: 8 byte inline message
0113  * flags: message properties (IUCV_IPPRTY)
0114  */
0115 struct iucv_message {
0116     u32 id;
0117     u32 audit;
0118     u32 class;
0119     u32 tag;
0120     u32 length;
0121     u32 reply_size;
0122     u8  rmmsg[8];
0123     u8  flags;
0124 } __packed;
0125 
0126 /*
0127  * struct iucv_handler
0128  *
0129  * A vector of functions that handle IUCV interrupts. Each functions gets
0130  * a parameter area as defined by the CP Programming Services and private
0131  * pointer that is provided by the user of the interface.
0132  */
0133 struct iucv_handler {
0134      /*
0135       * The path_pending function is called after an iucv interrupt
0136       * type 0x01 has been received. The base code allocates a path
0137       * structure and "asks" the handler if this path belongs to the
0138       * handler. To accept the path the path_pending function needs
0139       * to call iucv_path_accept and return 0. If the callback returns
0140       * a value != 0 the iucv base code will continue with the next
0141       * handler. The order in which the path_pending functions are
0142       * called is the order of the registration of the iucv handlers
0143       * to the base code.
0144       */
0145     int  (*path_pending)(struct iucv_path *, u8 *ipvmid, u8 *ipuser);
0146     /*
0147      * The path_complete function is called after an iucv interrupt
0148      * type 0x02 has been received for a path that has been established
0149      * for this handler with iucv_path_connect and got accepted by the
0150      * peer with iucv_path_accept.
0151      */
0152     void (*path_complete)(struct iucv_path *, u8 *ipuser);
0153      /*
0154       * The path_severed function is called after an iucv interrupt
0155       * type 0x03 has been received. The communication peer shutdown
0156       * his end of the communication path. The path still exists and
0157       * remaining messages can be received until a iucv_path_sever
0158       * shuts down the other end of the path as well.
0159       */
0160     void (*path_severed)(struct iucv_path *, u8 *ipuser);
0161     /*
0162      * The path_quiesced function is called after an icuv interrupt
0163      * type 0x04 has been received. The communication peer has quiesced
0164      * the path. Delivery of messages is stopped until iucv_path_resume
0165      * has been called.
0166      */
0167     void (*path_quiesced)(struct iucv_path *, u8 *ipuser);
0168     /*
0169      * The path_resumed function is called after an icuv interrupt
0170      * type 0x05 has been received. The communication peer has resumed
0171      * the path.
0172      */
0173     void (*path_resumed)(struct iucv_path *, u8 *ipuser);
0174     /*
0175      * The message_pending function is called after an icuv interrupt
0176      * type 0x06 or type 0x07 has been received. A new message is
0177      * available and can be received with iucv_message_receive.
0178      */
0179     void (*message_pending)(struct iucv_path *, struct iucv_message *);
0180     /*
0181      * The message_complete function is called after an icuv interrupt
0182      * type 0x08 or type 0x09 has been received. A message send with
0183      * iucv_message_send2way has been replied to. The reply can be
0184      * received with iucv_message_receive.
0185      */
0186     void (*message_complete)(struct iucv_path *, struct iucv_message *);
0187 
0188     struct list_head list;
0189     struct list_head paths;
0190 };
0191 
0192 /**
0193  * iucv_register:
0194  * @handler: address of iucv handler structure
0195  * @smp: != 0 indicates that the handler can deal with out of order messages
0196  *
0197  * Registers a driver with IUCV.
0198  *
0199  * Returns 0 on success, -ENOMEM if the memory allocation for the pathid
0200  * table failed, or -EIO if IUCV_DECLARE_BUFFER failed on all cpus.
0201  */
0202 int iucv_register(struct iucv_handler *handler, int smp);
0203 
0204 /**
0205  * iucv_unregister
0206  * @handler:  address of iucv handler structure
0207  * @smp: != 0 indicates that the handler can deal with out of order messages
0208  *
0209  * Unregister driver from IUCV.
0210  */
0211 void iucv_unregister(struct iucv_handler *handle, int smp);
0212 
0213 /**
0214  * iucv_path_alloc
0215  * @msglim: initial message limit
0216  * @flags: initial flags
0217  * @gfp: kmalloc allocation flag
0218  *
0219  * Allocate a new path structure for use with iucv_connect.
0220  *
0221  * Returns NULL if the memory allocation failed or a pointer to the
0222  * path structure.
0223  */
0224 static inline struct iucv_path *iucv_path_alloc(u16 msglim, u8 flags, gfp_t gfp)
0225 {
0226     struct iucv_path *path;
0227 
0228     path = kzalloc(sizeof(struct iucv_path), gfp);
0229     if (path) {
0230         path->msglim = msglim;
0231         path->flags = flags;
0232     }
0233     return path;
0234 }
0235 
0236 /**
0237  * iucv_path_free
0238  * @path: address of iucv path structure
0239  *
0240  * Frees a path structure.
0241  */
0242 static inline void iucv_path_free(struct iucv_path *path)
0243 {
0244     kfree(path);
0245 }
0246 
0247 /**
0248  * iucv_path_accept
0249  * @path: address of iucv path structure
0250  * @handler: address of iucv handler structure
0251  * @userdata: 16 bytes of data reflected to the communication partner
0252  * @private: private data passed to interrupt handlers for this path
0253  *
0254  * This function is issued after the user received a connection pending
0255  * external interrupt and now wishes to complete the IUCV communication path.
0256  *
0257  * Returns the result of the CP IUCV call.
0258  */
0259 int iucv_path_accept(struct iucv_path *path, struct iucv_handler *handler,
0260              u8 *userdata, void *private);
0261 
0262 /**
0263  * iucv_path_connect
0264  * @path: address of iucv path structure
0265  * @handler: address of iucv handler structure
0266  * @userid: 8-byte user identification
0267  * @system: 8-byte target system identification
0268  * @userdata: 16 bytes of data reflected to the communication partner
0269  * @private: private data passed to interrupt handlers for this path
0270  *
0271  * This function establishes an IUCV path. Although the connect may complete
0272  * successfully, you are not able to use the path until you receive an IUCV
0273  * Connection Complete external interrupt.
0274  *
0275  * Returns the result of the CP IUCV call.
0276  */
0277 int iucv_path_connect(struct iucv_path *path, struct iucv_handler *handler,
0278               u8 *userid, u8 *system, u8 *userdata,
0279               void *private);
0280 
0281 /**
0282  * iucv_path_quiesce:
0283  * @path: address of iucv path structure
0284  * @userdata: 16 bytes of data reflected to the communication partner
0285  *
0286  * This function temporarily suspends incoming messages on an IUCV path.
0287  * You can later reactivate the path by invoking the iucv_resume function.
0288  *
0289  * Returns the result from the CP IUCV call.
0290  */
0291 int iucv_path_quiesce(struct iucv_path *path, u8 *userdata);
0292 
0293 /**
0294  * iucv_path_resume:
0295  * @path: address of iucv path structure
0296  * @userdata: 16 bytes of data reflected to the communication partner
0297  *
0298  * This function resumes incoming messages on an IUCV path that has
0299  * been stopped with iucv_path_quiesce.
0300  *
0301  * Returns the result from the CP IUCV call.
0302  */
0303 int iucv_path_resume(struct iucv_path *path, u8 *userdata);
0304 
0305 /**
0306  * iucv_path_sever
0307  * @path: address of iucv path structure
0308  * @userdata: 16 bytes of data reflected to the communication partner
0309  *
0310  * This function terminates an IUCV path.
0311  *
0312  * Returns the result from the CP IUCV call.
0313  */
0314 int iucv_path_sever(struct iucv_path *path, u8 *userdata);
0315 
0316 /**
0317  * iucv_message_purge
0318  * @path: address of iucv path structure
0319  * @msg: address of iucv msg structure
0320  * @srccls: source class of message
0321  *
0322  * Cancels a message you have sent.
0323  *
0324  * Returns the result from the CP IUCV call.
0325  */
0326 int iucv_message_purge(struct iucv_path *path, struct iucv_message *msg,
0327                u32 srccls);
0328 
0329 /**
0330  * iucv_message_receive
0331  * @path: address of iucv path structure
0332  * @msg: address of iucv msg structure
0333  * @flags: flags that affect how the message is received (IUCV_IPBUFLST)
0334  * @buffer: address of data buffer or address of struct iucv_array
0335  * @size: length of data buffer
0336  * @residual:
0337  *
0338  * This function receives messages that are being sent to you over
0339  * established paths. This function will deal with RMDATA messages
0340  * embedded in struct iucv_message as well.
0341  *
0342  * Locking: local_bh_enable/local_bh_disable
0343  *
0344  * Returns the result from the CP IUCV call.
0345  */
0346 int iucv_message_receive(struct iucv_path *path, struct iucv_message *msg,
0347              u8 flags, void *buffer, size_t size, size_t *residual);
0348 
0349 /**
0350  * __iucv_message_receive
0351  * @path: address of iucv path structure
0352  * @msg: address of iucv msg structure
0353  * @flags: flags that affect how the message is received (IUCV_IPBUFLST)
0354  * @buffer: address of data buffer or address of struct iucv_array
0355  * @size: length of data buffer
0356  * @residual:
0357  *
0358  * This function receives messages that are being sent to you over
0359  * established paths. This function will deal with RMDATA messages
0360  * embedded in struct iucv_message as well.
0361  *
0362  * Locking: no locking.
0363  *
0364  * Returns the result from the CP IUCV call.
0365  */
0366 int __iucv_message_receive(struct iucv_path *path, struct iucv_message *msg,
0367                u8 flags, void *buffer, size_t size,
0368                size_t *residual);
0369 
0370 /**
0371  * iucv_message_reject
0372  * @path: address of iucv path structure
0373  * @msg: address of iucv msg structure
0374  *
0375  * The reject function refuses a specified message. Between the time you
0376  * are notified of a message and the time that you complete the message,
0377  * the message may be rejected.
0378  *
0379  * Returns the result from the CP IUCV call.
0380  */
0381 int iucv_message_reject(struct iucv_path *path, struct iucv_message *msg);
0382 
0383 /**
0384  * iucv_message_reply
0385  * @path: address of iucv path structure
0386  * @msg: address of iucv msg structure
0387  * @flags: how the reply is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
0388  * @reply: address of data buffer or address of struct iucv_array
0389  * @size: length of reply data buffer
0390  *
0391  * This function responds to the two-way messages that you receive. You
0392  * must identify completely the message to which you wish to reply. ie,
0393  * pathid, msgid, and trgcls. Prmmsg signifies the data is moved into
0394  * the parameter list.
0395  *
0396  * Returns the result from the CP IUCV call.
0397  */
0398 int iucv_message_reply(struct iucv_path *path, struct iucv_message *msg,
0399                u8 flags, void *reply, size_t size);
0400 
0401 /**
0402  * iucv_message_send
0403  * @path: address of iucv path structure
0404  * @msg: address of iucv msg structure
0405  * @flags: how the message is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
0406  * @srccls: source class of message
0407  * @buffer: address of data buffer or address of struct iucv_array
0408  * @size: length of send buffer
0409  *
0410  * This function transmits data to another application. Data to be
0411  * transmitted is in a buffer and this is a one-way message and the
0412  * receiver will not reply to the message.
0413  *
0414  * Locking: local_bh_enable/local_bh_disable
0415  *
0416  * Returns the result from the CP IUCV call.
0417  */
0418 int iucv_message_send(struct iucv_path *path, struct iucv_message *msg,
0419               u8 flags, u32 srccls, void *buffer, size_t size);
0420 
0421 /**
0422  * __iucv_message_send
0423  * @path: address of iucv path structure
0424  * @msg: address of iucv msg structure
0425  * @flags: how the message is sent (IUCV_IPRMDATA, IUCV_IPPRTY, IUCV_IPBUFLST)
0426  * @srccls: source class of message
0427  * @buffer: address of data buffer or address of struct iucv_array
0428  * @size: length of send buffer
0429  *
0430  * This function transmits data to another application. Data to be
0431  * transmitted is in a buffer and this is a one-way message and the
0432  * receiver will not reply to the message.
0433  *
0434  * Locking: no locking.
0435  *
0436  * Returns the result from the CP IUCV call.
0437  */
0438 int __iucv_message_send(struct iucv_path *path, struct iucv_message *msg,
0439             u8 flags, u32 srccls, void *buffer, size_t size);
0440 
0441 /**
0442  * iucv_message_send2way
0443  * @path: address of iucv path structure
0444  * @msg: address of iucv msg structure
0445  * @flags: how the message is sent and the reply is received
0446  *     (IUCV_IPRMDATA, IUCV_IPBUFLST, IUCV_IPPRTY, IUCV_ANSLST)
0447  * @srccls: source class of message
0448  * @buffer: address of data buffer or address of struct iucv_array
0449  * @size: length of send buffer
0450  * @ansbuf: address of answer buffer or address of struct iucv_array
0451  * @asize: size of reply buffer
0452  *
0453  * This function transmits data to another application. Data to be
0454  * transmitted is in a buffer. The receiver of the send is expected to
0455  * reply to the message and a buffer is provided into which IUCV moves
0456  * the reply to this message.
0457  *
0458  * Returns the result from the CP IUCV call.
0459  */
0460 int iucv_message_send2way(struct iucv_path *path, struct iucv_message *msg,
0461               u8 flags, u32 srccls, void *buffer, size_t size,
0462               void *answer, size_t asize, size_t *residual);
0463 
0464 struct iucv_interface {
0465     int (*message_receive)(struct iucv_path *path, struct iucv_message *msg,
0466         u8 flags, void *buffer, size_t size, size_t *residual);
0467     int (*__message_receive)(struct iucv_path *path,
0468         struct iucv_message *msg, u8 flags, void *buffer, size_t size,
0469         size_t *residual);
0470     int (*message_reply)(struct iucv_path *path, struct iucv_message *msg,
0471         u8 flags, void *reply, size_t size);
0472     int (*message_reject)(struct iucv_path *path, struct iucv_message *msg);
0473     int (*message_send)(struct iucv_path *path, struct iucv_message *msg,
0474         u8 flags, u32 srccls, void *buffer, size_t size);
0475     int (*__message_send)(struct iucv_path *path, struct iucv_message *msg,
0476         u8 flags, u32 srccls, void *buffer, size_t size);
0477     int (*message_send2way)(struct iucv_path *path,
0478         struct iucv_message *msg, u8 flags, u32 srccls, void *buffer,
0479         size_t size, void *answer, size_t asize, size_t *residual);
0480     int (*message_purge)(struct iucv_path *path, struct iucv_message *msg,
0481         u32 srccls);
0482     int (*path_accept)(struct iucv_path *path, struct iucv_handler *handler,
0483         u8 userdata[16], void *private);
0484     int (*path_connect)(struct iucv_path *path,
0485         struct iucv_handler *handler,
0486         u8 userid[8], u8 system[8], u8 userdata[16], void *private);
0487     int (*path_quiesce)(struct iucv_path *path, u8 userdata[16]);
0488     int (*path_resume)(struct iucv_path *path, u8 userdata[16]);
0489     int (*path_sever)(struct iucv_path *path, u8 userdata[16]);
0490     int (*iucv_register)(struct iucv_handler *handler, int smp);
0491     void (*iucv_unregister)(struct iucv_handler *handler, int smp);
0492     struct bus_type *bus;
0493     struct device *root;
0494 };
0495 
0496 extern struct iucv_interface iucv_if;