1f28990bcSIra Weiny /* 2f28990bcSIra Weiny * Copyright (c) 2014 Intel Corporation. All rights reserved. 3f28990bcSIra Weiny * 4f28990bcSIra Weiny * This software is available to you under a choice of one of two 5f28990bcSIra Weiny * licenses. You may choose to be licensed under the terms of the GNU 6f28990bcSIra Weiny * General Public License (GPL) Version 2, available from the file 7f28990bcSIra Weiny * COPYING in the main directory of this source tree, or the 8f28990bcSIra Weiny * OpenIB.org BSD license below: 9f28990bcSIra Weiny * 10f28990bcSIra Weiny * Redistribution and use in source and binary forms, with or 11f28990bcSIra Weiny * without modification, are permitted provided that the following 12f28990bcSIra Weiny * conditions are met: 13f28990bcSIra Weiny * 14f28990bcSIra Weiny * - Redistributions of source code must retain the above 15f28990bcSIra Weiny * copyright notice, this list of conditions and the following 16f28990bcSIra Weiny * disclaimer. 17f28990bcSIra Weiny * 18f28990bcSIra Weiny * - Redistributions in binary form must reproduce the above 19f28990bcSIra Weiny * copyright notice, this list of conditions and the following 20f28990bcSIra Weiny * disclaimer in the documentation and/or other materials 21f28990bcSIra Weiny * provided with the distribution. 22f28990bcSIra Weiny * 23f28990bcSIra Weiny * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24f28990bcSIra Weiny * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25f28990bcSIra Weiny * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26f28990bcSIra Weiny * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27f28990bcSIra Weiny * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28f28990bcSIra Weiny * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29f28990bcSIra Weiny * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30f28990bcSIra Weiny * SOFTWARE. 31f28990bcSIra Weiny */ 32f28990bcSIra Weiny 33f28990bcSIra Weiny #if !defined(OPA_SMI_H) 34f28990bcSIra Weiny #define OPA_SMI_H 35f28990bcSIra Weiny 36f28990bcSIra Weiny #include <rdma/ib_mad.h> 37f28990bcSIra Weiny #include <rdma/ib_smi.h> 38f28990bcSIra Weiny 39f28990bcSIra Weiny #define OPA_SMP_LID_DATA_SIZE 2016 40f28990bcSIra Weiny #define OPA_SMP_DR_DATA_SIZE 1872 41f28990bcSIra Weiny #define OPA_SMP_MAX_PATH_HOPS 64 42f28990bcSIra Weiny 43d4ab3470SDennis Dalessandro #define OPA_MAX_VLS 32 44d4ab3470SDennis Dalessandro #define OPA_MAX_SLS 32 45d4ab3470SDennis Dalessandro #define OPA_MAX_SCS 32 46d4ab3470SDennis Dalessandro 47f28990bcSIra Weiny #define OPA_LID_PERMISSIVE cpu_to_be32(0xFFFFFFFF) 48f28990bcSIra Weiny 49f28990bcSIra Weiny struct opa_smp { 50f28990bcSIra Weiny u8 base_version; 51f28990bcSIra Weiny u8 mgmt_class; 52f28990bcSIra Weiny u8 class_version; 53f28990bcSIra Weiny u8 method; 54f28990bcSIra Weiny __be16 status; 55f28990bcSIra Weiny u8 hop_ptr; 56f28990bcSIra Weiny u8 hop_cnt; 57f28990bcSIra Weiny __be64 tid; 58f28990bcSIra Weiny __be16 attr_id; 59f28990bcSIra Weiny __be16 resv; 60f28990bcSIra Weiny __be32 attr_mod; 61f28990bcSIra Weiny __be64 mkey; 62f28990bcSIra Weiny union { 63f28990bcSIra Weiny struct { 64f28990bcSIra Weiny uint8_t data[OPA_SMP_LID_DATA_SIZE]; 65f28990bcSIra Weiny } lid; 66f28990bcSIra Weiny struct { 67f28990bcSIra Weiny __be32 dr_slid; 68f28990bcSIra Weiny __be32 dr_dlid; 69f28990bcSIra Weiny u8 initial_path[OPA_SMP_MAX_PATH_HOPS]; 70f28990bcSIra Weiny u8 return_path[OPA_SMP_MAX_PATH_HOPS]; 71f28990bcSIra Weiny u8 reserved[8]; 72f28990bcSIra Weiny u8 data[OPA_SMP_DR_DATA_SIZE]; 73f28990bcSIra Weiny } dr; 74f28990bcSIra Weiny } route; 75f28990bcSIra Weiny } __packed; 76f28990bcSIra Weiny 77f28990bcSIra Weiny 78d4ab3470SDennis Dalessandro /* Subnet management attributes */ 79d4ab3470SDennis Dalessandro /* ... */ 80d4ab3470SDennis Dalessandro #define OPA_ATTRIB_ID_NODE_DESCRIPTION cpu_to_be16(0x0010) 81d4ab3470SDennis Dalessandro #define OPA_ATTRIB_ID_NODE_INFO cpu_to_be16(0x0011) 82d4ab3470SDennis Dalessandro #define OPA_ATTRIB_ID_PORT_INFO cpu_to_be16(0x0015) 83d4ab3470SDennis Dalessandro #define OPA_ATTRIB_ID_PARTITION_TABLE cpu_to_be16(0x0016) 84d4ab3470SDennis Dalessandro #define OPA_ATTRIB_ID_SL_TO_SC_MAP cpu_to_be16(0x0017) 85d4ab3470SDennis Dalessandro #define OPA_ATTRIB_ID_VL_ARBITRATION cpu_to_be16(0x0018) 86d4ab3470SDennis Dalessandro #define OPA_ATTRIB_ID_SM_INFO cpu_to_be16(0x0020) 87d4ab3470SDennis Dalessandro #define OPA_ATTRIB_ID_CABLE_INFO cpu_to_be16(0x0032) 88d4ab3470SDennis Dalessandro #define OPA_ATTRIB_ID_AGGREGATE cpu_to_be16(0x0080) 89d4ab3470SDennis Dalessandro #define OPA_ATTRIB_ID_SC_TO_SL_MAP cpu_to_be16(0x0082) 90d4ab3470SDennis Dalessandro #define OPA_ATTRIB_ID_SC_TO_VLR_MAP cpu_to_be16(0x0083) 91d4ab3470SDennis Dalessandro #define OPA_ATTRIB_ID_SC_TO_VLT_MAP cpu_to_be16(0x0084) 92d4ab3470SDennis Dalessandro #define OPA_ATTRIB_ID_SC_TO_VLNT_MAP cpu_to_be16(0x0085) 93d4ab3470SDennis Dalessandro /* ... */ 94d4ab3470SDennis Dalessandro #define OPA_ATTRIB_ID_PORT_STATE_INFO cpu_to_be16(0x0087) 95d4ab3470SDennis Dalessandro /* ... */ 96d4ab3470SDennis Dalessandro #define OPA_ATTRIB_ID_BUFFER_CONTROL_TABLE cpu_to_be16(0x008A) 97d4ab3470SDennis Dalessandro /* ... */ 98d4ab3470SDennis Dalessandro 99d4ab3470SDennis Dalessandro struct opa_node_description { 100d4ab3470SDennis Dalessandro u8 data[64]; 101*19b1a294SErez Alfasi } __packed; 102d4ab3470SDennis Dalessandro 103d4ab3470SDennis Dalessandro struct opa_node_info { 104d4ab3470SDennis Dalessandro u8 base_version; 105d4ab3470SDennis Dalessandro u8 class_version; 106d4ab3470SDennis Dalessandro u8 node_type; 107d4ab3470SDennis Dalessandro u8 num_ports; 108d4ab3470SDennis Dalessandro __be32 reserved; 109d4ab3470SDennis Dalessandro __be64 system_image_guid; 110d4ab3470SDennis Dalessandro __be64 node_guid; 111d4ab3470SDennis Dalessandro __be64 port_guid; 112d4ab3470SDennis Dalessandro __be16 partition_cap; 113d4ab3470SDennis Dalessandro __be16 device_id; 114d4ab3470SDennis Dalessandro __be32 revision; 115d4ab3470SDennis Dalessandro u8 local_port_num; 116d4ab3470SDennis Dalessandro u8 vendor_id[3]; /* network byte order */ 117*19b1a294SErez Alfasi } __packed; 118d4ab3470SDennis Dalessandro 119d4ab3470SDennis Dalessandro #define OPA_PARTITION_TABLE_BLK_SIZE 32 120d4ab3470SDennis Dalessandro 121f28990bcSIra Weiny static inline u8 122f28990bcSIra Weiny opa_get_smp_direction(struct opa_smp *smp) 123f28990bcSIra Weiny { 124f28990bcSIra Weiny return ib_get_smp_direction((struct ib_smp *)smp); 125f28990bcSIra Weiny } 126f28990bcSIra Weiny 127f28990bcSIra Weiny static inline u8 *opa_get_smp_data(struct opa_smp *smp) 128f28990bcSIra Weiny { 129f28990bcSIra Weiny if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) 130f28990bcSIra Weiny return smp->route.dr.data; 131f28990bcSIra Weiny 132f28990bcSIra Weiny return smp->route.lid.data; 133f28990bcSIra Weiny } 134f28990bcSIra Weiny 135f28990bcSIra Weiny static inline size_t opa_get_smp_data_size(struct opa_smp *smp) 136f28990bcSIra Weiny { 137f28990bcSIra Weiny if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) 138f28990bcSIra Weiny return sizeof(smp->route.dr.data); 139f28990bcSIra Weiny 140f28990bcSIra Weiny return sizeof(smp->route.lid.data); 141f28990bcSIra Weiny } 142f28990bcSIra Weiny 143f28990bcSIra Weiny static inline size_t opa_get_smp_header_size(struct opa_smp *smp) 144f28990bcSIra Weiny { 145f28990bcSIra Weiny if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) 146f28990bcSIra Weiny return sizeof(*smp) - sizeof(smp->route.dr.data); 147f28990bcSIra Weiny 148f28990bcSIra Weiny return sizeof(*smp) - sizeof(smp->route.lid.data); 149f28990bcSIra Weiny } 150f28990bcSIra Weiny 151f28990bcSIra Weiny #endif /* OPA_SMI_H */ 152