130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* 230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Copyright (c) 2004 Topspin Communications. All rights reserved. 330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Copyright (c) 2005 Voltaire, Inc. All rights reserved. 430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * 530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * This software is available to you under a choice of one of two 630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * licenses. You may choose to be licensed under the terms of the GNU 730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * General Public License (GPL) Version 2, available from the file 830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * COPYING in the main directory of this source tree, or the 930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * OpenIB.org BSD license below: 1030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * 1130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Redistribution and use in source and binary forms, with or 1230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * without modification, are permitted provided that the following 1330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * conditions are met: 1430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * 1530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * - Redistributions of source code must retain the above 1630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * copyright notice, this list of conditions and the following 1730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * disclaimer. 1830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * 1930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * - Redistributions in binary form must reproduce the above 2030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * copyright notice, this list of conditions and the following 2130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * disclaimer in the documentation and/or other materials 2230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * provided with the distribution. 2330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * 2430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 2530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 2830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 2930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 3030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 3130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * SOFTWARE. 3230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng */ 3330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 3430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#ifndef IB_USER_MAD_H 3530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define IB_USER_MAD_H 3630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 3730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#include <linux/types.h> 3830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#include <linux/ioctl.h> 3930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 4030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* 4130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Increment this value if any changes that break userspace ABI 4230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * compatibility are made. 4330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng */ 4430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define IB_USER_MAD_ABI_VERSION 5 4530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 4630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* 4730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Make sure that all structs defined in this file remain laid out so 4830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * that they pack the same way on 32-bit and 64-bit architectures (to 4930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * avoid incompatibility between 32-bit userspace and 64-bit kernels). 5030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng */ 5130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 5230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/** 5330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * ib_user_mad_hdr_old - Old version of MAD packet header without pkey_index 5430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @id - ID of agent MAD received with/to be sent with 5530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @status - 0 on successful receive, ETIMEDOUT if no response 5630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * received (transaction ID in data[] will be set to TID of original 5730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * request) (ignored on send) 5830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @timeout_ms - Milliseconds to wait for response (unset on receive) 5930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @retries - Number of automatic retries to attempt 6030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @qpn - Remote QP number received from/to be sent to 6130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @qkey - Remote Q_Key to be sent with (unset on receive) 6230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @lid - Remote lid received from/to be sent to 6330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @sl - Service level received with/to be sent with 6430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @path_bits - Local path bits received with/to be sent with 6530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @grh_present - If set, GRH was received/should be sent 6630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @gid_index - Local GID index to send with (unset on receive) 6730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @hop_limit - Hop limit in GRH 6830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @traffic_class - Traffic class in GRH 6930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @gid - Remote GID in GRH 7030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @flow_label - Flow label in GRH 7130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng */ 7230692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct ib_user_mad_hdr_old { 7330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u32 id; 7430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u32 status; 7530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u32 timeout_ms; 7630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u32 retries; 7730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u32 length; 7830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __be32 qpn; 7930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __be32 qkey; 8030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __be16 lid; 8130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 sl; 8230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 path_bits; 8330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 grh_present; 8430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 gid_index; 8530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 hop_limit; 8630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 traffic_class; 8730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 gid[16]; 8830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __be32 flow_label; 8930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}; 9030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 9130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/** 9230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * ib_user_mad_hdr - MAD packet header 9330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * This layout allows specifying/receiving the P_Key index. To use 9430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * this capability, an application must call the 9530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * IB_USER_MAD_ENABLE_PKEY ioctl on the user MAD file handle before 9630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * any other actions with the file handle. 9730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @id - ID of agent MAD received with/to be sent with 9830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @status - 0 on successful receive, ETIMEDOUT if no response 9930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * received (transaction ID in data[] will be set to TID of original 10030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * request) (ignored on send) 10130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @timeout_ms - Milliseconds to wait for response (unset on receive) 10230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @retries - Number of automatic retries to attempt 10330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @qpn - Remote QP number received from/to be sent to 10430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @qkey - Remote Q_Key to be sent with (unset on receive) 10530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @lid - Remote lid received from/to be sent to 10630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @sl - Service level received with/to be sent with 10730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @path_bits - Local path bits received with/to be sent with 10830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @grh_present - If set, GRH was received/should be sent 10930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @gid_index - Local GID index to send with (unset on receive) 11030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @hop_limit - Hop limit in GRH 11130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @traffic_class - Traffic class in GRH 11230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @gid - Remote GID in GRH 11330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @flow_label - Flow label in GRH 11430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @pkey_index - P_Key index 11530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng */ 11630692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct ib_user_mad_hdr { 11730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u32 id; 11830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u32 status; 11930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u32 timeout_ms; 12030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u32 retries; 12130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u32 length; 12230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __be32 qpn; 12330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __be32 qkey; 12430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __be16 lid; 12530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 sl; 12630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 path_bits; 12730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 grh_present; 12830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 gid_index; 12930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 hop_limit; 13030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 traffic_class; 13130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 gid[16]; 13230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __be32 flow_label; 13330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u16 pkey_index; 13430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 reserved[6]; 13530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}; 13630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 13730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/** 13830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * ib_user_mad - MAD packet 13930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @hdr - MAD packet header 14030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @data - Contents of MAD 14130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * 14230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng */ 14330692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct ib_user_mad { 14430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng struct ib_user_mad_hdr hdr; 14530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u64 data[0]; 14630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}; 14730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 14830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/* 14930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * Earlier versions of this interface definition declared the 15030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * method_mask[] member as an array of __u32 but treated it as a 15130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * bitmap made up of longs in the kernel. This ambiguity meant that 15230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * 32-bit big-endian applications that can run on both 32-bit and 15330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * 64-bit kernels had no consistent ABI to rely on, and 64-bit 15430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * big-endian applications that treated method_mask as being made up 15530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * of 32-bit words would have their bitmap misinterpreted. 15630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * 15730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * To clear up this confusion, we change the declaration of 15830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * method_mask[] to use unsigned long and handle the conversion from 15930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * 32-bit userspace to 64-bit kernel for big-endian systems in the 16030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * compat_ioctl method. Unfortunately, to keep the structure layout 16130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * the same, we need the method_mask[] array to be aligned only to 4 16230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * bytes even when long is 64 bits, which forces us into this ugly 16330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * typedef. 16430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng */ 16530692c65c4174412c90e79489e98ab85c1a7412fBen Chengtypedef unsigned long __attribute__((aligned(4))) packed_ulong; 16630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define IB_USER_MAD_LONGS_PER_METHOD_MASK (128 / (8 * sizeof (long))) 16730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 16830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng/** 16930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * ib_user_mad_reg_req - MAD registration request 17030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @id - Set by the kernel; used to identify agent in future requests. 17130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @qpn - Queue pair number; must be 0 or 1. 17230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @method_mask - The caller will receive unsolicited MADs for any method 17330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * where @method_mask = 1. 17430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @mgmt_class - Indicates which management class of MADs should be receive 17530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * by the caller. This field is only required if the user wishes to 17630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * receive unsolicited MADs, otherwise it should be 0. 17730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @mgmt_class_version - Indicates which version of MADs for the given 17830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * management class to receive. 17930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @oui: Indicates IEEE OUI when mgmt_class is a vendor class 18030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * in the range from 0x30 to 0x4f. Otherwise not used. 18130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * @rmpp_version: If set, indicates the RMPP version used. 18230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng * 18330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng */ 18430692c65c4174412c90e79489e98ab85c1a7412fBen Chengstruct ib_user_mad_reg_req { 18530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u32 id; 18630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng packed_ulong method_mask[IB_USER_MAD_LONGS_PER_METHOD_MASK]; 18730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 qpn; 18830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 mgmt_class; 18930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 mgmt_class_version; 19030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 oui[3]; 19130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng __u8 rmpp_version; 19230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng}; 19330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 19430692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define IB_IOCTL_MAGIC 0x1b 19530692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 19630692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define IB_USER_MAD_REGISTER_AGENT _IOWR(IB_IOCTL_MAGIC, 1, \ 19730692c65c4174412c90e79489e98ab85c1a7412fBen Cheng struct ib_user_mad_reg_req) 19830692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 19930692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define IB_USER_MAD_UNREGISTER_AGENT _IOW(IB_IOCTL_MAGIC, 2, __u32) 20030692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 20130692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#define IB_USER_MAD_ENABLE_PKEY _IO(IB_IOCTL_MAGIC, 3) 20230692c65c4174412c90e79489e98ab85c1a7412fBen Cheng 20330692c65c4174412c90e79489e98ab85c1a7412fBen Cheng#endif /* IB_USER_MAD_H */ 204