1321936Shselasky/* 2321936Shselasky * Copyright (c) 2011 Lawrence Livermore National Lab. All rights reserved. 3321936Shselasky * 4321936Shselasky * This software is available to you under a choice of one of two 5321936Shselasky * licenses. You may choose to be licensed under the terms of the GNU 6321936Shselasky * General Public License (GPL) Version 2, available from the file 7321936Shselasky * COPYING in the main directory of this source tree, or the 8321936Shselasky * OpenIB.org BSD license below: 9321936Shselasky * 10321936Shselasky * Redistribution and use in source and binary forms, with or 11321936Shselasky * without modification, are permitted provided that the following 12321936Shselasky * conditions are met: 13321936Shselasky * 14321936Shselasky * - Redistributions of source code must retain the above 15321936Shselasky * copyright notice, this list of conditions and the following 16321936Shselasky * disclaimer. 17321936Shselasky * 18321936Shselasky * - Redistributions in binary form must reproduce the above 19321936Shselasky * copyright notice, this list of conditions and the following 20321936Shselasky * disclaimer in the documentation and/or other materials 21321936Shselasky * provided with the distribution. 22321936Shselasky * 23321936Shselasky * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24321936Shselasky * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25321936Shselasky * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26321936Shselasky * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27321936Shselasky * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28321936Shselasky * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29321936Shselasky * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30321936Shselasky * SOFTWARE. 31321936Shselasky * 32321936Shselasky */ 33321936Shselasky 34321936Shselasky#if HAVE_CONFIG_H 35321936Shselasky# include <config.h> 36321936Shselasky#endif /* HAVE_CONFIG_H */ 37321936Shselasky 38321936Shselasky#include <stdio.h> 39321936Shselasky#include <stdlib.h> 40321936Shselasky#include <string.h> 41321936Shselasky 42321936Shselasky#include <infiniband/umad.h> 43321936Shselasky#include <infiniband/mad.h> 44321936Shselasky#include "mad_internal.h" 45321936Shselasky 46321936Shselasky#undef DEBUG 47321936Shselasky#define DEBUG if (ibdebug) IBWARN 48321936Shselasky 49321936Shselaskyvoid *cc_query_status_via(void *rcvbuf, ib_portid_t * portid, 50321936Shselasky unsigned attrid, unsigned mod, unsigned timeout, 51321936Shselasky int *rstatus, const struct ibmad_port * srcport, 52321936Shselasky uint64_t cckey) 53321936Shselasky{ 54321936Shselasky ib_rpc_cc_t rpc = { 0 }; 55321936Shselasky void *res; 56321936Shselasky 57321936Shselasky DEBUG("attr 0x%x mod 0x%x route %s", attrid, mod, portid2str(portid)); 58321936Shselasky rpc.method = IB_MAD_METHOD_GET; 59321936Shselasky rpc.attr.id = attrid; 60321936Shselasky rpc.attr.mod = mod; 61321936Shselasky rpc.timeout = timeout; 62321936Shselasky if (attrid == IB_CC_ATTR_CONGESTION_LOG) { 63321936Shselasky rpc.datasz = IB_CC_LOG_DATA_SZ; 64321936Shselasky rpc.dataoffs = IB_CC_LOG_DATA_OFFS; 65321936Shselasky } 66321936Shselasky else { 67321936Shselasky rpc.datasz = IB_CC_DATA_SZ; 68321936Shselasky rpc.dataoffs = IB_CC_DATA_OFFS; 69321936Shselasky } 70321936Shselasky rpc.mgtclass = IB_CC_CLASS; 71321936Shselasky rpc.cckey = cckey; 72321936Shselasky 73321936Shselasky portid->qp = 1; 74321936Shselasky if (!portid->qkey) 75321936Shselasky portid->qkey = IB_DEFAULT_QP1_QKEY; 76321936Shselasky 77321936Shselasky res = mad_rpc(srcport, (ib_rpc_t *)&rpc, portid, rcvbuf, rcvbuf); 78321936Shselasky if (rstatus) 79321936Shselasky *rstatus = rpc.rstatus; 80321936Shselasky 81321936Shselasky return res; 82321936Shselasky} 83321936Shselasky 84321936Shselaskyvoid *cc_config_status_via(void *payload, void *rcvbuf, ib_portid_t * portid, 85321936Shselasky unsigned attrid, unsigned mod, unsigned timeout, 86321936Shselasky int *rstatus, const struct ibmad_port * srcport, 87321936Shselasky uint64_t cckey) 88321936Shselasky{ 89321936Shselasky ib_rpc_cc_t rpc = { 0 }; 90321936Shselasky void *res; 91321936Shselasky 92321936Shselasky DEBUG("attr 0x%x mod 0x%x route %s", attrid, mod, portid2str(portid)); 93321936Shselasky rpc.method = IB_MAD_METHOD_SET; 94321936Shselasky rpc.attr.id = attrid; 95321936Shselasky rpc.attr.mod = mod; 96321936Shselasky rpc.timeout = timeout; 97321936Shselasky if (attrid == IB_CC_ATTR_CONGESTION_LOG) { 98321936Shselasky rpc.datasz = IB_CC_LOG_DATA_SZ; 99321936Shselasky rpc.dataoffs = IB_CC_LOG_DATA_OFFS; 100321936Shselasky } 101321936Shselasky else { 102321936Shselasky rpc.datasz = IB_CC_DATA_SZ; 103321936Shselasky rpc.dataoffs = IB_CC_DATA_OFFS; 104321936Shselasky } 105321936Shselasky rpc.mgtclass = IB_CC_CLASS; 106321936Shselasky rpc.cckey = cckey; 107321936Shselasky 108321936Shselasky portid->qp = 1; 109321936Shselasky if (!portid->qkey) 110321936Shselasky portid->qkey = IB_DEFAULT_QP1_QKEY; 111321936Shselasky 112321936Shselasky res = mad_rpc(srcport, (ib_rpc_t *)&rpc, portid, payload, rcvbuf); 113321936Shselasky if (rstatus) 114321936Shselasky *rstatus = rpc.rstatus; 115321936Shselasky 116321936Shselasky return res; 117321936Shselasky} 118321936Shselasky 119321936Shselasky 120