162306a36Sopenharmony_ci/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2004 Topspin Communications. All rights reserved. 462306a36Sopenharmony_ci * Copyright (c) 2005 Voltaire, Inc. All rights reserved. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * This software is available to you under a choice of one of two 762306a36Sopenharmony_ci * licenses. You may choose to be licensed under the terms of the GNU 862306a36Sopenharmony_ci * General Public License (GPL) Version 2, available from the file 962306a36Sopenharmony_ci * COPYING in the main directory of this source tree, or the 1062306a36Sopenharmony_ci * OpenIB.org BSD license below: 1162306a36Sopenharmony_ci * 1262306a36Sopenharmony_ci * Redistribution and use in source and binary forms, with or 1362306a36Sopenharmony_ci * without modification, are permitted provided that the following 1462306a36Sopenharmony_ci * conditions are met: 1562306a36Sopenharmony_ci * 1662306a36Sopenharmony_ci * - Redistributions of source code must retain the above 1762306a36Sopenharmony_ci * copyright notice, this list of conditions and the following 1862306a36Sopenharmony_ci * disclaimer. 1962306a36Sopenharmony_ci * 2062306a36Sopenharmony_ci * - Redistributions in binary form must reproduce the above 2162306a36Sopenharmony_ci * copyright notice, this list of conditions and the following 2262306a36Sopenharmony_ci * disclaimer in the documentation and/or other materials 2362306a36Sopenharmony_ci * provided with the distribution. 2462306a36Sopenharmony_ci * 2562306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 2662306a36Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2762306a36Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2862306a36Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 2962306a36Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 3062306a36Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 3162306a36Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 3262306a36Sopenharmony_ci * SOFTWARE. 3362306a36Sopenharmony_ci */ 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci#ifndef IB_USER_MAD_H 3662306a36Sopenharmony_ci#define IB_USER_MAD_H 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci#include <linux/types.h> 3962306a36Sopenharmony_ci#include <rdma/rdma_user_ioctl.h> 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci/* 4262306a36Sopenharmony_ci * Increment this value if any changes that break userspace ABI 4362306a36Sopenharmony_ci * compatibility are made. 4462306a36Sopenharmony_ci */ 4562306a36Sopenharmony_ci#define IB_USER_MAD_ABI_VERSION 5 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci/* 4862306a36Sopenharmony_ci * Make sure that all structs defined in this file remain laid out so 4962306a36Sopenharmony_ci * that they pack the same way on 32-bit and 64-bit architectures (to 5062306a36Sopenharmony_ci * avoid incompatibility between 32-bit userspace and 64-bit kernels). 5162306a36Sopenharmony_ci */ 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ci/** 5462306a36Sopenharmony_ci * ib_user_mad_hdr_old - Old version of MAD packet header without pkey_index 5562306a36Sopenharmony_ci * @id - ID of agent MAD received with/to be sent with 5662306a36Sopenharmony_ci * @status - 0 on successful receive, ETIMEDOUT if no response 5762306a36Sopenharmony_ci * received (transaction ID in data[] will be set to TID of original 5862306a36Sopenharmony_ci * request) (ignored on send) 5962306a36Sopenharmony_ci * @timeout_ms - Milliseconds to wait for response (unset on receive) 6062306a36Sopenharmony_ci * @retries - Number of automatic retries to attempt 6162306a36Sopenharmony_ci * @qpn - Remote QP number received from/to be sent to 6262306a36Sopenharmony_ci * @qkey - Remote Q_Key to be sent with (unset on receive) 6362306a36Sopenharmony_ci * @lid - Remote lid received from/to be sent to 6462306a36Sopenharmony_ci * @sl - Service level received with/to be sent with 6562306a36Sopenharmony_ci * @path_bits - Local path bits received with/to be sent with 6662306a36Sopenharmony_ci * @grh_present - If set, GRH was received/should be sent 6762306a36Sopenharmony_ci * @gid_index - Local GID index to send with (unset on receive) 6862306a36Sopenharmony_ci * @hop_limit - Hop limit in GRH 6962306a36Sopenharmony_ci * @traffic_class - Traffic class in GRH 7062306a36Sopenharmony_ci * @gid - Remote GID in GRH 7162306a36Sopenharmony_ci * @flow_label - Flow label in GRH 7262306a36Sopenharmony_ci */ 7362306a36Sopenharmony_cistruct ib_user_mad_hdr_old { 7462306a36Sopenharmony_ci __u32 id; 7562306a36Sopenharmony_ci __u32 status; 7662306a36Sopenharmony_ci __u32 timeout_ms; 7762306a36Sopenharmony_ci __u32 retries; 7862306a36Sopenharmony_ci __u32 length; 7962306a36Sopenharmony_ci __be32 qpn; 8062306a36Sopenharmony_ci __be32 qkey; 8162306a36Sopenharmony_ci __be16 lid; 8262306a36Sopenharmony_ci __u8 sl; 8362306a36Sopenharmony_ci __u8 path_bits; 8462306a36Sopenharmony_ci __u8 grh_present; 8562306a36Sopenharmony_ci __u8 gid_index; 8662306a36Sopenharmony_ci __u8 hop_limit; 8762306a36Sopenharmony_ci __u8 traffic_class; 8862306a36Sopenharmony_ci __u8 gid[16]; 8962306a36Sopenharmony_ci __be32 flow_label; 9062306a36Sopenharmony_ci}; 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci/** 9362306a36Sopenharmony_ci * ib_user_mad_hdr - MAD packet header 9462306a36Sopenharmony_ci * This layout allows specifying/receiving the P_Key index. To use 9562306a36Sopenharmony_ci * this capability, an application must call the 9662306a36Sopenharmony_ci * IB_USER_MAD_ENABLE_PKEY ioctl on the user MAD file handle before 9762306a36Sopenharmony_ci * any other actions with the file handle. 9862306a36Sopenharmony_ci * @id - ID of agent MAD received with/to be sent with 9962306a36Sopenharmony_ci * @status - 0 on successful receive, ETIMEDOUT if no response 10062306a36Sopenharmony_ci * received (transaction ID in data[] will be set to TID of original 10162306a36Sopenharmony_ci * request) (ignored on send) 10262306a36Sopenharmony_ci * @timeout_ms - Milliseconds to wait for response (unset on receive) 10362306a36Sopenharmony_ci * @retries - Number of automatic retries to attempt 10462306a36Sopenharmony_ci * @qpn - Remote QP number received from/to be sent to 10562306a36Sopenharmony_ci * @qkey - Remote Q_Key to be sent with (unset on receive) 10662306a36Sopenharmony_ci * @lid - Remote lid received from/to be sent to 10762306a36Sopenharmony_ci * @sl - Service level received with/to be sent with 10862306a36Sopenharmony_ci * @path_bits - Local path bits received with/to be sent with 10962306a36Sopenharmony_ci * @grh_present - If set, GRH was received/should be sent 11062306a36Sopenharmony_ci * @gid_index - Local GID index to send with (unset on receive) 11162306a36Sopenharmony_ci * @hop_limit - Hop limit in GRH 11262306a36Sopenharmony_ci * @traffic_class - Traffic class in GRH 11362306a36Sopenharmony_ci * @gid - Remote GID in GRH 11462306a36Sopenharmony_ci * @flow_label - Flow label in GRH 11562306a36Sopenharmony_ci * @pkey_index - P_Key index 11662306a36Sopenharmony_ci */ 11762306a36Sopenharmony_cistruct ib_user_mad_hdr { 11862306a36Sopenharmony_ci __u32 id; 11962306a36Sopenharmony_ci __u32 status; 12062306a36Sopenharmony_ci __u32 timeout_ms; 12162306a36Sopenharmony_ci __u32 retries; 12262306a36Sopenharmony_ci __u32 length; 12362306a36Sopenharmony_ci __be32 qpn; 12462306a36Sopenharmony_ci __be32 qkey; 12562306a36Sopenharmony_ci __be16 lid; 12662306a36Sopenharmony_ci __u8 sl; 12762306a36Sopenharmony_ci __u8 path_bits; 12862306a36Sopenharmony_ci __u8 grh_present; 12962306a36Sopenharmony_ci __u8 gid_index; 13062306a36Sopenharmony_ci __u8 hop_limit; 13162306a36Sopenharmony_ci __u8 traffic_class; 13262306a36Sopenharmony_ci __u8 gid[16]; 13362306a36Sopenharmony_ci __be32 flow_label; 13462306a36Sopenharmony_ci __u16 pkey_index; 13562306a36Sopenharmony_ci __u8 reserved[6]; 13662306a36Sopenharmony_ci}; 13762306a36Sopenharmony_ci 13862306a36Sopenharmony_ci/** 13962306a36Sopenharmony_ci * ib_user_mad - MAD packet 14062306a36Sopenharmony_ci * @hdr - MAD packet header 14162306a36Sopenharmony_ci * @data - Contents of MAD 14262306a36Sopenharmony_ci * 14362306a36Sopenharmony_ci */ 14462306a36Sopenharmony_cistruct ib_user_mad { 14562306a36Sopenharmony_ci struct ib_user_mad_hdr hdr; 14662306a36Sopenharmony_ci __aligned_u64 data[]; 14762306a36Sopenharmony_ci}; 14862306a36Sopenharmony_ci 14962306a36Sopenharmony_ci/* 15062306a36Sopenharmony_ci * Earlier versions of this interface definition declared the 15162306a36Sopenharmony_ci * method_mask[] member as an array of __u32 but treated it as a 15262306a36Sopenharmony_ci * bitmap made up of longs in the kernel. This ambiguity meant that 15362306a36Sopenharmony_ci * 32-bit big-endian applications that can run on both 32-bit and 15462306a36Sopenharmony_ci * 64-bit kernels had no consistent ABI to rely on, and 64-bit 15562306a36Sopenharmony_ci * big-endian applications that treated method_mask as being made up 15662306a36Sopenharmony_ci * of 32-bit words would have their bitmap misinterpreted. 15762306a36Sopenharmony_ci * 15862306a36Sopenharmony_ci * To clear up this confusion, we change the declaration of 15962306a36Sopenharmony_ci * method_mask[] to use unsigned long and handle the conversion from 16062306a36Sopenharmony_ci * 32-bit userspace to 64-bit kernel for big-endian systems in the 16162306a36Sopenharmony_ci * compat_ioctl method. Unfortunately, to keep the structure layout 16262306a36Sopenharmony_ci * the same, we need the method_mask[] array to be aligned only to 4 16362306a36Sopenharmony_ci * bytes even when long is 64 bits, which forces us into this ugly 16462306a36Sopenharmony_ci * typedef. 16562306a36Sopenharmony_ci */ 16662306a36Sopenharmony_citypedef unsigned long __attribute__((aligned(4))) packed_ulong; 16762306a36Sopenharmony_ci#define IB_USER_MAD_LONGS_PER_METHOD_MASK (128 / (8 * sizeof (long))) 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_ci/** 17062306a36Sopenharmony_ci * ib_user_mad_reg_req - MAD registration request 17162306a36Sopenharmony_ci * @id - Set by the kernel; used to identify agent in future requests. 17262306a36Sopenharmony_ci * @qpn - Queue pair number; must be 0 or 1. 17362306a36Sopenharmony_ci * @method_mask - The caller will receive unsolicited MADs for any method 17462306a36Sopenharmony_ci * where @method_mask = 1. 17562306a36Sopenharmony_ci * @mgmt_class - Indicates which management class of MADs should be receive 17662306a36Sopenharmony_ci * by the caller. This field is only required if the user wishes to 17762306a36Sopenharmony_ci * receive unsolicited MADs, otherwise it should be 0. 17862306a36Sopenharmony_ci * @mgmt_class_version - Indicates which version of MADs for the given 17962306a36Sopenharmony_ci * management class to receive. 18062306a36Sopenharmony_ci * @oui: Indicates IEEE OUI when mgmt_class is a vendor class 18162306a36Sopenharmony_ci * in the range from 0x30 to 0x4f. Otherwise not used. 18262306a36Sopenharmony_ci * @rmpp_version: If set, indicates the RMPP version used. 18362306a36Sopenharmony_ci * 18462306a36Sopenharmony_ci */ 18562306a36Sopenharmony_cistruct ib_user_mad_reg_req { 18662306a36Sopenharmony_ci __u32 id; 18762306a36Sopenharmony_ci packed_ulong method_mask[IB_USER_MAD_LONGS_PER_METHOD_MASK]; 18862306a36Sopenharmony_ci __u8 qpn; 18962306a36Sopenharmony_ci __u8 mgmt_class; 19062306a36Sopenharmony_ci __u8 mgmt_class_version; 19162306a36Sopenharmony_ci __u8 oui[3]; 19262306a36Sopenharmony_ci __u8 rmpp_version; 19362306a36Sopenharmony_ci}; 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci/** 19662306a36Sopenharmony_ci * ib_user_mad_reg_req2 - MAD registration request 19762306a36Sopenharmony_ci * 19862306a36Sopenharmony_ci * @id - Set by the _kernel_; used by userspace to identify the 19962306a36Sopenharmony_ci * registered agent in future requests. 20062306a36Sopenharmony_ci * @qpn - Queue pair number; must be 0 or 1. 20162306a36Sopenharmony_ci * @mgmt_class - Indicates which management class of MADs should be 20262306a36Sopenharmony_ci * receive by the caller. This field is only required if 20362306a36Sopenharmony_ci * the user wishes to receive unsolicited MADs, otherwise 20462306a36Sopenharmony_ci * it should be 0. 20562306a36Sopenharmony_ci * @mgmt_class_version - Indicates which version of MADs for the given 20662306a36Sopenharmony_ci * management class to receive. 20762306a36Sopenharmony_ci * @res - Ignored. 20862306a36Sopenharmony_ci * @flags - additional registration flags; Must be in the set of 20962306a36Sopenharmony_ci * flags defined in IB_USER_MAD_REG_FLAGS_CAP 21062306a36Sopenharmony_ci * @method_mask - The caller wishes to receive unsolicited MADs for the 21162306a36Sopenharmony_ci * methods whose bit(s) is(are) set. 21262306a36Sopenharmony_ci * @oui - Indicates IEEE OUI to use when mgmt_class is a vendor 21362306a36Sopenharmony_ci * class in the range from 0x30 to 0x4f. Otherwise not 21462306a36Sopenharmony_ci * used. 21562306a36Sopenharmony_ci * @rmpp_version - If set, indicates the RMPP version to use. 21662306a36Sopenharmony_ci */ 21762306a36Sopenharmony_cienum { 21862306a36Sopenharmony_ci IB_USER_MAD_USER_RMPP = (1 << 0), 21962306a36Sopenharmony_ci}; 22062306a36Sopenharmony_ci#define IB_USER_MAD_REG_FLAGS_CAP (IB_USER_MAD_USER_RMPP) 22162306a36Sopenharmony_cistruct ib_user_mad_reg_req2 { 22262306a36Sopenharmony_ci __u32 id; 22362306a36Sopenharmony_ci __u32 qpn; 22462306a36Sopenharmony_ci __u8 mgmt_class; 22562306a36Sopenharmony_ci __u8 mgmt_class_version; 22662306a36Sopenharmony_ci __u16 res; 22762306a36Sopenharmony_ci __u32 flags; 22862306a36Sopenharmony_ci __aligned_u64 method_mask[2]; 22962306a36Sopenharmony_ci __u32 oui; 23062306a36Sopenharmony_ci __u8 rmpp_version; 23162306a36Sopenharmony_ci __u8 reserved[3]; 23262306a36Sopenharmony_ci}; 23362306a36Sopenharmony_ci 23462306a36Sopenharmony_ci#endif /* IB_USER_MAD_H */ 235