Fix problems in uapi definitions reported by Gabriel Laskar: (see https://lkml.org/lkml/2016/4/5/205 for details) - move public header file rio_mport_cdev.h to include/uapi/linux directory - change types in data structures passed as IOCTL parameters - improve parameter checking in some IOCTL service routines
Showing the changes to include/linux (1 of 2 files). Show all
Unified · Split
| @@ -1,271 +0,0 @@ | ||
| 1 | −/* | |
| 2 | − * Copyright (c) 2015-2016, Integrated Device Technology Inc. | |
| 3 | − * Copyright (c) 2015, Prodrive Technologies | |
| 4 | − * Copyright (c) 2015, Texas Instruments Incorporated | |
| 5 | − * Copyright (c) 2015, RapidIO Trade Association | |
| 6 | − * All rights reserved. | |
| 7 | − * | |
| 8 | − * This software is available to you under a choice of one of two licenses. | |
| 9 | − * You may choose to be licensed under the terms of the GNU General Public | |
| 10 | − * License(GPL) Version 2, or the BSD-3 Clause license below: | |
| 11 | − * | |
| 12 | − * Redistribution and use in source and binary forms, with or without | |
| 13 | − * modification, are permitted provided that the following conditions are met: | |
| 14 | − * | |
| 15 | − * 1. Redistributions of source code must retain the above copyright notice, | |
| 16 | − * this list of conditions and the following disclaimer. | |
| 17 | − * | |
| 18 | − * 2. Redistributions in binary form must reproduce the above copyright notice, | |
| 19 | − * this list of conditions and the following disclaimer in the documentation | |
| 20 | − * and/or other materials provided with the distribution. | |
| 21 | − * | |
| 22 | − * 3. Neither the name of the copyright holder nor the names of its contributors | |
| 23 | − * may be used to endorse or promote products derived from this software without | |
| 24 | − * specific prior written permission. | |
| 25 | − * | |
| 26 | − * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
| 27 | − * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
| 28 | − * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 29 | − * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR | |
| 30 | − * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 31 | − * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 32 | − * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | |
| 33 | − * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
| 34 | − * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | |
| 35 | − * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
| 36 | − * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 37 | − */ | |
| 38 | − | |
| 39 | −#ifndef _RIO_MPORT_CDEV_H_ | |
| 40 | −#define _RIO_MPORT_CDEV_H_ | |
| 41 | − | |
| 42 | −#ifndef __user | |
| 43 | −#define __user | |
| 44 | −#endif | |
| 45 | − | |
| 46 | −struct rio_mport_maint_io { | |
| 47 | − uint32_t rioid; /* destID of remote device */ | |
| 48 | − uint32_t hopcount; /* hopcount to remote device */ | |
| 49 | − uint32_t offset; /* offset in register space */ | |
| 50 | − size_t length; /* length in bytes */ | |
| 51 | − void __user *buffer; /* data buffer */ | |
| 52 | −}; | |
| 53 | − | |
| 54 | −/* | |
| 55 | − * Definitions for RapidIO data transfers: | |
| 56 | − * - memory mapped (MAPPED) | |
| 57 | − * - packet generation from memory (TRANSFER) | |
| 58 | − */ | |
| 59 | −#define RIO_TRANSFER_MODE_MAPPED (1 << 0) | |
| 60 | −#define RIO_TRANSFER_MODE_TRANSFER (1 << 1) | |
| 61 | −#define RIO_CAP_DBL_SEND (1 << 2) | |
| 62 | −#define RIO_CAP_DBL_RECV (1 << 3) | |
| 63 | −#define RIO_CAP_PW_SEND (1 << 4) | |
| 64 | −#define RIO_CAP_PW_RECV (1 << 5) | |
| 65 | −#define RIO_CAP_MAP_OUTB (1 << 6) | |
| 66 | −#define RIO_CAP_MAP_INB (1 << 7) | |
| 67 | − | |
| 68 | −struct rio_mport_properties { | |
| 69 | − uint16_t hdid; | |
| 70 | − uint8_t id; /* Physical port ID */ | |
| 71 | − uint8_t index; | |
| 72 | − uint32_t flags; | |
| 73 | − uint32_t sys_size; /* Default addressing size */ | |
| 74 | − uint8_t port_ok; | |
| 75 | − uint8_t link_speed; | |
| 76 | − uint8_t link_width; | |
| 77 | − uint32_t dma_max_sge; | |
| 78 | − uint32_t dma_max_size; | |
| 79 | − uint32_t dma_align; | |
| 80 | − uint32_t transfer_mode; /* Default transfer mode */ | |
| 81 | − uint32_t cap_sys_size; /* Capable system sizes */ | |
| 82 | − uint32_t cap_addr_size; /* Capable addressing sizes */ | |
| 83 | − uint32_t cap_transfer_mode; /* Capable transfer modes */ | |
| 84 | − uint32_t cap_mport; /* Mport capabilities */ | |
| 85 | −}; | |
| 86 | − | |
| 87 | −/* | |
| 88 | − * Definitions for RapidIO events; | |
| 89 | − * - incoming port-writes | |
| 90 | − * - incoming doorbells | |
| 91 | − */ | |
| 92 | −#define RIO_DOORBELL (1 << 0) | |
| 93 | −#define RIO_PORTWRITE (1 << 1) | |
| 94 | − | |
| 95 | −struct rio_doorbell { | |
| 96 | − uint32_t rioid; | |
| 97 | − uint16_t payload; | |
| 98 | −}; | |
| 99 | − | |
| 100 | −struct rio_doorbell_filter { | |
| 101 | − uint32_t rioid; /* 0xffffffff to match all ids */ | |
| 102 | − uint16_t low; | |
| 103 | − uint16_t high; | |
| 104 | −}; | |
| 105 | − | |
| 106 | − | |
| 107 | −struct rio_portwrite { | |
| 108 | − uint32_t payload[16]; | |
| 109 | −}; | |
| 110 | − | |
| 111 | −struct rio_pw_filter { | |
| 112 | − uint32_t mask; | |
| 113 | − uint32_t low; | |
| 114 | − uint32_t high; | |
| 115 | −}; | |
| 116 | − | |
| 117 | −/* RapidIO base address for inbound requests set to value defined below | |
| 118 | − * indicates that no specific RIO-to-local address translation is requested | |
| 119 | − * and driver should use direct (one-to-one) address mapping. | |
| 120 | −*/ | |
| 121 | −#define RIO_MAP_ANY_ADDR (uint64_t)(~((uint64_t) 0)) | |
| 122 | − | |
| 123 | −struct rio_mmap { | |
| 124 | − uint32_t rioid; | |
| 125 | − uint64_t rio_addr; | |
| 126 | − uint64_t length; | |
| 127 | − uint64_t handle; | |
| 128 | − void *address; | |
| 129 | −}; | |
| 130 | − | |
| 131 | −struct rio_dma_mem { | |
| 132 | − uint64_t length; /* length of DMA memory */ | |
| 133 | − uint64_t dma_handle; /* handle associated with this memory */ | |
| 134 | − void *buffer; /* pointer to this memory */ | |
| 135 | −}; | |
| 136 | − | |
| 137 | − | |
| 138 | −struct rio_event { | |
| 139 | − unsigned int header; /* event type RIO_DOORBELL or RIO_PORTWRITE */ | |
| 140 | − union { | |
| 141 | − struct rio_doorbell doorbell; /* header for RIO_DOORBELL */ | |
| 142 | − struct rio_portwrite portwrite; /* header for RIO_PORTWRITE */ | |
| 143 | − } u; | |
| 144 | −}; | |
| 145 | − | |
| 146 | −enum rio_transfer_sync { | |
| 147 | − RIO_TRANSFER_SYNC, /* synchronous transfer */ | |
| 148 | − RIO_TRANSFER_ASYNC, /* asynchronous transfer */ | |
| 149 | − RIO_TRANSFER_FAF, /* fire-and-forget transfer */ | |
| 150 | −}; | |
| 151 | − | |
| 152 | −enum rio_transfer_dir { | |
| 153 | − RIO_TRANSFER_DIR_READ, /* Read operation */ | |
| 154 | − RIO_TRANSFER_DIR_WRITE, /* Write operation */ | |
| 155 | −}; | |
| 156 | − | |
| 157 | −/* | |
| 158 | − * RapidIO data exchange transactions are lists of individual transfers. Each | |
| 159 | − * transfer exchanges data between two RapidIO devices by remote direct memory | |
| 160 | − * access and has its own completion code. | |
| 161 | − * | |
| 162 | − * The RapidIO specification defines four types of data exchange requests: | |
| 163 | − * NREAD, NWRITE, SWRITE and NWRITE_R. The RapidIO DMA channel interface allows | |
| 164 | − * to specify the required type of write operation or combination of them when | |
| 165 | − * only the last data packet requires response. | |
| 166 | − * | |
| 167 | − * NREAD: read up to 256 bytes from remote device memory into local memory | |
| 168 | − * NWRITE: write up to 256 bytes from local memory to remote device memory | |
| 169 | − * without confirmation | |
| 170 | − * SWRITE: as NWRITE, but all addresses and payloads must be 64-bit aligned | |
| 171 | − * NWRITE_R: as NWRITE, but expect acknowledgment from remote device. | |
| 172 | − * | |
| 173 | − * The default exchange is chosen from NREAD and any of the WRITE modes as the | |
| 174 | − * driver sees fit. For write requests the user can explicitly choose between | |
| 175 | − * any of the write modes for each transaction. | |
| 176 | − */ | |
| 177 | −enum rio_exchange { | |
| 178 | − RIO_EXCHANGE_DEFAULT, /* Default method */ | |
| 179 | − RIO_EXCHANGE_NWRITE, /* All packets using NWRITE */ | |
| 180 | − RIO_EXCHANGE_SWRITE, /* All packets using SWRITE */ | |
| 181 | − RIO_EXCHANGE_NWRITE_R, /* Last packet NWRITE_R, others NWRITE */ | |
| 182 | − RIO_EXCHANGE_SWRITE_R, /* Last packet NWRITE_R, others SWRITE */ | |
| 183 | − RIO_EXCHANGE_NWRITE_R_ALL, /* All packets using NWRITE_R */ | |
| 184 | −}; | |
| 185 | − | |
| 186 | −struct rio_transfer_io { | |
| 187 | − uint32_t rioid; /* Target destID */ | |
| 188 | − uint64_t rio_addr; /* Address in target's RIO mem space */ | |
| 189 | − enum rio_exchange method; /* Data exchange method */ | |
| 190 | − void __user *loc_addr; | |
| 191 | − uint64_t handle; | |
| 192 | − uint64_t offset; /* Offset in buffer */ | |
| 193 | − uint64_t length; /* Length in bytes */ | |
| 194 | − uint32_t completion_code; /* Completion code for this transfer */ | |
| 195 | −}; | |
| 196 | − | |
| 197 | −struct rio_transaction { | |
| 198 | − uint32_t transfer_mode; /* Data transfer mode */ | |
| 199 | − enum rio_transfer_sync sync; /* Synchronization method */ | |
| 200 | − enum rio_transfer_dir dir; /* Transfer direction */ | |
| 201 | − size_t count; /* Number of transfers */ | |
| 202 | − struct rio_transfer_io __user *block; /* Array of <count> transfers */ | |
| 203 | −}; | |
| 204 | − | |
| 205 | −struct rio_async_tx_wait { | |
| 206 | − uint32_t token; /* DMA transaction ID token */ | |
| 207 | − uint32_t timeout; /* Wait timeout in msec, if 0 use default TO */ | |
| 208 | −}; | |
| 209 | − | |
| 210 | −#define RIO_MAX_DEVNAME_SZ 20 | |
| 211 | − | |
| 212 | −struct rio_rdev_info { | |
| 213 | − uint32_t destid; | |
| 214 | − uint8_t hopcount; | |
| 215 | − uint32_t comptag; | |
| 216 | − char name[RIO_MAX_DEVNAME_SZ + 1]; | |
| 217 | −}; | |
| 218 | − | |
| 219 | −/* Driver IOCTL codes */ | |
| 220 | −#define RIO_MPORT_DRV_MAGIC 'm' | |
| 221 | − | |
| 222 | −#define RIO_MPORT_MAINT_HDID_SET \ | |
| 223 | − _IOW(RIO_MPORT_DRV_MAGIC, 1, uint16_t) | |
| 224 | −#define RIO_MPORT_MAINT_COMPTAG_SET \ | |
| 225 | − _IOW(RIO_MPORT_DRV_MAGIC, 2, uint32_t) | |
| 226 | −#define RIO_MPORT_MAINT_PORT_IDX_GET \ | |
| 227 | − _IOR(RIO_MPORT_DRV_MAGIC, 3, uint32_t) | |
| 228 | −#define RIO_MPORT_GET_PROPERTIES \ | |
| 229 | − _IOR(RIO_MPORT_DRV_MAGIC, 4, struct rio_mport_properties) | |
| 230 | −#define RIO_MPORT_MAINT_READ_LOCAL \ | |
| 231 | − _IOR(RIO_MPORT_DRV_MAGIC, 5, struct rio_mport_maint_io) | |
| 232 | −#define RIO_MPORT_MAINT_WRITE_LOCAL \ | |
| 233 | − _IOW(RIO_MPORT_DRV_MAGIC, 6, struct rio_mport_maint_io) | |
| 234 | −#define RIO_MPORT_MAINT_READ_REMOTE \ | |
| 235 | − _IOR(RIO_MPORT_DRV_MAGIC, 7, struct rio_mport_maint_io) | |
| 236 | −#define RIO_MPORT_MAINT_WRITE_REMOTE \ | |
| 237 | − _IOW(RIO_MPORT_DRV_MAGIC, 8, struct rio_mport_maint_io) | |
| 238 | −#define RIO_ENABLE_DOORBELL_RANGE \ | |
| 239 | − _IOW(RIO_MPORT_DRV_MAGIC, 9, struct rio_doorbell_filter) | |
| 240 | −#define RIO_DISABLE_DOORBELL_RANGE \ | |
| 241 | − _IOW(RIO_MPORT_DRV_MAGIC, 10, struct rio_doorbell_filter) | |
| 242 | −#define RIO_ENABLE_PORTWRITE_RANGE \ | |
| 243 | − _IOW(RIO_MPORT_DRV_MAGIC, 11, struct rio_pw_filter) | |
| 244 | −#define RIO_DISABLE_PORTWRITE_RANGE \ | |
| 245 | − _IOW(RIO_MPORT_DRV_MAGIC, 12, struct rio_pw_filter) | |
| 246 | −#define RIO_SET_EVENT_MASK \ | |
| 247 | − _IOW(RIO_MPORT_DRV_MAGIC, 13, unsigned int) | |
| 248 | −#define RIO_GET_EVENT_MASK \ | |
| 249 | − _IOR(RIO_MPORT_DRV_MAGIC, 14, unsigned int) | |
| 250 | −#define RIO_MAP_OUTBOUND \ | |
| 251 | − _IOWR(RIO_MPORT_DRV_MAGIC, 15, struct rio_mmap) | |
| 252 | −#define RIO_UNMAP_OUTBOUND \ | |
| 253 | − _IOW(RIO_MPORT_DRV_MAGIC, 16, struct rio_mmap) | |
| 254 | −#define RIO_MAP_INBOUND \ | |
| 255 | − _IOWR(RIO_MPORT_DRV_MAGIC, 17, struct rio_mmap) | |
| 256 | −#define RIO_UNMAP_INBOUND \ | |
| 257 | − _IOW(RIO_MPORT_DRV_MAGIC, 18, uint64_t) | |
| 258 | −#define RIO_ALLOC_DMA \ | |
| 259 | − _IOWR(RIO_MPORT_DRV_MAGIC, 19, struct rio_dma_mem) | |
| 260 | −#define RIO_FREE_DMA \ | |
| 261 | − _IOW(RIO_MPORT_DRV_MAGIC, 20, uint64_t) | |
| 262 | −#define RIO_TRANSFER \ | |
| 263 | − _IOWR(RIO_MPORT_DRV_MAGIC, 21, struct rio_transaction) | |
| 264 | −#define RIO_WAIT_FOR_ASYNC \ | |
| 265 | − _IOW(RIO_MPORT_DRV_MAGIC, 22, struct rio_async_tx_wait) | |
| 266 | −#define RIO_DEV_ADD \ | |
| 267 | − _IOW(RIO_MPORT_DRV_MAGIC, 23, struct rio_rdev_info) | |
| 268 | −#define RIO_DEV_DEL \ | |
| 269 | − _IOW(RIO_MPORT_DRV_MAGIC, 24, struct rio_rdev_info) | |
| 270 | − | |
| 271 | −#endif /* _RIO_MPORT_CDEV_H_ */ | |