Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
0002 /*
0003  * Copyright (c) 2015-2016, Integrated Device Technology Inc.
0004  * Copyright (c) 2015, Prodrive Technologies
0005  * Copyright (c) 2015, Texas Instruments Incorporated
0006  * Copyright (c) 2015, RapidIO Trade Association
0007  * All rights reserved.
0008  *
0009  * This software is available to you under a choice of one of two licenses.
0010  * You may choose to be licensed under the terms of the GNU General Public
0011  * License(GPL) Version 2, or the BSD-3 Clause license below:
0012  *
0013  * Redistribution and use in source and binary forms, with or without
0014  * modification, are permitted provided that the following conditions are met:
0015  *
0016  * 1. Redistributions of source code must retain the above copyright notice,
0017  * this list of conditions and the following disclaimer.
0018  *
0019  * 2. Redistributions in binary form must reproduce the above copyright notice,
0020  * this list of conditions and the following disclaimer in the documentation
0021  * and/or other materials provided with the distribution.
0022  *
0023  * 3. Neither the name of the copyright holder nor the names of its contributors
0024  * may be used to endorse or promote products derived from this software without
0025  * specific prior written permission.
0026  *
0027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0028  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
0029  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
0030  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
0031  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
0032  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
0033  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
0034  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
0035  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
0036  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
0037  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0038  */
0039 
0040 #ifndef _RIO_MPORT_CDEV_H_
0041 #define _RIO_MPORT_CDEV_H_
0042 
0043 #include <linux/ioctl.h>
0044 #include <linux/types.h>
0045 
0046 struct rio_mport_maint_io {
0047     __u16 rioid;        /* destID of remote device */
0048     __u8  hopcount;     /* hopcount to remote device */
0049     __u8  pad0[5];
0050     __u32 offset;       /* offset in register space */
0051     __u32 length;       /* length in bytes */
0052     __u64 buffer;       /* pointer to data buffer */
0053 };
0054 
0055 /*
0056  * Definitions for RapidIO data transfers:
0057  * - memory mapped (MAPPED)
0058  * - packet generation from memory (TRANSFER)
0059  */
0060 #define RIO_TRANSFER_MODE_MAPPED    (1 << 0)
0061 #define RIO_TRANSFER_MODE_TRANSFER  (1 << 1)
0062 #define RIO_CAP_DBL_SEND        (1 << 2)
0063 #define RIO_CAP_DBL_RECV        (1 << 3)
0064 #define RIO_CAP_PW_SEND         (1 << 4)
0065 #define RIO_CAP_PW_RECV         (1 << 5)
0066 #define RIO_CAP_MAP_OUTB        (1 << 6)
0067 #define RIO_CAP_MAP_INB         (1 << 7)
0068 
0069 struct rio_mport_properties {
0070     __u16 hdid;
0071     __u8  id;           /* Physical port ID */
0072     __u8  index;
0073     __u32 flags;
0074     __u32 sys_size;     /* Default addressing size */
0075     __u8  port_ok;
0076     __u8  link_speed;
0077     __u8  link_width;
0078     __u8  pad0;
0079     __u32 dma_max_sge;
0080     __u32 dma_max_size;
0081     __u32 dma_align;
0082     __u32 transfer_mode;        /* Default transfer mode */
0083     __u32 cap_sys_size;     /* Capable system sizes */
0084     __u32 cap_addr_size;        /* Capable addressing sizes */
0085     __u32 cap_transfer_mode;    /* Capable transfer modes */
0086     __u32 cap_mport;        /* Mport capabilities */
0087 };
0088 
0089 /*
0090  * Definitions for RapidIO events;
0091  * - incoming port-writes
0092  * - incoming doorbells
0093  */
0094 #define RIO_DOORBELL    (1 << 0)
0095 #define RIO_PORTWRITE   (1 << 1)
0096 
0097 struct rio_doorbell {
0098     __u16 rioid;
0099     __u16 payload;
0100 };
0101 
0102 struct rio_doorbell_filter {
0103     __u16 rioid;    /* Use RIO_INVALID_DESTID to match all ids */
0104     __u16 low;
0105     __u16 high;
0106     __u16 pad0;
0107 };
0108 
0109 
0110 struct rio_portwrite {
0111     __u32 payload[16];
0112 };
0113 
0114 struct rio_pw_filter {
0115     __u32 mask;
0116     __u32 low;
0117     __u32 high;
0118     __u32 pad0;
0119 };
0120 
0121 /* RapidIO base address for inbound requests set to value defined below
0122  * indicates that no specific RIO-to-local address translation is requested
0123  * and driver should use direct (one-to-one) address mapping.
0124 */
0125 #define RIO_MAP_ANY_ADDR    (__u64)(~((__u64) 0))
0126 
0127 struct rio_mmap {
0128     __u16 rioid;
0129     __u16 pad0[3];
0130     __u64 rio_addr;
0131     __u64 length;
0132     __u64 handle;
0133     __u64 address;
0134 };
0135 
0136 struct rio_dma_mem {
0137     __u64 length;       /* length of DMA memory */
0138     __u64 dma_handle;   /* handle associated with this memory */
0139     __u64 address;
0140 };
0141 
0142 struct rio_event {
0143     __u32 header;   /* event type RIO_DOORBELL or RIO_PORTWRITE */
0144     union {
0145         struct rio_doorbell doorbell;   /* header for RIO_DOORBELL */
0146         struct rio_portwrite portwrite; /* header for RIO_PORTWRITE */
0147     } u;
0148     __u32 pad0;
0149 };
0150 
0151 enum rio_transfer_sync {
0152     RIO_TRANSFER_SYNC,  /* synchronous transfer */
0153     RIO_TRANSFER_ASYNC, /* asynchronous transfer */
0154     RIO_TRANSFER_FAF,   /* fire-and-forget transfer */
0155 };
0156 
0157 enum rio_transfer_dir {
0158     RIO_TRANSFER_DIR_READ,  /* Read operation */
0159     RIO_TRANSFER_DIR_WRITE, /* Write operation */
0160 };
0161 
0162 /*
0163  * RapidIO data exchange transactions are lists of individual transfers. Each
0164  * transfer exchanges data between two RapidIO devices by remote direct memory
0165  * access and has its own completion code.
0166  *
0167  * The RapidIO specification defines four types of data exchange requests:
0168  * NREAD, NWRITE, SWRITE and NWRITE_R. The RapidIO DMA channel interface allows
0169  * to specify the required type of write operation or combination of them when
0170  * only the last data packet requires response.
0171  *
0172  * NREAD:    read up to 256 bytes from remote device memory into local memory
0173  * NWRITE:   write up to 256 bytes from local memory to remote device memory
0174  *           without confirmation
0175  * SWRITE:   as NWRITE, but all addresses and payloads must be 64-bit aligned
0176  * NWRITE_R: as NWRITE, but expect acknowledgment from remote device.
0177  *
0178  * The default exchange is chosen from NREAD and any of the WRITE modes as the
0179  * driver sees fit. For write requests the user can explicitly choose between
0180  * any of the write modes for each transaction.
0181  */
0182 enum rio_exchange {
0183     RIO_EXCHANGE_DEFAULT,   /* Default method */
0184     RIO_EXCHANGE_NWRITE,    /* All packets using NWRITE */
0185     RIO_EXCHANGE_SWRITE,    /* All packets using SWRITE */
0186     RIO_EXCHANGE_NWRITE_R,  /* Last packet NWRITE_R, others NWRITE */
0187     RIO_EXCHANGE_SWRITE_R,  /* Last packet NWRITE_R, others SWRITE */
0188     RIO_EXCHANGE_NWRITE_R_ALL, /* All packets using NWRITE_R */
0189 };
0190 
0191 struct rio_transfer_io {
0192     __u64 rio_addr; /* Address in target's RIO mem space */
0193     __u64 loc_addr;
0194     __u64 handle;
0195     __u64 offset;   /* Offset in buffer */
0196     __u64 length;   /* Length in bytes */
0197     __u16 rioid;    /* Target destID */
0198     __u16 method;   /* Data exchange method, one of rio_exchange enum */
0199     __u32 completion_code;  /* Completion code for this transfer */
0200 };
0201 
0202 struct rio_transaction {
0203     __u64 block;    /* Pointer to array of <count> transfers */
0204     __u32 count;    /* Number of transfers */
0205     __u32 transfer_mode;    /* Data transfer mode */
0206     __u16 sync; /* Synch method, one of rio_transfer_sync enum */
0207     __u16 dir;  /* Transfer direction, one of rio_transfer_dir enum */
0208     __u32 pad0;
0209 };
0210 
0211 struct rio_async_tx_wait {
0212     __u32 token;    /* DMA transaction ID token */
0213     __u32 timeout;  /* Wait timeout in msec, if 0 use default TO */
0214 };
0215 
0216 #define RIO_MAX_DEVNAME_SZ  20
0217 
0218 struct rio_rdev_info {
0219     __u16 destid;
0220     __u8 hopcount;
0221     __u8 pad0;
0222     __u32 comptag;
0223     char name[RIO_MAX_DEVNAME_SZ + 1];
0224 };
0225 
0226 /* Driver IOCTL codes */
0227 #define RIO_MPORT_DRV_MAGIC           'm'
0228 
0229 #define RIO_MPORT_MAINT_HDID_SET    \
0230     _IOW(RIO_MPORT_DRV_MAGIC, 1, __u16)
0231 #define RIO_MPORT_MAINT_COMPTAG_SET \
0232     _IOW(RIO_MPORT_DRV_MAGIC, 2, __u32)
0233 #define RIO_MPORT_MAINT_PORT_IDX_GET    \
0234     _IOR(RIO_MPORT_DRV_MAGIC, 3, __u32)
0235 #define RIO_MPORT_GET_PROPERTIES \
0236     _IOR(RIO_MPORT_DRV_MAGIC, 4, struct rio_mport_properties)
0237 #define RIO_MPORT_MAINT_READ_LOCAL \
0238     _IOR(RIO_MPORT_DRV_MAGIC, 5, struct rio_mport_maint_io)
0239 #define RIO_MPORT_MAINT_WRITE_LOCAL \
0240     _IOW(RIO_MPORT_DRV_MAGIC, 6, struct rio_mport_maint_io)
0241 #define RIO_MPORT_MAINT_READ_REMOTE \
0242     _IOR(RIO_MPORT_DRV_MAGIC, 7, struct rio_mport_maint_io)
0243 #define RIO_MPORT_MAINT_WRITE_REMOTE \
0244     _IOW(RIO_MPORT_DRV_MAGIC, 8, struct rio_mport_maint_io)
0245 #define RIO_ENABLE_DOORBELL_RANGE   \
0246     _IOW(RIO_MPORT_DRV_MAGIC, 9, struct rio_doorbell_filter)
0247 #define RIO_DISABLE_DOORBELL_RANGE  \
0248     _IOW(RIO_MPORT_DRV_MAGIC, 10, struct rio_doorbell_filter)
0249 #define RIO_ENABLE_PORTWRITE_RANGE  \
0250     _IOW(RIO_MPORT_DRV_MAGIC, 11, struct rio_pw_filter)
0251 #define RIO_DISABLE_PORTWRITE_RANGE \
0252     _IOW(RIO_MPORT_DRV_MAGIC, 12, struct rio_pw_filter)
0253 #define RIO_SET_EVENT_MASK      \
0254     _IOW(RIO_MPORT_DRV_MAGIC, 13, __u32)
0255 #define RIO_GET_EVENT_MASK      \
0256     _IOR(RIO_MPORT_DRV_MAGIC, 14, __u32)
0257 #define RIO_MAP_OUTBOUND \
0258     _IOWR(RIO_MPORT_DRV_MAGIC, 15, struct rio_mmap)
0259 #define RIO_UNMAP_OUTBOUND \
0260     _IOW(RIO_MPORT_DRV_MAGIC, 16, struct rio_mmap)
0261 #define RIO_MAP_INBOUND \
0262     _IOWR(RIO_MPORT_DRV_MAGIC, 17, struct rio_mmap)
0263 #define RIO_UNMAP_INBOUND \
0264     _IOW(RIO_MPORT_DRV_MAGIC, 18, __u64)
0265 #define RIO_ALLOC_DMA \
0266     _IOWR(RIO_MPORT_DRV_MAGIC, 19, struct rio_dma_mem)
0267 #define RIO_FREE_DMA \
0268     _IOW(RIO_MPORT_DRV_MAGIC, 20, __u64)
0269 #define RIO_TRANSFER \
0270     _IOWR(RIO_MPORT_DRV_MAGIC, 21, struct rio_transaction)
0271 #define RIO_WAIT_FOR_ASYNC \
0272     _IOW(RIO_MPORT_DRV_MAGIC, 22, struct rio_async_tx_wait)
0273 #define RIO_DEV_ADD \
0274     _IOW(RIO_MPORT_DRV_MAGIC, 23, struct rio_rdev_info)
0275 #define RIO_DEV_DEL \
0276     _IOW(RIO_MPORT_DRV_MAGIC, 24, struct rio_rdev_info)
0277 
0278 #endif /* _RIO_MPORT_CDEV_H_ */