18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved. 48c2ecf20Sopenharmony_ci * Copyright (c) 2004 Infinicon Corporation. All rights reserved. 58c2ecf20Sopenharmony_ci * Copyright (c) 2004 Intel Corporation. All rights reserved. 68c2ecf20Sopenharmony_ci * Copyright (c) 2004 Topspin Corporation. All rights reserved. 78c2ecf20Sopenharmony_ci * Copyright (c) 2004-2006 Voltaire Corporation. All rights reserved. 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef IB_MAD_H 118c2ecf20Sopenharmony_ci#define IB_MAD_H 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <linux/list.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include <rdma/ib_verbs.h> 168c2ecf20Sopenharmony_ci#include <uapi/rdma/ib_user_mad.h> 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci/* Management base versions */ 198c2ecf20Sopenharmony_ci#define IB_MGMT_BASE_VERSION 1 208c2ecf20Sopenharmony_ci#define OPA_MGMT_BASE_VERSION 0x80 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#define OPA_SM_CLASS_VERSION 0x80 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci/* Management classes */ 258c2ecf20Sopenharmony_ci#define IB_MGMT_CLASS_SUBN_LID_ROUTED 0x01 268c2ecf20Sopenharmony_ci#define IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE 0x81 278c2ecf20Sopenharmony_ci#define IB_MGMT_CLASS_SUBN_ADM 0x03 288c2ecf20Sopenharmony_ci#define IB_MGMT_CLASS_PERF_MGMT 0x04 298c2ecf20Sopenharmony_ci#define IB_MGMT_CLASS_BM 0x05 308c2ecf20Sopenharmony_ci#define IB_MGMT_CLASS_DEVICE_MGMT 0x06 318c2ecf20Sopenharmony_ci#define IB_MGMT_CLASS_CM 0x07 328c2ecf20Sopenharmony_ci#define IB_MGMT_CLASS_SNMP 0x08 338c2ecf20Sopenharmony_ci#define IB_MGMT_CLASS_DEVICE_ADM 0x10 348c2ecf20Sopenharmony_ci#define IB_MGMT_CLASS_BOOT_MGMT 0x11 358c2ecf20Sopenharmony_ci#define IB_MGMT_CLASS_BIS 0x12 368c2ecf20Sopenharmony_ci#define IB_MGMT_CLASS_CONG_MGMT 0x21 378c2ecf20Sopenharmony_ci#define IB_MGMT_CLASS_VENDOR_RANGE2_START 0x30 388c2ecf20Sopenharmony_ci#define IB_MGMT_CLASS_VENDOR_RANGE2_END 0x4F 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#define IB_OPENIB_OUI (0x001405) 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci/* Management methods */ 438c2ecf20Sopenharmony_ci#define IB_MGMT_METHOD_GET 0x01 448c2ecf20Sopenharmony_ci#define IB_MGMT_METHOD_SET 0x02 458c2ecf20Sopenharmony_ci#define IB_MGMT_METHOD_GET_RESP 0x81 468c2ecf20Sopenharmony_ci#define IB_MGMT_METHOD_SEND 0x03 478c2ecf20Sopenharmony_ci#define IB_MGMT_METHOD_TRAP 0x05 488c2ecf20Sopenharmony_ci#define IB_MGMT_METHOD_REPORT 0x06 498c2ecf20Sopenharmony_ci#define IB_MGMT_METHOD_REPORT_RESP 0x86 508c2ecf20Sopenharmony_ci#define IB_MGMT_METHOD_TRAP_REPRESS 0x07 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#define IB_MGMT_METHOD_RESP 0x80 538c2ecf20Sopenharmony_ci#define IB_BM_ATTR_MOD_RESP cpu_to_be32(1) 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci#define IB_MGMT_MAX_METHODS 128 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci/* MAD Status field bit masks */ 588c2ecf20Sopenharmony_ci#define IB_MGMT_MAD_STATUS_SUCCESS 0x0000 598c2ecf20Sopenharmony_ci#define IB_MGMT_MAD_STATUS_BUSY 0x0001 608c2ecf20Sopenharmony_ci#define IB_MGMT_MAD_STATUS_REDIRECT_REQD 0x0002 618c2ecf20Sopenharmony_ci#define IB_MGMT_MAD_STATUS_BAD_VERSION 0x0004 628c2ecf20Sopenharmony_ci#define IB_MGMT_MAD_STATUS_UNSUPPORTED_METHOD 0x0008 638c2ecf20Sopenharmony_ci#define IB_MGMT_MAD_STATUS_UNSUPPORTED_METHOD_ATTRIB 0x000c 648c2ecf20Sopenharmony_ci#define IB_MGMT_MAD_STATUS_INVALID_ATTRIB_VALUE 0x001c 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci/* RMPP information */ 678c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_VERSION 1 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_TYPE_DATA 1 708c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_TYPE_ACK 2 718c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_TYPE_STOP 3 728c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_TYPE_ABORT 4 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_FLAG_ACTIVE 1 758c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_FLAG_FIRST (1<<1) 768c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_FLAG_LAST (1<<2) 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_NO_RESPTIME 0x1F 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_STATUS_SUCCESS 0 818c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_STATUS_RESX 1 828c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_STATUS_ABORT_MIN 118 838c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_STATUS_T2L 118 848c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_STATUS_BAD_LEN 119 858c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_STATUS_BAD_SEG 120 868c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_STATUS_BADT 121 878c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_STATUS_W2S 122 888c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_STATUS_S2B 123 898c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_STATUS_BAD_STATUS 124 908c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_STATUS_UNV 125 918c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_STATUS_TMR 126 928c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_STATUS_UNSPEC 127 938c2ecf20Sopenharmony_ci#define IB_MGMT_RMPP_STATUS_ABORT_MAX 127 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci#define IB_QP0 0 968c2ecf20Sopenharmony_ci#define IB_QP1 cpu_to_be32(1) 978c2ecf20Sopenharmony_ci#define IB_QP1_QKEY 0x80010000 988c2ecf20Sopenharmony_ci#define IB_QP_SET_QKEY 0x80000000 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci#define IB_DEFAULT_PKEY_PARTIAL 0x7FFF 1018c2ecf20Sopenharmony_ci#define IB_DEFAULT_PKEY_FULL 0xFFFF 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci/* 1048c2ecf20Sopenharmony_ci * Generic trap/notice types 1058c2ecf20Sopenharmony_ci */ 1068c2ecf20Sopenharmony_ci#define IB_NOTICE_TYPE_FATAL 0x80 1078c2ecf20Sopenharmony_ci#define IB_NOTICE_TYPE_URGENT 0x81 1088c2ecf20Sopenharmony_ci#define IB_NOTICE_TYPE_SECURITY 0x82 1098c2ecf20Sopenharmony_ci#define IB_NOTICE_TYPE_SM 0x83 1108c2ecf20Sopenharmony_ci#define IB_NOTICE_TYPE_INFO 0x84 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci/* 1138c2ecf20Sopenharmony_ci * Generic trap/notice producers 1148c2ecf20Sopenharmony_ci */ 1158c2ecf20Sopenharmony_ci#define IB_NOTICE_PROD_CA cpu_to_be16(1) 1168c2ecf20Sopenharmony_ci#define IB_NOTICE_PROD_SWITCH cpu_to_be16(2) 1178c2ecf20Sopenharmony_ci#define IB_NOTICE_PROD_ROUTER cpu_to_be16(3) 1188c2ecf20Sopenharmony_ci#define IB_NOTICE_PROD_CLASS_MGR cpu_to_be16(4) 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_cienum { 1218c2ecf20Sopenharmony_ci IB_MGMT_MAD_HDR = 24, 1228c2ecf20Sopenharmony_ci IB_MGMT_MAD_DATA = 232, 1238c2ecf20Sopenharmony_ci IB_MGMT_RMPP_HDR = 36, 1248c2ecf20Sopenharmony_ci IB_MGMT_RMPP_DATA = 220, 1258c2ecf20Sopenharmony_ci IB_MGMT_VENDOR_HDR = 40, 1268c2ecf20Sopenharmony_ci IB_MGMT_VENDOR_DATA = 216, 1278c2ecf20Sopenharmony_ci IB_MGMT_SA_HDR = 56, 1288c2ecf20Sopenharmony_ci IB_MGMT_SA_DATA = 200, 1298c2ecf20Sopenharmony_ci IB_MGMT_DEVICE_HDR = 64, 1308c2ecf20Sopenharmony_ci IB_MGMT_DEVICE_DATA = 192, 1318c2ecf20Sopenharmony_ci IB_MGMT_MAD_SIZE = IB_MGMT_MAD_HDR + IB_MGMT_MAD_DATA, 1328c2ecf20Sopenharmony_ci OPA_MGMT_MAD_DATA = 2024, 1338c2ecf20Sopenharmony_ci OPA_MGMT_RMPP_DATA = 2012, 1348c2ecf20Sopenharmony_ci OPA_MGMT_MAD_SIZE = IB_MGMT_MAD_HDR + OPA_MGMT_MAD_DATA, 1358c2ecf20Sopenharmony_ci}; 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_cistruct ib_mad_hdr { 1388c2ecf20Sopenharmony_ci u8 base_version; 1398c2ecf20Sopenharmony_ci u8 mgmt_class; 1408c2ecf20Sopenharmony_ci u8 class_version; 1418c2ecf20Sopenharmony_ci u8 method; 1428c2ecf20Sopenharmony_ci __be16 status; 1438c2ecf20Sopenharmony_ci __be16 class_specific; 1448c2ecf20Sopenharmony_ci __be64 tid; 1458c2ecf20Sopenharmony_ci __be16 attr_id; 1468c2ecf20Sopenharmony_ci __be16 resv; 1478c2ecf20Sopenharmony_ci __be32 attr_mod; 1488c2ecf20Sopenharmony_ci}; 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_cistruct ib_rmpp_hdr { 1518c2ecf20Sopenharmony_ci u8 rmpp_version; 1528c2ecf20Sopenharmony_ci u8 rmpp_type; 1538c2ecf20Sopenharmony_ci u8 rmpp_rtime_flags; 1548c2ecf20Sopenharmony_ci u8 rmpp_status; 1558c2ecf20Sopenharmony_ci __be32 seg_num; 1568c2ecf20Sopenharmony_ci __be32 paylen_newwin; 1578c2ecf20Sopenharmony_ci}; 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_citypedef u64 __bitwise ib_sa_comp_mask; 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci#define IB_SA_COMP_MASK(n) ((__force ib_sa_comp_mask) cpu_to_be64(1ull << (n))) 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci/* 1648c2ecf20Sopenharmony_ci * ib_sa_hdr and ib_sa_mad structures must be packed because they have 1658c2ecf20Sopenharmony_ci * 64-bit fields that are only 32-bit aligned. 64-bit architectures will 1668c2ecf20Sopenharmony_ci * lay them out wrong otherwise. (And unfortunately they are sent on 1678c2ecf20Sopenharmony_ci * the wire so we can't change the layout) 1688c2ecf20Sopenharmony_ci */ 1698c2ecf20Sopenharmony_cistruct ib_sa_hdr { 1708c2ecf20Sopenharmony_ci __be64 sm_key; 1718c2ecf20Sopenharmony_ci __be16 attr_offset; 1728c2ecf20Sopenharmony_ci __be16 reserved; 1738c2ecf20Sopenharmony_ci ib_sa_comp_mask comp_mask; 1748c2ecf20Sopenharmony_ci} __packed; 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_cistruct ib_mad { 1778c2ecf20Sopenharmony_ci struct ib_mad_hdr mad_hdr; 1788c2ecf20Sopenharmony_ci u8 data[IB_MGMT_MAD_DATA]; 1798c2ecf20Sopenharmony_ci}; 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_cistruct opa_mad { 1828c2ecf20Sopenharmony_ci struct ib_mad_hdr mad_hdr; 1838c2ecf20Sopenharmony_ci u8 data[OPA_MGMT_MAD_DATA]; 1848c2ecf20Sopenharmony_ci}; 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_cistruct ib_rmpp_mad { 1878c2ecf20Sopenharmony_ci struct ib_mad_hdr mad_hdr; 1888c2ecf20Sopenharmony_ci struct ib_rmpp_hdr rmpp_hdr; 1898c2ecf20Sopenharmony_ci u8 data[IB_MGMT_RMPP_DATA]; 1908c2ecf20Sopenharmony_ci}; 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_cistruct opa_rmpp_mad { 1938c2ecf20Sopenharmony_ci struct ib_mad_hdr mad_hdr; 1948c2ecf20Sopenharmony_ci struct ib_rmpp_hdr rmpp_hdr; 1958c2ecf20Sopenharmony_ci u8 data[OPA_MGMT_RMPP_DATA]; 1968c2ecf20Sopenharmony_ci}; 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_cistruct ib_sa_mad { 1998c2ecf20Sopenharmony_ci struct ib_mad_hdr mad_hdr; 2008c2ecf20Sopenharmony_ci struct ib_rmpp_hdr rmpp_hdr; 2018c2ecf20Sopenharmony_ci struct ib_sa_hdr sa_hdr; 2028c2ecf20Sopenharmony_ci u8 data[IB_MGMT_SA_DATA]; 2038c2ecf20Sopenharmony_ci} __packed; 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_cistruct ib_vendor_mad { 2068c2ecf20Sopenharmony_ci struct ib_mad_hdr mad_hdr; 2078c2ecf20Sopenharmony_ci struct ib_rmpp_hdr rmpp_hdr; 2088c2ecf20Sopenharmony_ci u8 reserved; 2098c2ecf20Sopenharmony_ci u8 oui[3]; 2108c2ecf20Sopenharmony_ci u8 data[IB_MGMT_VENDOR_DATA]; 2118c2ecf20Sopenharmony_ci}; 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci#define IB_MGMT_CLASSPORTINFO_ATTR_ID cpu_to_be16(0x0001) 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci#define IB_CLASS_PORT_INFO_RESP_TIME_MASK 0x1F 2168c2ecf20Sopenharmony_ci#define IB_CLASS_PORT_INFO_RESP_TIME_FIELD_SIZE 5 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_cistruct ib_class_port_info { 2198c2ecf20Sopenharmony_ci u8 base_version; 2208c2ecf20Sopenharmony_ci u8 class_version; 2218c2ecf20Sopenharmony_ci __be16 capability_mask; 2228c2ecf20Sopenharmony_ci /* 27 bits for cap_mask2, 5 bits for resp_time */ 2238c2ecf20Sopenharmony_ci __be32 cap_mask2_resp_time; 2248c2ecf20Sopenharmony_ci u8 redirect_gid[16]; 2258c2ecf20Sopenharmony_ci __be32 redirect_tcslfl; 2268c2ecf20Sopenharmony_ci __be16 redirect_lid; 2278c2ecf20Sopenharmony_ci __be16 redirect_pkey; 2288c2ecf20Sopenharmony_ci __be32 redirect_qp; 2298c2ecf20Sopenharmony_ci __be32 redirect_qkey; 2308c2ecf20Sopenharmony_ci u8 trap_gid[16]; 2318c2ecf20Sopenharmony_ci __be32 trap_tcslfl; 2328c2ecf20Sopenharmony_ci __be16 trap_lid; 2338c2ecf20Sopenharmony_ci __be16 trap_pkey; 2348c2ecf20Sopenharmony_ci __be32 trap_hlqp; 2358c2ecf20Sopenharmony_ci __be32 trap_qkey; 2368c2ecf20Sopenharmony_ci}; 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci/* PortInfo CapabilityMask */ 2398c2ecf20Sopenharmony_cienum ib_port_capability_mask_bits { 2408c2ecf20Sopenharmony_ci IB_PORT_SM = 1 << 1, 2418c2ecf20Sopenharmony_ci IB_PORT_NOTICE_SUP = 1 << 2, 2428c2ecf20Sopenharmony_ci IB_PORT_TRAP_SUP = 1 << 3, 2438c2ecf20Sopenharmony_ci IB_PORT_OPT_IPD_SUP = 1 << 4, 2448c2ecf20Sopenharmony_ci IB_PORT_AUTO_MIGR_SUP = 1 << 5, 2458c2ecf20Sopenharmony_ci IB_PORT_SL_MAP_SUP = 1 << 6, 2468c2ecf20Sopenharmony_ci IB_PORT_MKEY_NVRAM = 1 << 7, 2478c2ecf20Sopenharmony_ci IB_PORT_PKEY_NVRAM = 1 << 8, 2488c2ecf20Sopenharmony_ci IB_PORT_LED_INFO_SUP = 1 << 9, 2498c2ecf20Sopenharmony_ci IB_PORT_SM_DISABLED = 1 << 10, 2508c2ecf20Sopenharmony_ci IB_PORT_SYS_IMAGE_GUID_SUP = 1 << 11, 2518c2ecf20Sopenharmony_ci IB_PORT_PKEY_SW_EXT_PORT_TRAP_SUP = 1 << 12, 2528c2ecf20Sopenharmony_ci IB_PORT_EXTENDED_SPEEDS_SUP = 1 << 14, 2538c2ecf20Sopenharmony_ci IB_PORT_CAP_MASK2_SUP = 1 << 15, 2548c2ecf20Sopenharmony_ci IB_PORT_CM_SUP = 1 << 16, 2558c2ecf20Sopenharmony_ci IB_PORT_SNMP_TUNNEL_SUP = 1 << 17, 2568c2ecf20Sopenharmony_ci IB_PORT_REINIT_SUP = 1 << 18, 2578c2ecf20Sopenharmony_ci IB_PORT_DEVICE_MGMT_SUP = 1 << 19, 2588c2ecf20Sopenharmony_ci IB_PORT_VENDOR_CLASS_SUP = 1 << 20, 2598c2ecf20Sopenharmony_ci IB_PORT_DR_NOTICE_SUP = 1 << 21, 2608c2ecf20Sopenharmony_ci IB_PORT_CAP_MASK_NOTICE_SUP = 1 << 22, 2618c2ecf20Sopenharmony_ci IB_PORT_BOOT_MGMT_SUP = 1 << 23, 2628c2ecf20Sopenharmony_ci IB_PORT_LINK_LATENCY_SUP = 1 << 24, 2638c2ecf20Sopenharmony_ci IB_PORT_CLIENT_REG_SUP = 1 << 25, 2648c2ecf20Sopenharmony_ci IB_PORT_OTHER_LOCAL_CHANGES_SUP = 1 << 26, 2658c2ecf20Sopenharmony_ci IB_PORT_LINK_SPEED_WIDTH_TABLE_SUP = 1 << 27, 2668c2ecf20Sopenharmony_ci IB_PORT_VENDOR_SPECIFIC_MADS_TABLE_SUP = 1 << 28, 2678c2ecf20Sopenharmony_ci IB_PORT_MCAST_PKEY_TRAP_SUPPRESSION_SUP = 1 << 29, 2688c2ecf20Sopenharmony_ci IB_PORT_MCAST_FDB_TOP_SUP = 1 << 30, 2698c2ecf20Sopenharmony_ci IB_PORT_HIERARCHY_INFO_SUP = 1ULL << 31, 2708c2ecf20Sopenharmony_ci}; 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_cienum ib_port_capability_mask2_bits { 2738c2ecf20Sopenharmony_ci IB_PORT_SET_NODE_DESC_SUP = 1 << 0, 2748c2ecf20Sopenharmony_ci IB_PORT_EX_PORT_INFO_EX_SUP = 1 << 1, 2758c2ecf20Sopenharmony_ci IB_PORT_VIRT_SUP = 1 << 2, 2768c2ecf20Sopenharmony_ci IB_PORT_SWITCH_PORT_STATE_TABLE_SUP = 1 << 3, 2778c2ecf20Sopenharmony_ci IB_PORT_LINK_WIDTH_2X_SUP = 1 << 4, 2788c2ecf20Sopenharmony_ci IB_PORT_LINK_SPEED_HDR_SUP = 1 << 5, 2798c2ecf20Sopenharmony_ci}; 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ci#define OPA_CLASS_PORT_INFO_PR_SUPPORT BIT(26) 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_cistruct opa_class_port_info { 2848c2ecf20Sopenharmony_ci u8 base_version; 2858c2ecf20Sopenharmony_ci u8 class_version; 2868c2ecf20Sopenharmony_ci __be16 cap_mask; 2878c2ecf20Sopenharmony_ci __be32 cap_mask2_resp_time; 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ci u8 redirect_gid[16]; 2908c2ecf20Sopenharmony_ci __be32 redirect_tc_fl; 2918c2ecf20Sopenharmony_ci __be32 redirect_lid; 2928c2ecf20Sopenharmony_ci __be32 redirect_sl_qp; 2938c2ecf20Sopenharmony_ci __be32 redirect_qkey; 2948c2ecf20Sopenharmony_ci 2958c2ecf20Sopenharmony_ci u8 trap_gid[16]; 2968c2ecf20Sopenharmony_ci __be32 trap_tc_fl; 2978c2ecf20Sopenharmony_ci __be32 trap_lid; 2988c2ecf20Sopenharmony_ci __be32 trap_hl_qp; 2998c2ecf20Sopenharmony_ci __be32 trap_qkey; 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_ci __be16 trap_pkey; 3028c2ecf20Sopenharmony_ci __be16 redirect_pkey; 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci u8 trap_sl_rsvd; 3058c2ecf20Sopenharmony_ci u8 reserved[3]; 3068c2ecf20Sopenharmony_ci} __packed; 3078c2ecf20Sopenharmony_ci 3088c2ecf20Sopenharmony_ci/** 3098c2ecf20Sopenharmony_ci * ib_get_cpi_resp_time - Returns the resp_time value from 3108c2ecf20Sopenharmony_ci * cap_mask2_resp_time in ib_class_port_info. 3118c2ecf20Sopenharmony_ci * @cpi: A struct ib_class_port_info mad. 3128c2ecf20Sopenharmony_ci */ 3138c2ecf20Sopenharmony_cistatic inline u8 ib_get_cpi_resp_time(struct ib_class_port_info *cpi) 3148c2ecf20Sopenharmony_ci{ 3158c2ecf20Sopenharmony_ci return (u8)(be32_to_cpu(cpi->cap_mask2_resp_time) & 3168c2ecf20Sopenharmony_ci IB_CLASS_PORT_INFO_RESP_TIME_MASK); 3178c2ecf20Sopenharmony_ci} 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_ci/** 3208c2ecf20Sopenharmony_ci * ib_set_cpi_resptime - Sets the response time in an 3218c2ecf20Sopenharmony_ci * ib_class_port_info mad. 3228c2ecf20Sopenharmony_ci * @cpi: A struct ib_class_port_info. 3238c2ecf20Sopenharmony_ci * @rtime: The response time to set. 3248c2ecf20Sopenharmony_ci */ 3258c2ecf20Sopenharmony_cistatic inline void ib_set_cpi_resp_time(struct ib_class_port_info *cpi, 3268c2ecf20Sopenharmony_ci u8 rtime) 3278c2ecf20Sopenharmony_ci{ 3288c2ecf20Sopenharmony_ci cpi->cap_mask2_resp_time = 3298c2ecf20Sopenharmony_ci (cpi->cap_mask2_resp_time & 3308c2ecf20Sopenharmony_ci cpu_to_be32(~IB_CLASS_PORT_INFO_RESP_TIME_MASK)) | 3318c2ecf20Sopenharmony_ci cpu_to_be32(rtime & IB_CLASS_PORT_INFO_RESP_TIME_MASK); 3328c2ecf20Sopenharmony_ci} 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_ci/** 3358c2ecf20Sopenharmony_ci * ib_get_cpi_capmask2 - Returns the capmask2 value from 3368c2ecf20Sopenharmony_ci * cap_mask2_resp_time in ib_class_port_info. 3378c2ecf20Sopenharmony_ci * @cpi: A struct ib_class_port_info mad. 3388c2ecf20Sopenharmony_ci */ 3398c2ecf20Sopenharmony_cistatic inline u32 ib_get_cpi_capmask2(struct ib_class_port_info *cpi) 3408c2ecf20Sopenharmony_ci{ 3418c2ecf20Sopenharmony_ci return (be32_to_cpu(cpi->cap_mask2_resp_time) >> 3428c2ecf20Sopenharmony_ci IB_CLASS_PORT_INFO_RESP_TIME_FIELD_SIZE); 3438c2ecf20Sopenharmony_ci} 3448c2ecf20Sopenharmony_ci 3458c2ecf20Sopenharmony_ci/** 3468c2ecf20Sopenharmony_ci * ib_set_cpi_capmask2 - Sets the capmask2 in an 3478c2ecf20Sopenharmony_ci * ib_class_port_info mad. 3488c2ecf20Sopenharmony_ci * @cpi: A struct ib_class_port_info. 3498c2ecf20Sopenharmony_ci * @capmask2: The capmask2 to set. 3508c2ecf20Sopenharmony_ci */ 3518c2ecf20Sopenharmony_cistatic inline void ib_set_cpi_capmask2(struct ib_class_port_info *cpi, 3528c2ecf20Sopenharmony_ci u32 capmask2) 3538c2ecf20Sopenharmony_ci{ 3548c2ecf20Sopenharmony_ci cpi->cap_mask2_resp_time = 3558c2ecf20Sopenharmony_ci (cpi->cap_mask2_resp_time & 3568c2ecf20Sopenharmony_ci cpu_to_be32(IB_CLASS_PORT_INFO_RESP_TIME_MASK)) | 3578c2ecf20Sopenharmony_ci cpu_to_be32(capmask2 << 3588c2ecf20Sopenharmony_ci IB_CLASS_PORT_INFO_RESP_TIME_FIELD_SIZE); 3598c2ecf20Sopenharmony_ci} 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ci/** 3628c2ecf20Sopenharmony_ci * opa_get_cpi_capmask2 - Returns the capmask2 value from 3638c2ecf20Sopenharmony_ci * cap_mask2_resp_time in ib_class_port_info. 3648c2ecf20Sopenharmony_ci * @cpi: A struct opa_class_port_info mad. 3658c2ecf20Sopenharmony_ci */ 3668c2ecf20Sopenharmony_cistatic inline u32 opa_get_cpi_capmask2(struct opa_class_port_info *cpi) 3678c2ecf20Sopenharmony_ci{ 3688c2ecf20Sopenharmony_ci return (be32_to_cpu(cpi->cap_mask2_resp_time) >> 3698c2ecf20Sopenharmony_ci IB_CLASS_PORT_INFO_RESP_TIME_FIELD_SIZE); 3708c2ecf20Sopenharmony_ci} 3718c2ecf20Sopenharmony_ci 3728c2ecf20Sopenharmony_cistruct ib_mad_notice_attr { 3738c2ecf20Sopenharmony_ci u8 generic_type; 3748c2ecf20Sopenharmony_ci u8 prod_type_msb; 3758c2ecf20Sopenharmony_ci __be16 prod_type_lsb; 3768c2ecf20Sopenharmony_ci __be16 trap_num; 3778c2ecf20Sopenharmony_ci __be16 issuer_lid; 3788c2ecf20Sopenharmony_ci __be16 toggle_count; 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_ci union { 3818c2ecf20Sopenharmony_ci struct { 3828c2ecf20Sopenharmony_ci u8 details[54]; 3838c2ecf20Sopenharmony_ci } raw_data; 3848c2ecf20Sopenharmony_ci 3858c2ecf20Sopenharmony_ci struct { 3868c2ecf20Sopenharmony_ci __be16 reserved; 3878c2ecf20Sopenharmony_ci __be16 lid; /* where violation happened */ 3888c2ecf20Sopenharmony_ci u8 port_num; /* where violation happened */ 3898c2ecf20Sopenharmony_ci } __packed ntc_129_131; 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ci struct { 3928c2ecf20Sopenharmony_ci __be16 reserved; 3938c2ecf20Sopenharmony_ci __be16 lid; /* LID where change occurred */ 3948c2ecf20Sopenharmony_ci u8 reserved2; 3958c2ecf20Sopenharmony_ci u8 local_changes; /* low bit - local changes */ 3968c2ecf20Sopenharmony_ci __be32 new_cap_mask; /* new capability mask */ 3978c2ecf20Sopenharmony_ci u8 reserved3; 3988c2ecf20Sopenharmony_ci u8 change_flags; /* low 3 bits only */ 3998c2ecf20Sopenharmony_ci } __packed ntc_144; 4008c2ecf20Sopenharmony_ci 4018c2ecf20Sopenharmony_ci struct { 4028c2ecf20Sopenharmony_ci __be16 reserved; 4038c2ecf20Sopenharmony_ci __be16 lid; /* lid where sys guid changed */ 4048c2ecf20Sopenharmony_ci __be16 reserved2; 4058c2ecf20Sopenharmony_ci __be64 new_sys_guid; 4068c2ecf20Sopenharmony_ci } __packed ntc_145; 4078c2ecf20Sopenharmony_ci 4088c2ecf20Sopenharmony_ci struct { 4098c2ecf20Sopenharmony_ci __be16 reserved; 4108c2ecf20Sopenharmony_ci __be16 lid; 4118c2ecf20Sopenharmony_ci __be16 dr_slid; 4128c2ecf20Sopenharmony_ci u8 method; 4138c2ecf20Sopenharmony_ci u8 reserved2; 4148c2ecf20Sopenharmony_ci __be16 attr_id; 4158c2ecf20Sopenharmony_ci __be32 attr_mod; 4168c2ecf20Sopenharmony_ci __be64 mkey; 4178c2ecf20Sopenharmony_ci u8 reserved3; 4188c2ecf20Sopenharmony_ci u8 dr_trunc_hop; 4198c2ecf20Sopenharmony_ci u8 dr_rtn_path[30]; 4208c2ecf20Sopenharmony_ci } __packed ntc_256; 4218c2ecf20Sopenharmony_ci 4228c2ecf20Sopenharmony_ci struct { 4238c2ecf20Sopenharmony_ci __be16 reserved; 4248c2ecf20Sopenharmony_ci __be16 lid1; 4258c2ecf20Sopenharmony_ci __be16 lid2; 4268c2ecf20Sopenharmony_ci __be32 key; 4278c2ecf20Sopenharmony_ci __be32 sl_qp1; /* SL: high 4 bits */ 4288c2ecf20Sopenharmony_ci __be32 qp2; /* high 8 bits reserved */ 4298c2ecf20Sopenharmony_ci union ib_gid gid1; 4308c2ecf20Sopenharmony_ci union ib_gid gid2; 4318c2ecf20Sopenharmony_ci } __packed ntc_257_258; 4328c2ecf20Sopenharmony_ci 4338c2ecf20Sopenharmony_ci } details; 4348c2ecf20Sopenharmony_ci}; 4358c2ecf20Sopenharmony_ci 4368c2ecf20Sopenharmony_ci/** 4378c2ecf20Sopenharmony_ci * ib_mad_send_buf - MAD data buffer and work request for sends. 4388c2ecf20Sopenharmony_ci * @next: A pointer used to chain together MADs for posting. 4398c2ecf20Sopenharmony_ci * @mad: References an allocated MAD data buffer for MADs that do not have 4408c2ecf20Sopenharmony_ci * RMPP active. For MADs using RMPP, references the common and management 4418c2ecf20Sopenharmony_ci * class specific headers. 4428c2ecf20Sopenharmony_ci * @mad_agent: MAD agent that allocated the buffer. 4438c2ecf20Sopenharmony_ci * @ah: The address handle to use when sending the MAD. 4448c2ecf20Sopenharmony_ci * @context: User-controlled context fields. 4458c2ecf20Sopenharmony_ci * @hdr_len: Indicates the size of the data header of the MAD. This length 4468c2ecf20Sopenharmony_ci * includes the common MAD, RMPP, and class specific headers. 4478c2ecf20Sopenharmony_ci * @data_len: Indicates the total size of user-transferred data. 4488c2ecf20Sopenharmony_ci * @seg_count: The number of RMPP segments allocated for this send. 4498c2ecf20Sopenharmony_ci * @seg_size: Size of the data in each RMPP segment. This does not include 4508c2ecf20Sopenharmony_ci * class specific headers. 4518c2ecf20Sopenharmony_ci * @seg_rmpp_size: Size of each RMPP segment including the class specific 4528c2ecf20Sopenharmony_ci * headers. 4538c2ecf20Sopenharmony_ci * @timeout_ms: Time to wait for a response. 4548c2ecf20Sopenharmony_ci * @retries: Number of times to retry a request for a response. For MADs 4558c2ecf20Sopenharmony_ci * using RMPP, this applies per window. On completion, returns the number 4568c2ecf20Sopenharmony_ci * of retries needed to complete the transfer. 4578c2ecf20Sopenharmony_ci * 4588c2ecf20Sopenharmony_ci * Users are responsible for initializing the MAD buffer itself, with the 4598c2ecf20Sopenharmony_ci * exception of any RMPP header. Additional segment buffer space allocated 4608c2ecf20Sopenharmony_ci * beyond data_len is padding. 4618c2ecf20Sopenharmony_ci */ 4628c2ecf20Sopenharmony_cistruct ib_mad_send_buf { 4638c2ecf20Sopenharmony_ci struct ib_mad_send_buf *next; 4648c2ecf20Sopenharmony_ci void *mad; 4658c2ecf20Sopenharmony_ci struct ib_mad_agent *mad_agent; 4668c2ecf20Sopenharmony_ci struct ib_ah *ah; 4678c2ecf20Sopenharmony_ci void *context[2]; 4688c2ecf20Sopenharmony_ci int hdr_len; 4698c2ecf20Sopenharmony_ci int data_len; 4708c2ecf20Sopenharmony_ci int seg_count; 4718c2ecf20Sopenharmony_ci int seg_size; 4728c2ecf20Sopenharmony_ci int seg_rmpp_size; 4738c2ecf20Sopenharmony_ci int timeout_ms; 4748c2ecf20Sopenharmony_ci int retries; 4758c2ecf20Sopenharmony_ci}; 4768c2ecf20Sopenharmony_ci 4778c2ecf20Sopenharmony_ci/** 4788c2ecf20Sopenharmony_ci * ib_response_mad - Returns if the specified MAD has been generated in 4798c2ecf20Sopenharmony_ci * response to a sent request or trap. 4808c2ecf20Sopenharmony_ci */ 4818c2ecf20Sopenharmony_ciint ib_response_mad(const struct ib_mad_hdr *hdr); 4828c2ecf20Sopenharmony_ci 4838c2ecf20Sopenharmony_ci/** 4848c2ecf20Sopenharmony_ci * ib_get_rmpp_resptime - Returns the RMPP response time. 4858c2ecf20Sopenharmony_ci * @rmpp_hdr: An RMPP header. 4868c2ecf20Sopenharmony_ci */ 4878c2ecf20Sopenharmony_cistatic inline u8 ib_get_rmpp_resptime(struct ib_rmpp_hdr *rmpp_hdr) 4888c2ecf20Sopenharmony_ci{ 4898c2ecf20Sopenharmony_ci return rmpp_hdr->rmpp_rtime_flags >> 3; 4908c2ecf20Sopenharmony_ci} 4918c2ecf20Sopenharmony_ci 4928c2ecf20Sopenharmony_ci/** 4938c2ecf20Sopenharmony_ci * ib_get_rmpp_flags - Returns the RMPP flags. 4948c2ecf20Sopenharmony_ci * @rmpp_hdr: An RMPP header. 4958c2ecf20Sopenharmony_ci */ 4968c2ecf20Sopenharmony_cistatic inline u8 ib_get_rmpp_flags(struct ib_rmpp_hdr *rmpp_hdr) 4978c2ecf20Sopenharmony_ci{ 4988c2ecf20Sopenharmony_ci return rmpp_hdr->rmpp_rtime_flags & 0x7; 4998c2ecf20Sopenharmony_ci} 5008c2ecf20Sopenharmony_ci 5018c2ecf20Sopenharmony_ci/** 5028c2ecf20Sopenharmony_ci * ib_set_rmpp_resptime - Sets the response time in an RMPP header. 5038c2ecf20Sopenharmony_ci * @rmpp_hdr: An RMPP header. 5048c2ecf20Sopenharmony_ci * @rtime: The response time to set. 5058c2ecf20Sopenharmony_ci */ 5068c2ecf20Sopenharmony_cistatic inline void ib_set_rmpp_resptime(struct ib_rmpp_hdr *rmpp_hdr, u8 rtime) 5078c2ecf20Sopenharmony_ci{ 5088c2ecf20Sopenharmony_ci rmpp_hdr->rmpp_rtime_flags = ib_get_rmpp_flags(rmpp_hdr) | (rtime << 3); 5098c2ecf20Sopenharmony_ci} 5108c2ecf20Sopenharmony_ci 5118c2ecf20Sopenharmony_ci/** 5128c2ecf20Sopenharmony_ci * ib_set_rmpp_flags - Sets the flags in an RMPP header. 5138c2ecf20Sopenharmony_ci * @rmpp_hdr: An RMPP header. 5148c2ecf20Sopenharmony_ci * @flags: The flags to set. 5158c2ecf20Sopenharmony_ci */ 5168c2ecf20Sopenharmony_cistatic inline void ib_set_rmpp_flags(struct ib_rmpp_hdr *rmpp_hdr, u8 flags) 5178c2ecf20Sopenharmony_ci{ 5188c2ecf20Sopenharmony_ci rmpp_hdr->rmpp_rtime_flags = (rmpp_hdr->rmpp_rtime_flags & 0xF8) | 5198c2ecf20Sopenharmony_ci (flags & 0x7); 5208c2ecf20Sopenharmony_ci} 5218c2ecf20Sopenharmony_ci 5228c2ecf20Sopenharmony_cistruct ib_mad_agent; 5238c2ecf20Sopenharmony_cistruct ib_mad_send_wc; 5248c2ecf20Sopenharmony_cistruct ib_mad_recv_wc; 5258c2ecf20Sopenharmony_ci 5268c2ecf20Sopenharmony_ci/** 5278c2ecf20Sopenharmony_ci * ib_mad_send_handler - callback handler for a sent MAD. 5288c2ecf20Sopenharmony_ci * @mad_agent: MAD agent that sent the MAD. 5298c2ecf20Sopenharmony_ci * @mad_send_wc: Send work completion information on the sent MAD. 5308c2ecf20Sopenharmony_ci */ 5318c2ecf20Sopenharmony_citypedef void (*ib_mad_send_handler)(struct ib_mad_agent *mad_agent, 5328c2ecf20Sopenharmony_ci struct ib_mad_send_wc *mad_send_wc); 5338c2ecf20Sopenharmony_ci 5348c2ecf20Sopenharmony_ci/** 5358c2ecf20Sopenharmony_ci * ib_mad_recv_handler - callback handler for a received MAD. 5368c2ecf20Sopenharmony_ci * @mad_agent: MAD agent requesting the received MAD. 5378c2ecf20Sopenharmony_ci * @send_buf: Send buffer if found, else NULL 5388c2ecf20Sopenharmony_ci * @mad_recv_wc: Received work completion information on the received MAD. 5398c2ecf20Sopenharmony_ci * 5408c2ecf20Sopenharmony_ci * MADs received in response to a send request operation will be handed to 5418c2ecf20Sopenharmony_ci * the user before the send operation completes. All data buffers given 5428c2ecf20Sopenharmony_ci * to registered agents through this routine are owned by the receiving 5438c2ecf20Sopenharmony_ci * client. 5448c2ecf20Sopenharmony_ci */ 5458c2ecf20Sopenharmony_citypedef void (*ib_mad_recv_handler)(struct ib_mad_agent *mad_agent, 5468c2ecf20Sopenharmony_ci struct ib_mad_send_buf *send_buf, 5478c2ecf20Sopenharmony_ci struct ib_mad_recv_wc *mad_recv_wc); 5488c2ecf20Sopenharmony_ci 5498c2ecf20Sopenharmony_ci/** 5508c2ecf20Sopenharmony_ci * ib_mad_agent - Used to track MAD registration with the access layer. 5518c2ecf20Sopenharmony_ci * @device: Reference to device registration is on. 5528c2ecf20Sopenharmony_ci * @qp: Reference to QP used for sending and receiving MADs. 5538c2ecf20Sopenharmony_ci * @mr: Memory region for system memory usable for DMA. 5548c2ecf20Sopenharmony_ci * @recv_handler: Callback handler for a received MAD. 5558c2ecf20Sopenharmony_ci * @send_handler: Callback handler for a sent MAD. 5568c2ecf20Sopenharmony_ci * @context: User-specified context associated with this registration. 5578c2ecf20Sopenharmony_ci * @hi_tid: Access layer assigned transaction ID for this client. 5588c2ecf20Sopenharmony_ci * Unsolicited MADs sent by this client will have the upper 32-bits 5598c2ecf20Sopenharmony_ci * of their TID set to this value. 5608c2ecf20Sopenharmony_ci * @flags: registration flags 5618c2ecf20Sopenharmony_ci * @port_num: Port number on which QP is registered 5628c2ecf20Sopenharmony_ci * @rmpp_version: If set, indicates the RMPP version used by this agent. 5638c2ecf20Sopenharmony_ci */ 5648c2ecf20Sopenharmony_cienum { 5658c2ecf20Sopenharmony_ci IB_MAD_USER_RMPP = IB_USER_MAD_USER_RMPP, 5668c2ecf20Sopenharmony_ci}; 5678c2ecf20Sopenharmony_cistruct ib_mad_agent { 5688c2ecf20Sopenharmony_ci struct ib_device *device; 5698c2ecf20Sopenharmony_ci struct ib_qp *qp; 5708c2ecf20Sopenharmony_ci ib_mad_recv_handler recv_handler; 5718c2ecf20Sopenharmony_ci ib_mad_send_handler send_handler; 5728c2ecf20Sopenharmony_ci void *context; 5738c2ecf20Sopenharmony_ci u32 hi_tid; 5748c2ecf20Sopenharmony_ci u32 flags; 5758c2ecf20Sopenharmony_ci void *security; 5768c2ecf20Sopenharmony_ci struct list_head mad_agent_sec_list; 5778c2ecf20Sopenharmony_ci u8 port_num; 5788c2ecf20Sopenharmony_ci u8 rmpp_version; 5798c2ecf20Sopenharmony_ci bool smp_allowed; 5808c2ecf20Sopenharmony_ci}; 5818c2ecf20Sopenharmony_ci 5828c2ecf20Sopenharmony_ci/** 5838c2ecf20Sopenharmony_ci * ib_mad_send_wc - MAD send completion information. 5848c2ecf20Sopenharmony_ci * @send_buf: Send MAD data buffer associated with the send MAD request. 5858c2ecf20Sopenharmony_ci * @status: Completion status. 5868c2ecf20Sopenharmony_ci * @vendor_err: Optional vendor error information returned with a failed 5878c2ecf20Sopenharmony_ci * request. 5888c2ecf20Sopenharmony_ci */ 5898c2ecf20Sopenharmony_cistruct ib_mad_send_wc { 5908c2ecf20Sopenharmony_ci struct ib_mad_send_buf *send_buf; 5918c2ecf20Sopenharmony_ci enum ib_wc_status status; 5928c2ecf20Sopenharmony_ci u32 vendor_err; 5938c2ecf20Sopenharmony_ci}; 5948c2ecf20Sopenharmony_ci 5958c2ecf20Sopenharmony_ci/** 5968c2ecf20Sopenharmony_ci * ib_mad_recv_buf - received MAD buffer information. 5978c2ecf20Sopenharmony_ci * @list: Reference to next data buffer for a received RMPP MAD. 5988c2ecf20Sopenharmony_ci * @grh: References a data buffer containing the global route header. 5998c2ecf20Sopenharmony_ci * The data refereced by this buffer is only valid if the GRH is 6008c2ecf20Sopenharmony_ci * valid. 6018c2ecf20Sopenharmony_ci * @mad: References the start of the received MAD. 6028c2ecf20Sopenharmony_ci */ 6038c2ecf20Sopenharmony_cistruct ib_mad_recv_buf { 6048c2ecf20Sopenharmony_ci struct list_head list; 6058c2ecf20Sopenharmony_ci struct ib_grh *grh; 6068c2ecf20Sopenharmony_ci union { 6078c2ecf20Sopenharmony_ci struct ib_mad *mad; 6088c2ecf20Sopenharmony_ci struct opa_mad *opa_mad; 6098c2ecf20Sopenharmony_ci }; 6108c2ecf20Sopenharmony_ci}; 6118c2ecf20Sopenharmony_ci 6128c2ecf20Sopenharmony_ci/** 6138c2ecf20Sopenharmony_ci * ib_mad_recv_wc - received MAD information. 6148c2ecf20Sopenharmony_ci * @wc: Completion information for the received data. 6158c2ecf20Sopenharmony_ci * @recv_buf: Specifies the location of the received data buffer(s). 6168c2ecf20Sopenharmony_ci * @rmpp_list: Specifies a list of RMPP reassembled received MAD buffers. 6178c2ecf20Sopenharmony_ci * @mad_len: The length of the received MAD, without duplicated headers. 6188c2ecf20Sopenharmony_ci * @mad_seg_size: The size of individual MAD segments 6198c2ecf20Sopenharmony_ci * 6208c2ecf20Sopenharmony_ci * For received response, the wr_id contains a pointer to the ib_mad_send_buf 6218c2ecf20Sopenharmony_ci * for the corresponding send request. 6228c2ecf20Sopenharmony_ci */ 6238c2ecf20Sopenharmony_cistruct ib_mad_recv_wc { 6248c2ecf20Sopenharmony_ci struct ib_wc *wc; 6258c2ecf20Sopenharmony_ci struct ib_mad_recv_buf recv_buf; 6268c2ecf20Sopenharmony_ci struct list_head rmpp_list; 6278c2ecf20Sopenharmony_ci int mad_len; 6288c2ecf20Sopenharmony_ci size_t mad_seg_size; 6298c2ecf20Sopenharmony_ci}; 6308c2ecf20Sopenharmony_ci 6318c2ecf20Sopenharmony_ci/** 6328c2ecf20Sopenharmony_ci * ib_mad_reg_req - MAD registration request 6338c2ecf20Sopenharmony_ci * @mgmt_class: Indicates which management class of MADs should be receive 6348c2ecf20Sopenharmony_ci * by the caller. This field is only required if the user wishes to 6358c2ecf20Sopenharmony_ci * receive unsolicited MADs, otherwise it should be 0. 6368c2ecf20Sopenharmony_ci * @mgmt_class_version: Indicates which version of MADs for the given 6378c2ecf20Sopenharmony_ci * management class to receive. 6388c2ecf20Sopenharmony_ci * @oui: Indicates IEEE OUI when mgmt_class is a vendor class 6398c2ecf20Sopenharmony_ci * in the range from 0x30 to 0x4f. Otherwise not used. 6408c2ecf20Sopenharmony_ci * @method_mask: The caller will receive unsolicited MADs for any method 6418c2ecf20Sopenharmony_ci * where @method_mask = 1. 6428c2ecf20Sopenharmony_ci * 6438c2ecf20Sopenharmony_ci */ 6448c2ecf20Sopenharmony_cistruct ib_mad_reg_req { 6458c2ecf20Sopenharmony_ci u8 mgmt_class; 6468c2ecf20Sopenharmony_ci u8 mgmt_class_version; 6478c2ecf20Sopenharmony_ci u8 oui[3]; 6488c2ecf20Sopenharmony_ci DECLARE_BITMAP(method_mask, IB_MGMT_MAX_METHODS); 6498c2ecf20Sopenharmony_ci}; 6508c2ecf20Sopenharmony_ci 6518c2ecf20Sopenharmony_ci/** 6528c2ecf20Sopenharmony_ci * ib_register_mad_agent - Register to send/receive MADs. 6538c2ecf20Sopenharmony_ci * @device: The device to register with. 6548c2ecf20Sopenharmony_ci * @port_num: The port on the specified device to use. 6558c2ecf20Sopenharmony_ci * @qp_type: Specifies which QP to access. Must be either 6568c2ecf20Sopenharmony_ci * IB_QPT_SMI or IB_QPT_GSI. 6578c2ecf20Sopenharmony_ci * @mad_reg_req: Specifies which unsolicited MADs should be received 6588c2ecf20Sopenharmony_ci * by the caller. This parameter may be NULL if the caller only 6598c2ecf20Sopenharmony_ci * wishes to receive solicited responses. 6608c2ecf20Sopenharmony_ci * @rmpp_version: If set, indicates that the client will send 6618c2ecf20Sopenharmony_ci * and receive MADs that contain the RMPP header for the given version. 6628c2ecf20Sopenharmony_ci * If set to 0, indicates that RMPP is not used by this client. 6638c2ecf20Sopenharmony_ci * @send_handler: The completion callback routine invoked after a send 6648c2ecf20Sopenharmony_ci * request has completed. 6658c2ecf20Sopenharmony_ci * @recv_handler: The completion callback routine invoked for a received 6668c2ecf20Sopenharmony_ci * MAD. 6678c2ecf20Sopenharmony_ci * @context: User specified context associated with the registration. 6688c2ecf20Sopenharmony_ci * @registration_flags: Registration flags to set for this agent 6698c2ecf20Sopenharmony_ci */ 6708c2ecf20Sopenharmony_cistruct ib_mad_agent *ib_register_mad_agent(struct ib_device *device, 6718c2ecf20Sopenharmony_ci u8 port_num, 6728c2ecf20Sopenharmony_ci enum ib_qp_type qp_type, 6738c2ecf20Sopenharmony_ci struct ib_mad_reg_req *mad_reg_req, 6748c2ecf20Sopenharmony_ci u8 rmpp_version, 6758c2ecf20Sopenharmony_ci ib_mad_send_handler send_handler, 6768c2ecf20Sopenharmony_ci ib_mad_recv_handler recv_handler, 6778c2ecf20Sopenharmony_ci void *context, 6788c2ecf20Sopenharmony_ci u32 registration_flags); 6798c2ecf20Sopenharmony_ci/** 6808c2ecf20Sopenharmony_ci * ib_unregister_mad_agent - Unregisters a client from using MAD services. 6818c2ecf20Sopenharmony_ci * @mad_agent: Corresponding MAD registration request to deregister. 6828c2ecf20Sopenharmony_ci * 6838c2ecf20Sopenharmony_ci * After invoking this routine, MAD services are no longer usable by the 6848c2ecf20Sopenharmony_ci * client on the associated QP. 6858c2ecf20Sopenharmony_ci */ 6868c2ecf20Sopenharmony_civoid ib_unregister_mad_agent(struct ib_mad_agent *mad_agent); 6878c2ecf20Sopenharmony_ci 6888c2ecf20Sopenharmony_ci/** 6898c2ecf20Sopenharmony_ci * ib_post_send_mad - Posts MAD(s) to the send queue of the QP associated 6908c2ecf20Sopenharmony_ci * with the registered client. 6918c2ecf20Sopenharmony_ci * @send_buf: Specifies the information needed to send the MAD(s). 6928c2ecf20Sopenharmony_ci * @bad_send_buf: Specifies the MAD on which an error was encountered. This 6938c2ecf20Sopenharmony_ci * parameter is optional if only a single MAD is posted. 6948c2ecf20Sopenharmony_ci * 6958c2ecf20Sopenharmony_ci * Sent MADs are not guaranteed to complete in the order that they were posted. 6968c2ecf20Sopenharmony_ci * 6978c2ecf20Sopenharmony_ci * If the MAD requires RMPP, the data buffer should contain a single copy 6988c2ecf20Sopenharmony_ci * of the common MAD, RMPP, and class specific headers, followed by the class 6998c2ecf20Sopenharmony_ci * defined data. If the class defined data would not divide evenly into 7008c2ecf20Sopenharmony_ci * RMPP segments, then space must be allocated at the end of the referenced 7018c2ecf20Sopenharmony_ci * buffer for any required padding. To indicate the amount of class defined 7028c2ecf20Sopenharmony_ci * data being transferred, the paylen_newwin field in the RMPP header should 7038c2ecf20Sopenharmony_ci * be set to the size of the class specific header plus the amount of class 7048c2ecf20Sopenharmony_ci * defined data being transferred. The paylen_newwin field should be 7058c2ecf20Sopenharmony_ci * specified in network-byte order. 7068c2ecf20Sopenharmony_ci */ 7078c2ecf20Sopenharmony_ciint ib_post_send_mad(struct ib_mad_send_buf *send_buf, 7088c2ecf20Sopenharmony_ci struct ib_mad_send_buf **bad_send_buf); 7098c2ecf20Sopenharmony_ci 7108c2ecf20Sopenharmony_ci 7118c2ecf20Sopenharmony_ci/** 7128c2ecf20Sopenharmony_ci * ib_free_recv_mad - Returns data buffers used to receive a MAD. 7138c2ecf20Sopenharmony_ci * @mad_recv_wc: Work completion information for a received MAD. 7148c2ecf20Sopenharmony_ci * 7158c2ecf20Sopenharmony_ci * Clients receiving MADs through their ib_mad_recv_handler must call this 7168c2ecf20Sopenharmony_ci * routine to return the work completion buffers to the access layer. 7178c2ecf20Sopenharmony_ci */ 7188c2ecf20Sopenharmony_civoid ib_free_recv_mad(struct ib_mad_recv_wc *mad_recv_wc); 7198c2ecf20Sopenharmony_ci 7208c2ecf20Sopenharmony_ci/** 7218c2ecf20Sopenharmony_ci * ib_cancel_mad - Cancels an outstanding send MAD operation. 7228c2ecf20Sopenharmony_ci * @mad_agent: Specifies the registration associated with sent MAD. 7238c2ecf20Sopenharmony_ci * @send_buf: Indicates the MAD to cancel. 7248c2ecf20Sopenharmony_ci * 7258c2ecf20Sopenharmony_ci * MADs will be returned to the user through the corresponding 7268c2ecf20Sopenharmony_ci * ib_mad_send_handler. 7278c2ecf20Sopenharmony_ci */ 7288c2ecf20Sopenharmony_civoid ib_cancel_mad(struct ib_mad_agent *mad_agent, 7298c2ecf20Sopenharmony_ci struct ib_mad_send_buf *send_buf); 7308c2ecf20Sopenharmony_ci 7318c2ecf20Sopenharmony_ci/** 7328c2ecf20Sopenharmony_ci * ib_modify_mad - Modifies an outstanding send MAD operation. 7338c2ecf20Sopenharmony_ci * @mad_agent: Specifies the registration associated with sent MAD. 7348c2ecf20Sopenharmony_ci * @send_buf: Indicates the MAD to modify. 7358c2ecf20Sopenharmony_ci * @timeout_ms: New timeout value for sent MAD. 7368c2ecf20Sopenharmony_ci * 7378c2ecf20Sopenharmony_ci * This call will reset the timeout value for a sent MAD to the specified 7388c2ecf20Sopenharmony_ci * value. 7398c2ecf20Sopenharmony_ci */ 7408c2ecf20Sopenharmony_ciint ib_modify_mad(struct ib_mad_agent *mad_agent, 7418c2ecf20Sopenharmony_ci struct ib_mad_send_buf *send_buf, u32 timeout_ms); 7428c2ecf20Sopenharmony_ci 7438c2ecf20Sopenharmony_ci/** 7448c2ecf20Sopenharmony_ci * ib_create_send_mad - Allocate and initialize a data buffer and work request 7458c2ecf20Sopenharmony_ci * for sending a MAD. 7468c2ecf20Sopenharmony_ci * @mad_agent: Specifies the registered MAD service to associate with the MAD. 7478c2ecf20Sopenharmony_ci * @remote_qpn: Specifies the QPN of the receiving node. 7488c2ecf20Sopenharmony_ci * @pkey_index: Specifies which PKey the MAD will be sent using. This field 7498c2ecf20Sopenharmony_ci * is valid only if the remote_qpn is QP 1. 7508c2ecf20Sopenharmony_ci * @rmpp_active: Indicates if the send will enable RMPP. 7518c2ecf20Sopenharmony_ci * @hdr_len: Indicates the size of the data header of the MAD. This length 7528c2ecf20Sopenharmony_ci * should include the common MAD header, RMPP header, plus any class 7538c2ecf20Sopenharmony_ci * specific header. 7548c2ecf20Sopenharmony_ci * @data_len: Indicates the size of any user-transferred data. The call will 7558c2ecf20Sopenharmony_ci * automatically adjust the allocated buffer size to account for any 7568c2ecf20Sopenharmony_ci * additional padding that may be necessary. 7578c2ecf20Sopenharmony_ci * @gfp_mask: GFP mask used for the memory allocation. 7588c2ecf20Sopenharmony_ci * @base_version: Base Version of this MAD 7598c2ecf20Sopenharmony_ci * 7608c2ecf20Sopenharmony_ci * This routine allocates a MAD for sending. The returned MAD send buffer 7618c2ecf20Sopenharmony_ci * will reference a data buffer usable for sending a MAD, along 7628c2ecf20Sopenharmony_ci * with an initialized work request structure. Users may modify the returned 7638c2ecf20Sopenharmony_ci * MAD data buffer before posting the send. 7648c2ecf20Sopenharmony_ci * 7658c2ecf20Sopenharmony_ci * The returned MAD header, class specific headers, and any padding will be 7668c2ecf20Sopenharmony_ci * cleared. Users are responsible for initializing the common MAD header, 7678c2ecf20Sopenharmony_ci * any class specific header, and MAD data area. 7688c2ecf20Sopenharmony_ci * If @rmpp_active is set, the RMPP header will be initialized for sending. 7698c2ecf20Sopenharmony_ci */ 7708c2ecf20Sopenharmony_cistruct ib_mad_send_buf *ib_create_send_mad(struct ib_mad_agent *mad_agent, 7718c2ecf20Sopenharmony_ci u32 remote_qpn, u16 pkey_index, 7728c2ecf20Sopenharmony_ci int rmpp_active, 7738c2ecf20Sopenharmony_ci int hdr_len, int data_len, 7748c2ecf20Sopenharmony_ci gfp_t gfp_mask, 7758c2ecf20Sopenharmony_ci u8 base_version); 7768c2ecf20Sopenharmony_ci 7778c2ecf20Sopenharmony_ci/** 7788c2ecf20Sopenharmony_ci * ib_is_mad_class_rmpp - returns whether given management class 7798c2ecf20Sopenharmony_ci * supports RMPP. 7808c2ecf20Sopenharmony_ci * @mgmt_class: management class 7818c2ecf20Sopenharmony_ci * 7828c2ecf20Sopenharmony_ci * This routine returns whether the management class supports RMPP. 7838c2ecf20Sopenharmony_ci */ 7848c2ecf20Sopenharmony_ciint ib_is_mad_class_rmpp(u8 mgmt_class); 7858c2ecf20Sopenharmony_ci 7868c2ecf20Sopenharmony_ci/** 7878c2ecf20Sopenharmony_ci * ib_get_mad_data_offset - returns the data offset for a given 7888c2ecf20Sopenharmony_ci * management class. 7898c2ecf20Sopenharmony_ci * @mgmt_class: management class 7908c2ecf20Sopenharmony_ci * 7918c2ecf20Sopenharmony_ci * This routine returns the data offset in the MAD for the management 7928c2ecf20Sopenharmony_ci * class requested. 7938c2ecf20Sopenharmony_ci */ 7948c2ecf20Sopenharmony_ciint ib_get_mad_data_offset(u8 mgmt_class); 7958c2ecf20Sopenharmony_ci 7968c2ecf20Sopenharmony_ci/** 7978c2ecf20Sopenharmony_ci * ib_get_rmpp_segment - returns the data buffer for a given RMPP segment. 7988c2ecf20Sopenharmony_ci * @send_buf: Previously allocated send data buffer. 7998c2ecf20Sopenharmony_ci * @seg_num: number of segment to return 8008c2ecf20Sopenharmony_ci * 8018c2ecf20Sopenharmony_ci * This routine returns a pointer to the data buffer of an RMPP MAD. 8028c2ecf20Sopenharmony_ci * Users must provide synchronization to @send_buf around this call. 8038c2ecf20Sopenharmony_ci */ 8048c2ecf20Sopenharmony_civoid *ib_get_rmpp_segment(struct ib_mad_send_buf *send_buf, int seg_num); 8058c2ecf20Sopenharmony_ci 8068c2ecf20Sopenharmony_ci/** 8078c2ecf20Sopenharmony_ci * ib_free_send_mad - Returns data buffers used to send a MAD. 8088c2ecf20Sopenharmony_ci * @send_buf: Previously allocated send data buffer. 8098c2ecf20Sopenharmony_ci */ 8108c2ecf20Sopenharmony_civoid ib_free_send_mad(struct ib_mad_send_buf *send_buf); 8118c2ecf20Sopenharmony_ci 8128c2ecf20Sopenharmony_ci/** 8138c2ecf20Sopenharmony_ci * ib_mad_kernel_rmpp_agent - Returns if the agent is performing RMPP. 8148c2ecf20Sopenharmony_ci * @agent: the agent in question 8158c2ecf20Sopenharmony_ci * @return: true if agent is performing rmpp, false otherwise. 8168c2ecf20Sopenharmony_ci */ 8178c2ecf20Sopenharmony_ciint ib_mad_kernel_rmpp_agent(const struct ib_mad_agent *agent); 8188c2ecf20Sopenharmony_ci 8198c2ecf20Sopenharmony_ci#endif /* IB_MAD_H */ 820