|
Packit |
db064d |
/*
|
|
Packit |
db064d |
* Copyright (c) 2006-2007 The Regents of the University of California.
|
|
Packit |
db064d |
* Copyright (c) 2004-2009 Voltaire Inc. All rights reserved.
|
|
Packit |
db064d |
* Copyright (c) 2002-2010 Mellanox Technologies LTD. All rights reserved.
|
|
Packit |
db064d |
* Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
|
|
Packit |
db064d |
* Copyright (c) 2009 HNR Consulting. All rights reserved.
|
|
Packit |
db064d |
* Copyright (c) 2012 Lawrence Livermore National Security. All rights reserved.
|
|
Packit |
db064d |
*
|
|
Packit |
db064d |
* This software is available to you under a choice of one of two
|
|
Packit |
db064d |
* licenses. You may choose to be licensed under the terms of the GNU
|
|
Packit |
db064d |
* General Public License (GPL) Version 2, available from the file
|
|
Packit |
db064d |
* COPYING in the main directory of this source tree, or the
|
|
Packit |
db064d |
* OpenIB.org BSD license below:
|
|
Packit |
db064d |
*
|
|
Packit |
db064d |
* Redistribution and use in source and binary forms, with or
|
|
Packit |
db064d |
* without modification, are permitted provided that the following
|
|
Packit |
db064d |
* conditions are met:
|
|
Packit |
db064d |
*
|
|
Packit |
db064d |
* - Redistributions of source code must retain the above
|
|
Packit |
db064d |
* copyright notice, this list of conditions and the following
|
|
Packit |
db064d |
* disclaimer.
|
|
Packit |
db064d |
*
|
|
Packit |
db064d |
* - Redistributions in binary form must reproduce the above
|
|
Packit |
db064d |
* copyright notice, this list of conditions and the following
|
|
Packit |
db064d |
* disclaimer in the documentation and/or other materials
|
|
Packit |
db064d |
* provided with the distribution.
|
|
Packit |
db064d |
*
|
|
Packit |
db064d |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
Packit |
db064d |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
Packit |
db064d |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
Packit |
db064d |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
Packit |
db064d |
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
Packit |
db064d |
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
Packit |
db064d |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
Packit |
db064d |
* SOFTWARE.
|
|
Packit |
db064d |
*
|
|
Packit |
db064d |
*/
|
|
Packit |
db064d |
|
|
Packit |
db064d |
#ifndef _IBDIAG_SA_H_
|
|
Packit |
db064d |
#define _IBDIAG_SA_H_
|
|
Packit |
db064d |
|
|
Packit |
db064d |
#include <infiniband/mad.h>
|
|
Packit |
db064d |
#include <infiniband/iba/ib_types.h>
|
|
Packit |
db064d |
|
|
Packit |
db064d |
/* define an SA query structure to be common
|
|
Packit |
db064d |
* This is by no means optimal but it moves the saquery functionality out of
|
|
Packit |
db064d |
* the saquery tool and provides it to other utilities.
|
|
Packit |
db064d |
*/
|
|
Packit |
db064d |
struct sa_handle {
|
|
Packit |
db064d |
int fd, agent;
|
|
Packit |
db064d |
ib_portid_t dport;
|
|
Packit |
db064d |
struct ibmad_port *srcport;
|
|
Packit |
db064d |
};
|
|
Packit |
db064d |
|
|
Packit |
db064d |
struct sa_query_result {
|
|
Packit |
db064d |
uint32_t status;
|
|
Packit |
db064d |
unsigned result_cnt;
|
|
Packit |
db064d |
void *p_result_madw;
|
|
Packit |
db064d |
};
|
|
Packit |
db064d |
|
|
Packit |
db064d |
/* NOTE: umad_init must be called prior to sa_get_handle */
|
|
Packit |
db064d |
struct sa_handle * sa_get_handle(void);
|
|
Packit |
db064d |
void sa_free_handle(struct sa_handle * h);
|
|
Packit |
db064d |
|
|
Packit |
db064d |
int sa_query(struct sa_handle *h, uint8_t method,
|
|
Packit |
db064d |
uint16_t attr, uint32_t mod, uint64_t comp_mask, uint64_t sm_key,
|
|
Packit |
db064d |
void *data, size_t datasz, struct sa_query_result *result);
|
|
Packit |
db064d |
void sa_free_result_mad(struct sa_query_result *result);
|
|
Packit |
db064d |
void *sa_get_query_rec(void *mad, unsigned i);
|
|
Packit |
db064d |
void sa_report_err(int status);
|
|
Packit |
db064d |
|
|
Packit |
db064d |
/* Macros for setting query values and ComponentMasks */
|
|
Packit |
db064d |
static inline uint8_t htobe8(uint8_t val)
|
|
Packit |
db064d |
{
|
|
Packit |
db064d |
return val;
|
|
Packit |
db064d |
}
|
|
Packit |
db064d |
#define CHECK_AND_SET_VAL(val, size, comp_with, target, name, mask) \
|
|
Packit |
db064d |
if ((int##size##_t) val != (int##size##_t) comp_with) { \
|
|
Packit |
db064d |
target = htobe##size((uint##size##_t) val); \
|
|
Packit |
db064d |
comp_mask |= IB_##name##_COMPMASK_##mask; \
|
|
Packit |
db064d |
}
|
|
Packit |
db064d |
|
|
Packit |
db064d |
#define CHECK_AND_SET_GID(val, target, name, mask) \
|
|
Packit |
db064d |
if (valid_gid(&(val))) { \
|
|
Packit |
db064d |
memcpy(&(target), &(val), sizeof(val)); \
|
|
Packit |
db064d |
comp_mask |= IB_##name##_COMPMASK_##mask; \
|
|
Packit |
db064d |
}
|
|
Packit |
db064d |
|
|
Packit |
db064d |
#define CHECK_AND_SET_VAL_AND_SEL(val, target, name, mask, sel) \
|
|
Packit |
db064d |
if (val) { \
|
|
Packit |
db064d |
target = val; \
|
|
Packit |
db064d |
comp_mask |= IB_##name##_COMPMASK_##mask##sel; \
|
|
Packit |
db064d |
comp_mask |= IB_##name##_COMPMASK_##mask; \
|
|
Packit |
db064d |
}
|
|
Packit |
db064d |
|
|
Packit |
db064d |
#endif /* _IBDIAG_SA_H_ */
|