diff options
| author | Sudeep Dutt <sudeep.dutt@intel.com> | 2015-04-29 08:32:28 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-05-24 15:13:36 -0400 |
| commit | 7df20f2d893db42eaa1ea1e30a2573c971ec9238 (patch) | |
| tree | 372f796f0c48006754facac07edda9ea390b88c7 /include | |
| parent | 0d09f1a54d9710548c9af72dc1564c8291a5307c (diff) | |
misc: mic: SCIF header file and IOCTL interface
This patch introduces the SCIF documentation in the header file
and describes the IOCTL interface for user mode. mic_overview.txt
is updated with documentation on SCIF and a new document
describing SCIF in more details is available in scif_overview.txt.
Reviewed-by: Nikhil Rao <nikhil.rao@intel.com>
Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Signed-off-by: Sudeep Dutt <sudeep.dutt@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/scif.h | 993 | ||||
| -rw-r--r-- | include/uapi/linux/Kbuild | 1 | ||||
| -rw-r--r-- | include/uapi/linux/scif_ioctl.h | 130 |
3 files changed, 1124 insertions, 0 deletions
diff --git a/include/linux/scif.h b/include/linux/scif.h new file mode 100644 index 000000000000..44f4f3898bbe --- /dev/null +++ b/include/linux/scif.h | |||
| @@ -0,0 +1,993 @@ | |||
| 1 | /* | ||
| 2 | * Intel MIC Platform Software Stack (MPSS) | ||
| 3 | * | ||
| 4 | * This file is provided under a dual BSD/GPLv2 license. When using or | ||
| 5 | * redistributing this file, you may do so under either license. | ||
| 6 | * | ||
| 7 | * GPL LICENSE SUMMARY | ||
| 8 | * | ||
| 9 | * Copyright(c) 2014 Intel Corporation. | ||
| 10 | * | ||
| 11 | * This program is free software; you can redistribute it and/or modify | ||
| 12 | * it under the terms of version 2 of the GNU General Public License as | ||
| 13 | * published by the Free Software Foundation. | ||
| 14 | * | ||
| 15 | * This program is distributed in the hope that it will be useful, but | ||
| 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 18 | * General Public License for more details. | ||
| 19 | * | ||
| 20 | * BSD LICENSE | ||
| 21 | * | ||
| 22 | * Copyright(c) 2014 Intel Corporation. | ||
| 23 | * | ||
| 24 | * Redistribution and use in source and binary forms, with or without | ||
| 25 | * modification, are permitted provided that the following conditions | ||
| 26 | * are met: | ||
| 27 | * | ||
| 28 | * * Redistributions of source code must retain the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer. | ||
| 30 | * * Redistributions in binary form must reproduce the above copyright | ||
| 31 | * notice, this list of conditions and the following disclaimer in | ||
| 32 | * the documentation and/or other materials provided with the | ||
| 33 | * distribution. | ||
| 34 | * * Neither the name of Intel Corporation nor the names of its | ||
| 35 | * contributors may be used to endorse or promote products derived | ||
| 36 | * from this software without specific prior written permission. | ||
| 37 | * | ||
| 38 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 39 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 40 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| 41 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| 42 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 43 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| 44 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| 45 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| 46 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| 47 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| 48 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 49 | * | ||
| 50 | * Intel SCIF driver. | ||
| 51 | * | ||
| 52 | */ | ||
| 53 | #ifndef __SCIF_H__ | ||
| 54 | #define __SCIF_H__ | ||
| 55 | |||
| 56 | #include <linux/types.h> | ||
| 57 | #include <linux/poll.h> | ||
| 58 | #include <linux/scif_ioctl.h> | ||
| 59 | |||
| 60 | #define SCIF_ACCEPT_SYNC 1 | ||
| 61 | #define SCIF_SEND_BLOCK 1 | ||
| 62 | #define SCIF_RECV_BLOCK 1 | ||
| 63 | |||
| 64 | enum { | ||
| 65 | SCIF_PROT_READ = (1 << 0), | ||
| 66 | SCIF_PROT_WRITE = (1 << 1) | ||
| 67 | }; | ||
| 68 | |||
| 69 | enum { | ||
| 70 | SCIF_MAP_FIXED = 0x10, | ||
| 71 | SCIF_MAP_KERNEL = 0x20, | ||
| 72 | }; | ||
| 73 | |||
| 74 | enum { | ||
| 75 | SCIF_FENCE_INIT_SELF = (1 << 0), | ||
| 76 | SCIF_FENCE_INIT_PEER = (1 << 1), | ||
| 77 | SCIF_SIGNAL_LOCAL = (1 << 4), | ||
| 78 | SCIF_SIGNAL_REMOTE = (1 << 5) | ||
| 79 | }; | ||
| 80 | |||
| 81 | enum { | ||
| 82 | SCIF_RMA_USECPU = (1 << 0), | ||
| 83 | SCIF_RMA_USECACHE = (1 << 1), | ||
| 84 | SCIF_RMA_SYNC = (1 << 2), | ||
| 85 | SCIF_RMA_ORDERED = (1 << 3) | ||
| 86 | }; | ||
| 87 | |||
| 88 | /* End of SCIF Admin Reserved Ports */ | ||
| 89 | #define SCIF_ADMIN_PORT_END 1024 | ||
| 90 | |||
| 91 | /* End of SCIF Reserved Ports */ | ||
| 92 | #define SCIF_PORT_RSVD 1088 | ||
| 93 | |||
| 94 | typedef struct scif_endpt *scif_epd_t; | ||
| 95 | |||
| 96 | #define SCIF_OPEN_FAILED ((scif_epd_t)-1) | ||
| 97 | #define SCIF_REGISTER_FAILED ((off_t)-1) | ||
| 98 | #define SCIF_MMAP_FAILED ((void *)-1) | ||
| 99 | |||
| 100 | /** | ||
| 101 | * scif_open() - Create an endpoint | ||
| 102 | * | ||
| 103 | * Return: | ||
| 104 | * Upon successful completion, scif_open() returns an endpoint descriptor to | ||
| 105 | * be used in subsequent SCIF functions calls to refer to that endpoint; | ||
| 106 | * otherwise in user mode SCIF_OPEN_FAILED (that is ((scif_epd_t)-1)) is | ||
| 107 | * returned and errno is set to indicate the error; in kernel mode a NULL | ||
| 108 | * scif_epd_t is returned. | ||
| 109 | * | ||
| 110 | * Errors: | ||
| 111 | * ENOMEM - Insufficient kernel memory was available | ||
| 112 | */ | ||
| 113 | scif_epd_t scif_open(void); | ||
| 114 | |||
| 115 | /** | ||
| 116 | * scif_bind() - Bind an endpoint to a port | ||
| 117 | * @epd: endpoint descriptor | ||
| 118 | * @pn: port number | ||
| 119 | * | ||
| 120 | * scif_bind() binds endpoint epd to port pn, where pn is a port number on the | ||
| 121 | * local node. If pn is zero, a port number greater than or equal to | ||
| 122 | * SCIF_PORT_RSVD is assigned and returned. Each endpoint may be bound to | ||
| 123 | * exactly one local port. Ports less than 1024 when requested can only be bound | ||
| 124 | * by system (or root) processes or by processes executed by privileged users. | ||
| 125 | * | ||
| 126 | * Return: | ||
| 127 | * Upon successful completion, scif_bind() returns the port number to which epd | ||
| 128 | * is bound; otherwise in user mode -1 is returned and errno is set to | ||
| 129 | * indicate the error; in kernel mode the negative of one of the following | ||
| 130 | * errors is returned. | ||
| 131 | * | ||
| 132 | * Errors: | ||
| 133 | * EBADF, ENOTTY - epd is not a valid endpoint descriptor | ||
| 134 | * EINVAL - the endpoint or the port is already bound | ||
| 135 | * EISCONN - The endpoint is already connected | ||
| 136 | * ENOSPC - No port number available for assignment | ||
| 137 | * EACCES - The port requested is protected and the user is not the superuser | ||
| 138 | */ | ||
| 139 | int scif_bind(scif_epd_t epd, u16 pn); | ||
| 140 | |||
| 141 | /** | ||
| 142 | * scif_listen() - Listen for connections on an endpoint | ||
| 143 | * @epd: endpoint descriptor | ||
| 144 | * @backlog: maximum pending connection requests | ||
| 145 | * | ||
| 146 | * scif_listen() marks the endpoint epd as a listening endpoint - that is, as | ||
| 147 | * an endpoint that will be used to accept incoming connection requests. Once | ||
| 148 | * so marked, the endpoint is said to be in the listening state and may not be | ||
| 149 | * used as the endpoint of a connection. | ||
| 150 | * | ||
| 151 | * The endpoint, epd, must have been bound to a port. | ||
| 152 | * | ||
| 153 | * The backlog argument defines the maximum length to which the queue of | ||
| 154 | * pending connections for epd may grow. If a connection request arrives when | ||
| 155 | * the queue is full, the client may receive an error with an indication that | ||
| 156 | * the connection was refused. | ||
| 157 | * | ||
| 158 | * Return: | ||
| 159 | * Upon successful completion, scif_listen() returns 0; otherwise in user mode | ||
| 160 | * -1 is returned and errno is set to indicate the error; in kernel mode the | ||
| 161 | * negative of one of the following errors is returned. | ||
| 162 | * | ||
| 163 | * Errors: | ||
| 164 | * EBADF, ENOTTY - epd is not a valid endpoint descriptor | ||
| 165 | * EINVAL - the endpoint is not bound to a port | ||
| 166 | * EISCONN - The endpoint is already connected or listening | ||
| 167 | */ | ||
| 168 | int scif_listen(scif_epd_t epd, int backlog); | ||
| 169 | |||
| 170 | /** | ||
| 171 | * scif_connect() - Initiate a connection on a port | ||
| 172 | * @epd: endpoint descriptor | ||
| 173 | * @dst: global id of port to which to connect | ||
| 174 | * | ||
| 175 | * The scif_connect() function requests the connection of endpoint epd to remote | ||
| 176 | * port dst. If the connection is successful, a peer endpoint, bound to dst, is | ||
| 177 | * created on node dst.node. On successful return, the connection is complete. | ||
| 178 | * | ||
| 179 | * If the endpoint epd has not already been bound to a port, scif_connect() | ||
| 180 | * will bind it to an unused local port. | ||
| 181 | * | ||
| 182 | * A connection is terminated when an endpoint of the connection is closed, | ||
| 183 | * either explicitly by scif_close(), or when a process that owns one of the | ||
| 184 | * endpoints of the connection is terminated. | ||
| 185 | * | ||
| 186 | * In user space, scif_connect() supports an asynchronous connection mode | ||
| 187 | * if the application has set the O_NONBLOCK flag on the endpoint via the | ||
| 188 | * fcntl() system call. Setting this flag will result in the calling process | ||
| 189 | * not to wait during scif_connect(). | ||
| 190 | * | ||
| 191 | * Return: | ||
| 192 | * Upon successful completion, scif_connect() returns the port ID to which the | ||
| 193 | * endpoint, epd, is bound; otherwise in user mode -1 is returned and errno is | ||
| 194 | * set to indicate the error; in kernel mode the negative of one of the | ||
| 195 | * following errors is returned. | ||
| 196 | * | ||
| 197 | * Errors: | ||
| 198 | * EBADF, ENOTTY - epd is not a valid endpoint descriptor | ||
| 199 | * ECONNREFUSED - The destination was not listening for connections or refused | ||
| 200 | * the connection request | ||
| 201 | * EINVAL - dst.port is not a valid port ID | ||
| 202 | * EISCONN - The endpoint is already connected | ||
| 203 | * ENOMEM - No buffer space is available | ||
| 204 | * ENODEV - The destination node does not exist, or the node is lost or existed, | ||
| 205 | * but is not currently in the network since it may have crashed | ||
| 206 | * ENOSPC - No port number available for assignment | ||
| 207 | * EOPNOTSUPP - The endpoint is listening and cannot be connected | ||
| 208 | */ | ||
| 209 | int scif_connect(scif_epd_t epd, struct scif_port_id *dst); | ||
| 210 | |||
| < | |||
