1 /* 2 * Copyright (c) 2011 Lawrence Livermore National Lab. 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 #if HAVE_CONFIG_H 35 # include <config.h> 36 #endif /* HAVE_CONFIG_H */ 37 38 #include <stdio.h> 39 #include <stdlib.h> 40 #include <string.h> 41 42 #include <infiniband/umad.h> 43 #include <infiniband/mad.h> 44 #include "mad_internal.h" 45 46 #undef DEBUG 47 #define DEBUG if (ibdebug) IBWARN 48 49 void *cc_query_status_via(void *rcvbuf, ib_portid_t * portid, 50 unsigned attrid, unsigned mod, unsigned timeout, 51 int *rstatus, const struct ibmad_port * srcport, 52 uint64_t cckey) 53 { 54 ib_rpc_cc_t rpc = { 0 }; 55 void *res; 56 57 DEBUG("attr 0x%x mod 0x%x route %s", attrid, mod, portid2str(portid)); 58 rpc.method = IB_MAD_METHOD_GET; 59 rpc.attr.id = attrid; 60 rpc.attr.mod = mod; 61 rpc.timeout = timeout; 62 if (attrid == IB_CC_ATTR_CONGESTION_LOG) { 63 rpc.datasz = IB_CC_LOG_DATA_SZ; 64 rpc.dataoffs = IB_CC_LOG_DATA_OFFS; 65 } 66 else { 67 rpc.datasz = IB_CC_DATA_SZ; 68 rpc.dataoffs = IB_CC_DATA_OFFS; 69 } 70 rpc.mgtclass = IB_CC_CLASS; 71 rpc.cckey = cckey; 72 73 portid->qp = 1; 74 if (!portid->qkey) 75 portid->qkey = IB_DEFAULT_QP1_QKEY; 76 77 res = mad_rpc(srcport, (ib_rpc_t *)&rpc, portid, rcvbuf, rcvbuf); 78 if (rstatus) 79 *rstatus = rpc.rstatus; 80 81 return res; 82 } 83 84 void *cc_config_status_via(void *payload, void *rcvbuf, ib_portid_t * portid, 85 unsigned attrid, unsigned mod, unsigned timeout, 86 int *rstatus, const struct ibmad_port * srcport, 87 uint64_t cckey) 88 { 89 ib_rpc_cc_t rpc = { 0 }; 90 void *res; 91 92 DEBUG("attr 0x%x mod 0x%x route %s", attrid, mod, portid2str(portid)); 93 rpc.method = IB_MAD_METHOD_SET; 94 rpc.attr.id = attrid; 95 rpc.attr.mod = mod; 96 rpc.timeout = timeout; 97 if (attrid == IB_CC_ATTR_CONGESTION_LOG) { 98 rpc.datasz = IB_CC_LOG_DATA_SZ; 99 rpc.dataoffs = IB_CC_LOG_DATA_OFFS; 100 } 101 else { 102 rpc.datasz = IB_CC_DATA_SZ; 103 rpc.dataoffs = IB_CC_DATA_OFFS; 104 } 105 rpc.mgtclass = IB_CC_CLASS; 106 rpc.cckey = cckey; 107 108 portid->qp = 1; 109 if (!portid->qkey) 110 portid->qkey = IB_DEFAULT_QP1_QKEY; 111 112 res = mad_rpc(srcport, (ib_rpc_t *)&rpc, portid, payload, rcvbuf); 113 if (rstatus) 114 *rstatus = rpc.rstatus; 115 116 return res; 117 } 118 119 120