mlx4_ib_cm.c (270710) | mlx4_ib_cm.c (278886) |
---|---|
1/* 2 * Copyright (c) 2012 Mellanox Technologies. 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: --- 19 unchanged lines hidden (view full) --- 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#include <rdma/ib_mad.h> 34 35#include <linux/mlx4/cmd.h> | 1/* 2 * Copyright (c) 2012 Mellanox Technologies. 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: --- 19 unchanged lines hidden (view full) --- 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#include <rdma/ib_mad.h> 34 35#include <linux/mlx4/cmd.h> |
36#include <linux/rbtree.h> |
|
36#include <linux/idr.h> 37#include <rdma/ib_cm.h> 38 39#include "mlx4_ib.h" 40 41#define CM_CLEANUP_CACHE_TIMEOUT (5 * HZ) 42 43struct id_map_entry { --- 11 unchanged lines hidden (view full) --- 55 56struct cm_generic_msg { 57 struct ib_mad_hdr hdr; 58 59 __be32 local_comm_id; 60 __be32 remote_comm_id; 61}; 62 | 37#include <linux/idr.h> 38#include <rdma/ib_cm.h> 39 40#include "mlx4_ib.h" 41 42#define CM_CLEANUP_CACHE_TIMEOUT (5 * HZ) 43 44struct id_map_entry { --- 11 unchanged lines hidden (view full) --- 56 57struct cm_generic_msg { 58 struct ib_mad_hdr hdr; 59 60 __be32 local_comm_id; 61 __be32 remote_comm_id; 62}; 63 |
64struct cm_sidr_generic_msg { 65 struct ib_mad_hdr hdr; 66 __be32 request_id; 67}; 68 |
|
63struct cm_req_msg { 64 unsigned char unused[0x60]; 65 union ib_gid primary_path_sgid; 66}; 67 68 69static void set_local_comm_id(struct ib_mad *mad, u32 cm_id) 70{ | 69struct cm_req_msg { 70 unsigned char unused[0x60]; 71 union ib_gid primary_path_sgid; 72}; 73 74 75static void set_local_comm_id(struct ib_mad *mad, u32 cm_id) 76{ |
77 if (mad->mad_hdr.attr_id == CM_SIDR_REQ_ATTR_ID) { 78 struct cm_sidr_generic_msg *msg = 79 (struct cm_sidr_generic_msg *)mad; 80 msg->request_id = cpu_to_be32(cm_id); 81 } else if (mad->mad_hdr.attr_id == CM_SIDR_REP_ATTR_ID) { 82 pr_err("trying to set local_comm_id in SIDR_REP\n"); 83 return; 84 } else { |
|
71 struct cm_generic_msg *msg = (struct cm_generic_msg *)mad; 72 msg->local_comm_id = cpu_to_be32(cm_id); | 85 struct cm_generic_msg *msg = (struct cm_generic_msg *)mad; 86 msg->local_comm_id = cpu_to_be32(cm_id); |
87 } |
|
73} 74 75static u32 get_local_comm_id(struct ib_mad *mad) 76{ | 88} 89 90static u32 get_local_comm_id(struct ib_mad *mad) 91{ |
92 if (mad->mad_hdr.attr_id == CM_SIDR_REQ_ATTR_ID) { 93 struct cm_sidr_generic_msg *msg = 94 (struct cm_sidr_generic_msg *)mad; 95 return be32_to_cpu(msg->request_id); 96 } else if (mad->mad_hdr.attr_id == CM_SIDR_REP_ATTR_ID) { 97 pr_err("trying to set local_comm_id in SIDR_REP\n"); 98 return -1; 99 } else { |
|
77 struct cm_generic_msg *msg = (struct cm_generic_msg *)mad; | 100 struct cm_generic_msg *msg = (struct cm_generic_msg *)mad; |
78 | |
79 return be32_to_cpu(msg->local_comm_id); | 101 return be32_to_cpu(msg->local_comm_id); |
102 } |
|
80} 81 82static void set_remote_comm_id(struct ib_mad *mad, u32 cm_id) 83{ | 103} 104 105static void set_remote_comm_id(struct ib_mad *mad, u32 cm_id) 106{ |
107 if (mad->mad_hdr.attr_id == CM_SIDR_REP_ATTR_ID) { 108 struct cm_sidr_generic_msg *msg = 109 (struct cm_sidr_generic_msg *)mad; 110 msg->request_id = cpu_to_be32(cm_id); 111 } else if (mad->mad_hdr.attr_id == CM_SIDR_REQ_ATTR_ID) { 112 pr_err("trying to set remote_comm_id in SIDR_REQ\n"); 113 return; 114 } else { |
|
84 struct cm_generic_msg *msg = (struct cm_generic_msg *)mad; 85 msg->remote_comm_id = cpu_to_be32(cm_id); | 115 struct cm_generic_msg *msg = (struct cm_generic_msg *)mad; 116 msg->remote_comm_id = cpu_to_be32(cm_id); |
117 } |
|
86} 87 88static u32 get_remote_comm_id(struct ib_mad *mad) 89{ | 118} 119 120static u32 get_remote_comm_id(struct ib_mad *mad) 121{ |
122 if (mad->mad_hdr.attr_id == CM_SIDR_REP_ATTR_ID) { 123 struct cm_sidr_generic_msg *msg = 124 (struct cm_sidr_generic_msg *)mad; 125 return be32_to_cpu(msg->request_id); 126 } else if (mad->mad_hdr.attr_id == CM_SIDR_REQ_ATTR_ID) { 127 pr_err("trying to set remote_comm_id in SIDR_REQ\n"); 128 return -1; 129 } else { |
|
90 struct cm_generic_msg *msg = (struct cm_generic_msg *)mad; | 130 struct cm_generic_msg *msg = (struct cm_generic_msg *)mad; |
91 | |
92 return be32_to_cpu(msg->remote_comm_id); | 131 return be32_to_cpu(msg->remote_comm_id); |
132 } |
|
93} 94 95static union ib_gid gid_from_req_msg(struct ib_device *ibdev, struct ib_mad *mad) 96{ 97 struct cm_req_msg *msg = (struct cm_req_msg *)mad; 98 99 return msg->primary_path_sgid; 100} --- 179 unchanged lines hidden (view full) --- 280 281int mlx4_ib_multiplex_cm_handler(struct ib_device *ibdev, int port, int slave_id, 282 struct ib_mad *mad) 283{ 284 struct id_map_entry *id; 285 u32 sl_cm_id; 286 int pv_cm_id = -1; 287 | 133} 134 135static union ib_gid gid_from_req_msg(struct ib_device *ibdev, struct ib_mad *mad) 136{ 137 struct cm_req_msg *msg = (struct cm_req_msg *)mad; 138 139 return msg->primary_path_sgid; 140} --- 179 unchanged lines hidden (view full) --- 320 321int mlx4_ib_multiplex_cm_handler(struct ib_device *ibdev, int port, int slave_id, 322 struct ib_mad *mad) 323{ 324 struct id_map_entry *id; 325 u32 sl_cm_id; 326 int pv_cm_id = -1; 327 |
288 sl_cm_id = get_local_comm_id(mad); 289 | |
290 if (mad->mad_hdr.attr_id == CM_REQ_ATTR_ID || | 328 if (mad->mad_hdr.attr_id == CM_REQ_ATTR_ID || |
291 mad->mad_hdr.attr_id == CM_REP_ATTR_ID) { | 329 mad->mad_hdr.attr_id == CM_REP_ATTR_ID || 330 mad->mad_hdr.attr_id == CM_SIDR_REQ_ATTR_ID || 331 mad->mad_hdr.attr_id == CM_SIDR_REP_ATTR_ID) { 332 sl_cm_id = get_local_comm_id(mad); |
292 id = id_map_alloc(ibdev, slave_id, sl_cm_id); 293 if (IS_ERR(id)) { 294 mlx4_ib_warn(ibdev, "%s: id{slave: %d, sl_cm_id: 0x%x} Failed to id_map_alloc\n", 295 __func__, slave_id, sl_cm_id); 296 return PTR_ERR(id); 297 } | 333 id = id_map_alloc(ibdev, slave_id, sl_cm_id); 334 if (IS_ERR(id)) { 335 mlx4_ib_warn(ibdev, "%s: id{slave: %d, sl_cm_id: 0x%x} Failed to id_map_alloc\n", 336 __func__, slave_id, sl_cm_id); 337 return PTR_ERR(id); 338 } |
298 } else if (mad->mad_hdr.attr_id == CM_REJ_ATTR_ID) { | 339 } else if (mad->mad_hdr.attr_id == CM_REJ_ATTR_ID || 340 mad->mad_hdr.attr_id == CM_SIDR_REP_ATTR_ID) { |
299 return 0; 300 } else { | 341 return 0; 342 } else { |
343 sl_cm_id = get_local_comm_id(mad); |
|
301 id = id_map_get(ibdev, &pv_cm_id, slave_id, sl_cm_id); 302 } 303 304 if (!id) { 305 pr_debug("id{slave: %d, sl_cm_id: 0x%x} is NULL!\n", 306 slave_id, sl_cm_id); 307 return -EINVAL; 308 } --- 9 unchanged lines hidden (view full) --- 318} 319 320int mlx4_ib_demux_cm_handler(struct ib_device *ibdev, int port, int *slave, 321 struct ib_mad *mad, int is_eth) 322{ 323 u32 pv_cm_id; 324 struct id_map_entry *id; 325 | 344 id = id_map_get(ibdev, &pv_cm_id, slave_id, sl_cm_id); 345 } 346 347 if (!id) { 348 pr_debug("id{slave: %d, sl_cm_id: 0x%x} is NULL!\n", 349 slave_id, sl_cm_id); 350 return -EINVAL; 351 } --- 9 unchanged lines hidden (view full) --- 361} 362 363int mlx4_ib_demux_cm_handler(struct ib_device *ibdev, int port, int *slave, 364 struct ib_mad *mad, int is_eth) 365{ 366 u32 pv_cm_id; 367 struct id_map_entry *id; 368 |
326 if (mad->mad_hdr.attr_id == CM_REQ_ATTR_ID) { | 369 if (mad->mad_hdr.attr_id == CM_REQ_ATTR_ID || 370 mad->mad_hdr.attr_id == CM_SIDR_REQ_ATTR_ID) { |
327 union ib_gid gid; 328 329 if (is_eth) 330 return 0; 331 332 gid = gid_from_req_msg(ibdev, mad); 333 *slave = mlx4_ib_find_real_gid(ibdev, port, gid.global.interface_id); 334 if (*slave < 0) { 335 mlx4_ib_warn(ibdev, "failed matching slave_id by gid (0x%llx)\n", | 371 union ib_gid gid; 372 373 if (is_eth) 374 return 0; 375 376 gid = gid_from_req_msg(ibdev, mad); 377 *slave = mlx4_ib_find_real_gid(ibdev, port, gid.global.interface_id); 378 if (*slave < 0) { 379 mlx4_ib_warn(ibdev, "failed matching slave_id by gid (0x%llx)\n", |
336 (long long)gid.global.interface_id); | 380 (unsigned long long)gid.global.interface_id); |
337 return -ENOENT; 338 } 339 return 0; 340 } 341 342 pv_cm_id = get_remote_comm_id(mad); 343 id = id_map_get(ibdev, (int *)&pv_cm_id, -1, -1); 344 --- 96 unchanged lines hidden --- | 381 return -ENOENT; 382 } 383 return 0; 384 } 385 386 pv_cm_id = get_remote_comm_id(mad); 387 id = id_map_get(ibdev, (int *)&pv_cm_id, -1, -1); 388 --- 96 unchanged lines hidden --- |