Hi Sasha, This patch adds support for handling of BM (Baseboard management) MADs.
Signed-off-by: Itai Baz <[email protected]> --- libibmad/Makefile.am | 3 +- libibmad/include/infiniband/mad.h | 49 ++++++++++++++++++ libibmad/src/bm.c | 101 +++++++++++++++++++++++++++++++++++++ libibmad/src/libibmad.map | 1 + libibmad/src/register.c | 2 + 5 files changed, 155 insertions(+), 1 deletions(-) create mode 100644 libibmad/src/bm.c diff --git a/libibmad/Makefile.am b/libibmad/Makefile.am index 4f3ba98..618ed3e 100644 --- a/libibmad/Makefile.am +++ b/libibmad/Makefile.am @@ -15,7 +15,8 @@ endif libibmad_la_SOURCES = src/dump.c src/fields.c src/mad.c src/portid.c \ src/resolve.c src/rpc.c src/sa.c src/smp.c src/gs.c \ - src/serv.c src/register.c src/vendor.c src/mad_internal.h + src/serv.c src/register.c src/vendor.c src/mad_internal.h \ + src/bm.c libibmad_la_LDFLAGS = -version-info $(ibmad_api_version) \ -export-dynamic $(libibmad_version_script) diff --git a/libibmad/include/infiniband/mad.h b/libibmad/include/infiniband/mad.h index b8290a7..efc887a 100644 --- a/libibmad/include/infiniband/mad.h +++ b/libibmad/include/infiniband/mad.h @@ -63,6 +63,11 @@ BEGIN_C_DECLS #define IB_SA_MCM_RECSZ 53 #define IB_SA_PR_RECSZ 64 +#define IB_BM_DATA_OFFS 64 +#define IB_BM_DATA_SZ (IB_MAD_SIZE - IB_BM_DATA_OFFS) +#define IB_BM_BKEY_OFFS 24 +#define IB_BM_BKEY_AND_DATA_SZ (IB_MAD_SIZE - IB_BM_BKEY_OFFS) + enum MAD_CLASSES { IB_SMI_CLASS = 0x1, IB_SMI_DIRECT_CLASS = 0x81, @@ -108,6 +113,14 @@ enum MAD_ATTR_ID { INFORM_INFO = 0x3, }; +enum MAD_STATUS { + IB_MAD_STS_OK = (0 << 2), + IB_MAD_STS_BAD_BASE_VER_OR_CLASS = (1 << 2), + IB_MAD_STS_METHOD_NOT_SUPPORTED = (2 << 2), + IB_MAD_STS_METHOD_ATTR_NOT_SUPPORTED = (3 << 2), + IB_MAD_STS_INV_ATTR_VALUE = (7 << 2), +}; + enum SMI_ATTR_ID { IB_ATTR_NODE_DESC = 0x10, IB_ATTR_NODE_INFO = 0x11, @@ -158,6 +171,29 @@ enum GSI_ATTR_ID { IB_GSI_ATTR_LAST }; +enum BM_ATTR_ID { + IB_BM_ATTR_BKEYINFO = 0x10, + IB_BM_ATTR_WRITE_VPD = 0x20, + IB_BM_ATTR_READ_VPD = 0x21, + IB_BM_ATTR_RESET_IBML = 0x22, + IB_BM_ATTR_SET_MODULE_PM_CONTROL = 0x23, + IB_BM_ATTR_GET_MODULE_PM_CONTROL = 0x24, + IB_BM_ATTR_SET_UNIT_PM_CONTROL = 0x25, + IB_BM_ATTR_GET_UNIT_PM_CONTROL = 0x26, + IB_BM_ATTR_SET_IOC_PM_CONTROL = 0x27, + IB_BM_ATTR_GET_IOC_PM_CONTROL = 0x28, + IB_BM_ATTR_SET_MODULE_STATE = 0x29, + IB_BM_ATTR_SET_MODULE_ATTENTION = 0x2A, + IB_BM_ATTR_GET_MODULE_STATUS = 0x2B, + IB_BM_ATTR_IB2IBML = 0x2C, + IB_BM_ATTR_IB2CME = 0x2D, + IB_BM_ATTR_IB2MME = 0x2E, + IB_BM_ATTR_OEM = 0x2F, + + IB_BM_ATTR_LAST +}; + + #define IB_VENDOR_OPENIB_PING_CLASS (IB_VENDOR_RANGE2_START_CLASS + 2) #define IB_VENDOR_OPENIB_SYSSTAT_CLASS (IB_VENDOR_RANGE2_START_CLASS + 3) #define IB_OPENIB_OUI (0x001405) @@ -661,6 +697,16 @@ typedef struct ib_vendor_call { ib_rmpp_hdr_t rmpp; } ib_vendor_call_t; +typedef struct ib_bm_call { + unsigned method; + unsigned attrid; + unsigned mod; + unsigned timeout; + ib_rmpp_hdr_t rmpp; + uint64_t bkey; +} ib_bm_call_t; + + #define IB_MIN_UCAST_LID 1 #define IB_MAX_UCAST_LID (0xc000-1) #define IB_MIN_MCAST_LID 0xc000 @@ -876,6 +922,9 @@ MAD_EXPORT uint8_t *performance_reset_via(void *rcvbuf, ib_portid_t * dest, unsigned timeout, unsigned id, const struct ibmad_port *srcport); +/* bm.c */ +uint8_t * bm_rpc_call_via(void *data, ib_portid_t *portid, ib_bm_call_t *call, struct ibmad_port *srcport); + /* dump.c */ MAD_EXPORT ib_mad_dump_fn mad_dump_int, mad_dump_uint, mad_dump_hex, mad_dump_rhex, diff --git a/libibmad/src/bm.c b/libibmad/src/bm.c new file mode 100644 index 0000000..a095b9a --- /dev/null +++ b/libibmad/src/bm.c @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2004-2007 Voltaire Inc. All rights reserved. + * + * This software is available to you under a choice of one of two + * licenses. You may choose to be licensed under the terms of the GNU + * General Public License (GPL) Version 2, available from the file + * COPYING in the main directory of this source tree, or the + * OpenIB.org BSD license below: + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#if HAVE_CONFIG_H +# include <config.h> +#endif /* HAVE_CONFIG_H */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <pthread.h> +#include <string.h> +#include <sys/time.h> + +#include <infiniband/mad.h> + +#undef DEBUG +#define DEBUG if (ibdebug) IBWARN + +static inline int +response_expected(int method) +{ + return method == IB_MAD_METHOD_GET || + method == IB_MAD_METHOD_SET || + method == IB_MAD_METHOD_TRAP; +} + +uint8_t * +bm_rpc_call_via(void *data, ib_portid_t *portid, ib_bm_call_t *call, struct ibmad_port *srcport) +{ + ib_rpc_t rpc = {0}; + int resp_expected; + char data_with_bkey[IB_BM_BKEY_AND_DATA_SZ] = {0}; + + DEBUG("route %s data %p", portid2str(portid), data); + if (portid->lid <= 0) { + IBWARN("only lid routes are supported"); + return 0; + } + + resp_expected = response_expected(call->method); + + rpc.mgtclass = IB_BOARD_MGMT_CLASS; + + rpc.method = call->method; + rpc.attr.id = call->attrid; + rpc.attr.mod = call->mod; + rpc.timeout = resp_expected ? call->timeout : 0; + // send data and bkey + rpc.datasz = IB_BM_BKEY_AND_DATA_SZ; + rpc.dataoffs = IB_BM_BKEY_OFFS; + + // copy data to a buffer which also includes the bkey + *((uint64_t *) data_with_bkey) = call->bkey; + memcpy(data_with_bkey + IB_BM_DATA_OFFS - IB_BM_BKEY_OFFS, data, IB_BM_DATA_SZ); + + DEBUG("method 0x%x attr 0x%x mod 0x%x datasz %d off %d res_ex %d bkey 0x%08x%08x", + rpc.method, rpc.attr.id, rpc.attr.mod, + rpc.datasz, rpc.dataoffs, resp_expected, + (int) (call->bkey >> 32), (int) call->bkey); + + portid->qp = 1; + if (!portid->qkey) + portid->qkey = IB_DEFAULT_QP1_QKEY; + + if (resp_expected) + return mad_rpc_rmpp(srcport, &rpc, portid, 0, data_with_bkey); /* FIXME: no RMPP for now */ + + return mad_send_via(&rpc, portid, 0, data_with_bkey, srcport) < 0 ? 0 : data_with_bkey; /* FIXME: no RMPP for now */ +} + diff --git a/libibmad/src/libibmad.map b/libibmad/src/libibmad.map index 4306dbc..a08b7b2 100644 --- a/libibmad/src/libibmad.map +++ b/libibmad/src/libibmad.map @@ -102,5 +102,6 @@ IBMAD_1.3 { ib_resolve_guid_via; ib_resolve_portid_str_via; ib_resolve_self_via; + bm_rpc_call_via; local: *; }; diff --git a/libibmad/src/register.c b/libibmad/src/register.c index eac8f5d..76567e1 100644 --- a/libibmad/src/register.c +++ b/libibmad/src/register.c @@ -68,6 +68,8 @@ static int mgmt_class_vers(int mgmt_class) return 1; case IB_CC_CLASS: return 2; + case IB_BOARD_MGMT_CLASS: + return 1; } return 0; -- 1.5.3.7 _______________________________________________ general mailing list [email protected] http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general
