Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
0002 /*
0003  * Copyright (c) 2014 Intel Corporation.  All rights reserved.
0004  */
0005 
0006 #ifndef OPA_SMI_H
0007 #define OPA_SMI_H
0008 
0009 #include <rdma/ib_mad.h>
0010 #include <rdma/ib_smi.h>
0011 
0012 #define OPA_SMP_LID_DATA_SIZE           2016
0013 #define OPA_SMP_DR_DATA_SIZE            1872
0014 #define OPA_SMP_MAX_PATH_HOPS           64
0015 
0016 #define OPA_MAX_VLS             32
0017 #define OPA_MAX_SLS             32
0018 #define OPA_MAX_SCS             32
0019 
0020 #define OPA_LID_PERMISSIVE          cpu_to_be32(0xFFFFFFFF)
0021 
0022 struct opa_smp {
0023     u8  base_version;
0024     u8  mgmt_class;
0025     u8  class_version;
0026     u8  method;
0027     __be16  status;
0028     u8  hop_ptr;
0029     u8  hop_cnt;
0030     __be64  tid;
0031     __be16  attr_id;
0032     __be16  resv;
0033     __be32  attr_mod;
0034     __be64  mkey;
0035     union {
0036         struct {
0037             uint8_t data[OPA_SMP_LID_DATA_SIZE];
0038         } lid;
0039         struct {
0040             __be32  dr_slid;
0041             __be32  dr_dlid;
0042             u8  initial_path[OPA_SMP_MAX_PATH_HOPS];
0043             u8  return_path[OPA_SMP_MAX_PATH_HOPS];
0044             u8  reserved[8];
0045             u8  data[OPA_SMP_DR_DATA_SIZE];
0046         } dr;
0047     } route;
0048 } __packed;
0049 
0050 
0051 /* Subnet management attributes */
0052 /* ... */
0053 #define OPA_ATTRIB_ID_NODE_DESCRIPTION      cpu_to_be16(0x0010)
0054 #define OPA_ATTRIB_ID_NODE_INFO         cpu_to_be16(0x0011)
0055 #define OPA_ATTRIB_ID_PORT_INFO         cpu_to_be16(0x0015)
0056 #define OPA_ATTRIB_ID_PARTITION_TABLE       cpu_to_be16(0x0016)
0057 #define OPA_ATTRIB_ID_SL_TO_SC_MAP      cpu_to_be16(0x0017)
0058 #define OPA_ATTRIB_ID_VL_ARBITRATION        cpu_to_be16(0x0018)
0059 #define OPA_ATTRIB_ID_SM_INFO           cpu_to_be16(0x0020)
0060 #define OPA_ATTRIB_ID_CABLE_INFO        cpu_to_be16(0x0032)
0061 #define OPA_ATTRIB_ID_AGGREGATE         cpu_to_be16(0x0080)
0062 #define OPA_ATTRIB_ID_SC_TO_SL_MAP      cpu_to_be16(0x0082)
0063 #define OPA_ATTRIB_ID_SC_TO_VLR_MAP     cpu_to_be16(0x0083)
0064 #define OPA_ATTRIB_ID_SC_TO_VLT_MAP     cpu_to_be16(0x0084)
0065 #define OPA_ATTRIB_ID_SC_TO_VLNT_MAP        cpu_to_be16(0x0085)
0066 /* ... */
0067 #define OPA_ATTRIB_ID_PORT_STATE_INFO       cpu_to_be16(0x0087)
0068 /* ... */
0069 #define OPA_ATTRIB_ID_BUFFER_CONTROL_TABLE  cpu_to_be16(0x008A)
0070 /* ... */
0071 
0072 struct opa_node_description {
0073     u8 data[64];
0074 } __packed;
0075 
0076 struct opa_node_info {
0077     u8      base_version;
0078     u8      class_version;
0079     u8      node_type;
0080     u8      num_ports;
0081     __be32  reserved;
0082     __be64  system_image_guid;
0083     __be64  node_guid;
0084     __be64  port_guid;
0085     __be16  partition_cap;
0086     __be16  device_id;
0087     __be32  revision;
0088     u8      local_port_num;
0089     u8      vendor_id[3];   /* network byte order */
0090 } __packed;
0091 
0092 #define OPA_PARTITION_TABLE_BLK_SIZE 32
0093 
0094 static inline u8
0095 opa_get_smp_direction(struct opa_smp *smp)
0096 {
0097     return ib_get_smp_direction((struct ib_smp *)smp);
0098 }
0099 
0100 static inline u8 *opa_get_smp_data(struct opa_smp *smp)
0101 {
0102     if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
0103         return smp->route.dr.data;
0104 
0105     return smp->route.lid.data;
0106 }
0107 
0108 static inline size_t opa_get_smp_data_size(struct opa_smp *smp)
0109 {
0110     if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
0111         return sizeof(smp->route.dr.data);
0112 
0113     return sizeof(smp->route.lid.data);
0114 }
0115 
0116 static inline size_t opa_get_smp_header_size(struct opa_smp *smp)
0117 {
0118     if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
0119         return sizeof(*smp) - sizeof(smp->route.dr.data);
0120 
0121     return sizeof(*smp) - sizeof(smp->route.lid.data);
0122 }
0123 
0124 #endif /* OPA_SMI_H */