1a0aa309cSMatan Barak /* 2a0aa309cSMatan Barak * Copyright (c) 2017, Mellanox Technologies inc. All rights reserved. 3a0aa309cSMatan Barak * 4a0aa309cSMatan Barak * This software is available to you under a choice of one of two 5a0aa309cSMatan Barak * licenses. You may choose to be licensed under the terms of the GNU 6a0aa309cSMatan Barak * General Public License (GPL) Version 2, available from the file 7a0aa309cSMatan Barak * COPYING in the main directory of this source tree, or the 8a0aa309cSMatan Barak * OpenIB.org BSD license below: 9a0aa309cSMatan Barak * 10a0aa309cSMatan Barak * Redistribution and use in source and binary forms, with or 11a0aa309cSMatan Barak * without modification, are permitted provided that the following 12a0aa309cSMatan Barak * conditions are met: 13a0aa309cSMatan Barak * 14a0aa309cSMatan Barak * - Redistributions of source code must retain the above 15a0aa309cSMatan Barak * copyright notice, this list of conditions and the following 16a0aa309cSMatan Barak * disclaimer. 17a0aa309cSMatan Barak * 18a0aa309cSMatan Barak * - Redistributions in binary form must reproduce the above 19a0aa309cSMatan Barak * copyright notice, this list of conditions and the following 20a0aa309cSMatan Barak * disclaimer in the documentation and/or other materials 21a0aa309cSMatan Barak * provided with the distribution. 22a0aa309cSMatan Barak * 23a0aa309cSMatan Barak * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24a0aa309cSMatan Barak * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25a0aa309cSMatan Barak * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26a0aa309cSMatan Barak * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27a0aa309cSMatan Barak * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28a0aa309cSMatan Barak * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29a0aa309cSMatan Barak * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30a0aa309cSMatan Barak * SOFTWARE. 31a0aa309cSMatan Barak */ 32a0aa309cSMatan Barak 33a0aa309cSMatan Barak #ifndef _UVERBS_IOCTL_ 34a0aa309cSMatan Barak #define _UVERBS_IOCTL_ 35a0aa309cSMatan Barak 36a0aa309cSMatan Barak #include <rdma/uverbs_types.h> 37a0aa309cSMatan Barak 38a0aa309cSMatan Barak /* 39a0aa309cSMatan Barak * ======================================= 40a0aa309cSMatan Barak * Verbs action specifications 41a0aa309cSMatan Barak * ======================================= 42a0aa309cSMatan Barak */ 43a0aa309cSMatan Barak 44*f43dbebfSMatan Barak enum uverbs_attr_type { 45*f43dbebfSMatan Barak UVERBS_ATTR_TYPE_NA, 46*f43dbebfSMatan Barak UVERBS_ATTR_TYPE_IDR, 47*f43dbebfSMatan Barak UVERBS_ATTR_TYPE_FD, 48*f43dbebfSMatan Barak }; 49*f43dbebfSMatan Barak 50a0aa309cSMatan Barak enum uverbs_obj_access { 51a0aa309cSMatan Barak UVERBS_ACCESS_READ, 52a0aa309cSMatan Barak UVERBS_ACCESS_WRITE, 53a0aa309cSMatan Barak UVERBS_ACCESS_NEW, 54a0aa309cSMatan Barak UVERBS_ACCESS_DESTROY 55a0aa309cSMatan Barak }; 56a0aa309cSMatan Barak 57*f43dbebfSMatan Barak struct uverbs_attr_spec { 58*f43dbebfSMatan Barak enum uverbs_attr_type type; 59*f43dbebfSMatan Barak struct { 60*f43dbebfSMatan Barak /* 61*f43dbebfSMatan Barak * higher bits mean the namespace and lower bits mean 62*f43dbebfSMatan Barak * the type id within the namespace. 63*f43dbebfSMatan Barak */ 64*f43dbebfSMatan Barak u16 obj_type; 65*f43dbebfSMatan Barak u8 access; 66*f43dbebfSMatan Barak } obj; 67*f43dbebfSMatan Barak }; 68*f43dbebfSMatan Barak 69*f43dbebfSMatan Barak struct uverbs_attr_spec_hash { 70*f43dbebfSMatan Barak size_t num_attrs; 71*f43dbebfSMatan Barak struct uverbs_attr_spec attrs[0]; 72*f43dbebfSMatan Barak }; 73*f43dbebfSMatan Barak 74*f43dbebfSMatan Barak struct uverbs_obj_attr { 75*f43dbebfSMatan Barak struct ib_uobject *uobject; 76*f43dbebfSMatan Barak }; 77*f43dbebfSMatan Barak 78*f43dbebfSMatan Barak struct uverbs_attr { 79*f43dbebfSMatan Barak struct uverbs_obj_attr obj_attr; 80*f43dbebfSMatan Barak }; 81*f43dbebfSMatan Barak 82*f43dbebfSMatan Barak struct uverbs_attr_bundle_hash { 83*f43dbebfSMatan Barak /* if bit i is set, it means attrs[i] contains valid information */ 84*f43dbebfSMatan Barak unsigned long *valid_bitmap; 85*f43dbebfSMatan Barak size_t num_attrs; 86*f43dbebfSMatan Barak /* 87*f43dbebfSMatan Barak * arrays of attributes, each element corresponds to the specification 88*f43dbebfSMatan Barak * of the attribute in the same index. 89*f43dbebfSMatan Barak */ 90*f43dbebfSMatan Barak struct uverbs_attr *attrs; 91*f43dbebfSMatan Barak }; 92*f43dbebfSMatan Barak 93*f43dbebfSMatan Barak struct uverbs_attr_bundle { 94*f43dbebfSMatan Barak size_t num_buckets; 95*f43dbebfSMatan Barak struct uverbs_attr_bundle_hash hash[]; 96*f43dbebfSMatan Barak }; 97*f43dbebfSMatan Barak 98*f43dbebfSMatan Barak static inline bool uverbs_attr_is_valid_in_hash(const struct uverbs_attr_bundle_hash *attrs_hash, 99*f43dbebfSMatan Barak unsigned int idx) 100*f43dbebfSMatan Barak { 101*f43dbebfSMatan Barak return test_bit(idx, attrs_hash->valid_bitmap); 102*f43dbebfSMatan Barak } 103*f43dbebfSMatan Barak 104a0aa309cSMatan Barak #endif 105a0aa309cSMatan Barak 106