Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

IB/mad: Add partial Intel OPA MAD support

Add OPA SMP processing functionality.

Define the new OPA SMP format, create support functions for this format using
the previously defined helper functions as appropriate.

These functions are defined in this patch and used in the final OPA MAD support
patch.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>

authored by

Ira Weiny and committed by
Doug Ledford
f28990bc 548ead17

+239
+1
drivers/infiniband/core/mad_priv.h
··· 41 41 #include <linux/workqueue.h> 42 42 #include <rdma/ib_mad.h> 43 43 #include <rdma/ib_smi.h> 44 + #include <rdma/opa_smi.h> 44 45 45 46 #define IB_MAD_QPS_CORE 2 /* Always QP0 and QP1 as a minimum */ 46 47
+78
drivers/infiniband/core/opa_smi.h
··· 1 + /* 2 + * Copyright (c) 2014 Intel Corporation. All rights reserved. 3 + * 4 + * This software is available to you under a choice of one of two 5 + * licenses. You may choose to be licensed under the terms of the GNU 6 + * General Public License (GPL) Version 2, available from the file 7 + * COPYING in the main directory of this source tree, or the 8 + * OpenIB.org BSD license below: 9 + * 10 + * Redistribution and use in source and binary forms, with or 11 + * without modification, are permitted provided that the following 12 + * conditions are met: 13 + * 14 + * - Redistributions of source code must retain the above 15 + * copyright notice, this list of conditions and the following 16 + * disclaimer. 17 + * 18 + * - Redistributions in binary form must reproduce the above 19 + * copyright notice, this list of conditions and the following 20 + * disclaimer in the documentation and/or other materials 21 + * provided with the distribution. 22 + * 23 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27 + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28 + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 + * SOFTWARE. 31 + * 32 + */ 33 + 34 + #ifndef __OPA_SMI_H_ 35 + #define __OPA_SMI_H_ 36 + 37 + #include <rdma/ib_smi.h> 38 + #include <rdma/opa_smi.h> 39 + 40 + #include "smi.h" 41 + 42 + enum smi_action opa_smi_handle_dr_smp_recv(struct opa_smp *smp, u8 node_type, 43 + int port_num, int phys_port_cnt); 44 + int opa_smi_get_fwd_port(struct opa_smp *smp); 45 + extern enum smi_forward_action opa_smi_check_forward_dr_smp(struct opa_smp *smp); 46 + extern enum smi_action opa_smi_handle_dr_smp_send(struct opa_smp *smp, 47 + u8 node_type, int port_num); 48 + 49 + /* 50 + * Return IB_SMI_HANDLE if the SMP should be handled by the local SMA/SM 51 + * via process_mad 52 + */ 53 + static inline enum smi_action opa_smi_check_local_smp(struct opa_smp *smp, 54 + struct ib_device *device) 55 + { 56 + /* C14-9:3 -- We're at the end of the DR segment of path */ 57 + /* C14-9:4 -- Hop Pointer = Hop Count + 1 -> give to SMA/SM */ 58 + return (device->process_mad && 59 + !opa_get_smp_direction(smp) && 60 + (smp->hop_ptr == smp->hop_cnt + 1)) ? 61 + IB_SMI_HANDLE : IB_SMI_DISCARD; 62 + } 63 + 64 + /* 65 + * Return IB_SMI_HANDLE if the SMP should be handled by the local SMA/SM 66 + * via process_mad 67 + */ 68 + static inline enum smi_action opa_smi_check_local_returning_smp(struct opa_smp *smp, 69 + struct ib_device *device) 70 + { 71 + /* C14-13:3 -- We're at the end of the DR segment of path */ 72 + /* C14-13:4 -- Hop Pointer == 0 -> give to SM */ 73 + return (device->process_mad && 74 + opa_get_smp_direction(smp) && 75 + !smp->hop_ptr) ? IB_SMI_HANDLE : IB_SMI_DISCARD; 76 + } 77 + 78 + #endif /* __OPA_SMI_H_ */
+54
drivers/infiniband/core/smi.c
··· 5 5 * Copyright (c) 2004, 2005 Topspin Corporation. All rights reserved. 6 6 * Copyright (c) 2004-2007 Voltaire Corporation. All rights reserved. 7 7 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 8 + * Copyright (c) 2014 Intel Corporation. All rights reserved. 8 9 * 9 10 * This software is available to you under a choice of one of two 10 11 * licenses. You may choose to be licensed under the terms of the GNU ··· 39 38 40 39 #include <rdma/ib_smi.h> 41 40 #include "smi.h" 41 + #include "opa_smi.h" 42 42 43 43 static enum smi_action __smi_handle_dr_smp_send(u8 node_type, int port_num, 44 44 u8 *hop_ptr, u8 hop_cnt, ··· 136 134 ib_get_smp_direction(smp), 137 135 smp->dr_dlid == IB_LID_PERMISSIVE, 138 136 smp->dr_slid == IB_LID_PERMISSIVE); 137 + } 138 + 139 + enum smi_action opa_smi_handle_dr_smp_send(struct opa_smp *smp, 140 + u8 node_type, int port_num) 141 + { 142 + return __smi_handle_dr_smp_send(node_type, port_num, 143 + &smp->hop_ptr, smp->hop_cnt, 144 + smp->route.dr.initial_path, 145 + smp->route.dr.return_path, 146 + opa_get_smp_direction(smp), 147 + smp->route.dr.dr_dlid == 148 + OPA_LID_PERMISSIVE, 149 + smp->route.dr.dr_slid == 150 + OPA_LID_PERMISSIVE); 139 151 } 140 152 141 153 static enum smi_action __smi_handle_dr_smp_recv(u8 node_type, int port_num, ··· 250 234 smp->dr_slid == IB_LID_PERMISSIVE); 251 235 } 252 236 237 + /* 238 + * Adjust information for a received SMP 239 + * Return IB_SMI_DISCARD if the SMP should be dropped 240 + */ 241 + enum smi_action opa_smi_handle_dr_smp_recv(struct opa_smp *smp, u8 node_type, 242 + int port_num, int phys_port_cnt) 243 + { 244 + return __smi_handle_dr_smp_recv(node_type, port_num, phys_port_cnt, 245 + &smp->hop_ptr, smp->hop_cnt, 246 + smp->route.dr.initial_path, 247 + smp->route.dr.return_path, 248 + opa_get_smp_direction(smp), 249 + smp->route.dr.dr_dlid == 250 + OPA_LID_PERMISSIVE, 251 + smp->route.dr.dr_slid == 252 + OPA_LID_PERMISSIVE); 253 + } 254 + 253 255 static enum smi_forward_action __smi_check_forward_dr_smp(u8 hop_ptr, u8 hop_cnt, 254 256 u8 direction, 255 257 bool dr_dlid_is_permissive, ··· 308 274 smp->dr_slid == IB_LID_PERMISSIVE); 309 275 } 310 276 277 + enum smi_forward_action opa_smi_check_forward_dr_smp(struct opa_smp *smp) 278 + { 279 + return __smi_check_forward_dr_smp(smp->hop_ptr, smp->hop_cnt, 280 + opa_get_smp_direction(smp), 281 + smp->route.dr.dr_dlid == 282 + OPA_LID_PERMISSIVE, 283 + smp->route.dr.dr_slid == 284 + OPA_LID_PERMISSIVE); 285 + } 286 + 311 287 /* 312 288 * Return the forwarding port number from initial_path for outgoing SMP and 313 289 * from return_path for returning SMP ··· 326 282 { 327 283 return (!ib_get_smp_direction(smp) ? smp->initial_path[smp->hop_ptr+1] : 328 284 smp->return_path[smp->hop_ptr-1]); 285 + } 286 + 287 + /* 288 + * Return the forwarding port number from initial_path for outgoing SMP and 289 + * from return_path for returning SMP 290 + */ 291 + int opa_smi_get_fwd_port(struct opa_smp *smp) 292 + { 293 + return !opa_get_smp_direction(smp) ? smp->route.dr.initial_path[smp->hop_ptr+1] : 294 + smp->route.dr.return_path[smp->hop_ptr-1]; 329 295 }
+106
include/rdma/opa_smi.h
··· 1 + /* 2 + * Copyright (c) 2014 Intel Corporation. All rights reserved. 3 + * 4 + * This software is available to you under a choice of one of two 5 + * licenses. You may choose to be licensed under the terms of the GNU 6 + * General Public License (GPL) Version 2, available from the file 7 + * COPYING in the main directory of this source tree, or the 8 + * OpenIB.org BSD license below: 9 + * 10 + * Redistribution and use in source and binary forms, with or 11 + * without modification, are permitted provided that the following 12 + * conditions are met: 13 + * 14 + * - Redistributions of source code must retain the above 15 + * copyright notice, this list of conditions and the following 16 + * disclaimer. 17 + * 18 + * - Redistributions in binary form must reproduce the above 19 + * copyright notice, this list of conditions and the following 20 + * disclaimer in the documentation and/or other materials 21 + * provided with the distribution. 22 + * 23 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27 + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28 + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 + * SOFTWARE. 31 + */ 32 + 33 + #if !defined(OPA_SMI_H) 34 + #define OPA_SMI_H 35 + 36 + #include <rdma/ib_mad.h> 37 + #include <rdma/ib_smi.h> 38 + 39 + #define OPA_SMP_LID_DATA_SIZE 2016 40 + #define OPA_SMP_DR_DATA_SIZE 1872 41 + #define OPA_SMP_MAX_PATH_HOPS 64 42 + 43 + #define OPA_SMI_CLASS_VERSION 0x80 44 + 45 + #define OPA_LID_PERMISSIVE cpu_to_be32(0xFFFFFFFF) 46 + 47 + struct opa_smp { 48 + u8 base_version; 49 + u8 mgmt_class; 50 + u8 class_version; 51 + u8 method; 52 + __be16 status; 53 + u8 hop_ptr; 54 + u8 hop_cnt; 55 + __be64 tid; 56 + __be16 attr_id; 57 + __be16 resv; 58 + __be32 attr_mod; 59 + __be64 mkey; 60 + union { 61 + struct { 62 + uint8_t data[OPA_SMP_LID_DATA_SIZE]; 63 + } lid; 64 + struct { 65 + __be32 dr_slid; 66 + __be32 dr_dlid; 67 + u8 initial_path[OPA_SMP_MAX_PATH_HOPS]; 68 + u8 return_path[OPA_SMP_MAX_PATH_HOPS]; 69 + u8 reserved[8]; 70 + u8 data[OPA_SMP_DR_DATA_SIZE]; 71 + } dr; 72 + } route; 73 + } __packed; 74 + 75 + 76 + static inline u8 77 + opa_get_smp_direction(struct opa_smp *smp) 78 + { 79 + return ib_get_smp_direction((struct ib_smp *)smp); 80 + } 81 + 82 + static inline u8 *opa_get_smp_data(struct opa_smp *smp) 83 + { 84 + if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) 85 + return smp->route.dr.data; 86 + 87 + return smp->route.lid.data; 88 + } 89 + 90 + static inline size_t opa_get_smp_data_size(struct opa_smp *smp) 91 + { 92 + if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) 93 + return sizeof(smp->route.dr.data); 94 + 95 + return sizeof(smp->route.lid.data); 96 + } 97 + 98 + static inline size_t opa_get_smp_header_size(struct opa_smp *smp) 99 + { 100 + if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) 101 + return sizeof(*smp) - sizeof(smp->route.dr.data); 102 + 103 + return sizeof(*smp) - sizeof(smp->route.lid.data); 104 + } 105 + 106 + #endif /* OPA_SMI_H */