1*b633e08cSHans Petter Selasky /* 2*b633e08cSHans Petter Selasky * Copyright (c) 2018, Mellanox Technologies inc. All rights reserved. 3*b633e08cSHans Petter Selasky * 4*b633e08cSHans Petter Selasky * This software is available to you under a choice of one of two 5*b633e08cSHans Petter Selasky * licenses. You may choose to be licensed under the terms of the GNU 6*b633e08cSHans Petter Selasky * General Public License (GPL) Version 2, available from the file 7*b633e08cSHans Petter Selasky * COPYING in the main directory of this source tree, or the 8*b633e08cSHans Petter Selasky * OpenIB.org BSD license below: 9*b633e08cSHans Petter Selasky * 10*b633e08cSHans Petter Selasky * Redistribution and use in source and binary forms, with or 11*b633e08cSHans Petter Selasky * without modification, are permitted provided that the following 12*b633e08cSHans Petter Selasky * conditions are met: 13*b633e08cSHans Petter Selasky * 14*b633e08cSHans Petter Selasky * - Redistributions of source code must retain the above 15*b633e08cSHans Petter Selasky * copyright notice, this list of conditions and the following 16*b633e08cSHans Petter Selasky * disclaimer. 17*b633e08cSHans Petter Selasky * 18*b633e08cSHans Petter Selasky * - Redistributions in binary form must reproduce the above 19*b633e08cSHans Petter Selasky * copyright notice, this list of conditions and the following 20*b633e08cSHans Petter Selasky * disclaimer in the documentation and/or other materials 21*b633e08cSHans Petter Selasky * provided with the distribution. 22*b633e08cSHans Petter Selasky * 23*b633e08cSHans Petter Selasky * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24*b633e08cSHans Petter Selasky * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25*b633e08cSHans Petter Selasky * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26*b633e08cSHans Petter Selasky * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27*b633e08cSHans Petter Selasky * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28*b633e08cSHans Petter Selasky * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29*b633e08cSHans Petter Selasky * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30*b633e08cSHans Petter Selasky * SOFTWARE. 31*b633e08cSHans Petter Selasky */ 32*b633e08cSHans Petter Selasky 33*b633e08cSHans Petter Selasky #ifndef RDMA_USER_IOCTL_CMDS_H 34*b633e08cSHans Petter Selasky #define RDMA_USER_IOCTL_CMDS_H 35*b633e08cSHans Petter Selasky 36*b633e08cSHans Petter Selasky #ifdef _KERNEL 37*b633e08cSHans Petter Selasky #include <linux/types.h> 38*b633e08cSHans Petter Selasky #include <linux/ioctl.h> 39*b633e08cSHans Petter Selasky #else 40*b633e08cSHans Petter Selasky #include <infiniband/types.h> 41*b633e08cSHans Petter Selasky #include <sys/ioccom.h> 42*b633e08cSHans Petter Selasky #endif 43*b633e08cSHans Petter Selasky 44*b633e08cSHans Petter Selasky /* Documentation/ioctl/ioctl-number.rst */ 45*b633e08cSHans Petter Selasky #define RDMA_IOCTL_MAGIC 0x1b 46*b633e08cSHans Petter Selasky #define RDMA_VERBS_IOCTL \ 47*b633e08cSHans Petter Selasky _IOWR(RDMA_IOCTL_MAGIC, 1, struct ib_uverbs_ioctl_hdr) 48*b633e08cSHans Petter Selasky 49*b633e08cSHans Petter Selasky enum { 50*b633e08cSHans Petter Selasky /* User input */ 51*b633e08cSHans Petter Selasky UVERBS_ATTR_F_MANDATORY = 1U << 0, 52*b633e08cSHans Petter Selasky /* 53*b633e08cSHans Petter Selasky * Valid output bit should be ignored and considered set in 54*b633e08cSHans Petter Selasky * mandatory fields. This bit is kernel output. 55*b633e08cSHans Petter Selasky */ 56*b633e08cSHans Petter Selasky UVERBS_ATTR_F_VALID_OUTPUT = 1U << 1, 57*b633e08cSHans Petter Selasky }; 58*b633e08cSHans Petter Selasky 59*b633e08cSHans Petter Selasky struct ib_uverbs_attr { 60*b633e08cSHans Petter Selasky __u16 attr_id; /* command specific type attribute */ 61*b633e08cSHans Petter Selasky __u16 len; /* only for pointers and IDRs array */ 62*b633e08cSHans Petter Selasky __u16 flags; /* combination of UVERBS_ATTR_F_XXXX */ 63*b633e08cSHans Petter Selasky union { 64*b633e08cSHans Petter Selasky struct { 65*b633e08cSHans Petter Selasky __u8 elem_id; 66*b633e08cSHans Petter Selasky __u8 reserved; 67*b633e08cSHans Petter Selasky } enum_data; 68*b633e08cSHans Petter Selasky __u16 reserved; 69*b633e08cSHans Petter Selasky } attr_data; 70*b633e08cSHans Petter Selasky union { 71*b633e08cSHans Petter Selasky /* 72*b633e08cSHans Petter Selasky * ptr to command, inline data, idr/fd or 73*b633e08cSHans Petter Selasky * ptr to __u32 array of IDRs 74*b633e08cSHans Petter Selasky */ 75*b633e08cSHans Petter Selasky __aligned_u64 data; 76*b633e08cSHans Petter Selasky /* Used by FD_IN and FD_OUT */ 77*b633e08cSHans Petter Selasky __s64 data_s64; 78*b633e08cSHans Petter Selasky }; 79*b633e08cSHans Petter Selasky }; 80*b633e08cSHans Petter Selasky 81*b633e08cSHans Petter Selasky struct ib_uverbs_ioctl_hdr { 82*b633e08cSHans Petter Selasky __u16 length; 83*b633e08cSHans Petter Selasky __u16 object_id; 84*b633e08cSHans Petter Selasky __u16 method_id; 85*b633e08cSHans Petter Selasky __u16 num_attrs; 86*b633e08cSHans Petter Selasky __aligned_u64 reserved1; 87*b633e08cSHans Petter Selasky __u32 driver_id; 88*b633e08cSHans Petter Selasky __u32 reserved2; 89*b633e08cSHans Petter Selasky struct ib_uverbs_attr attrs[0]; 90*b633e08cSHans Petter Selasky }; 91*b633e08cSHans Petter Selasky 92*b633e08cSHans Petter Selasky #endif 93