/*
*
* 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
* 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.
*/
/*
* OFED Solaris wrapper
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <ctype.h>
#include <string.h>
#include <strings.h>
#include <getopt.h>
#include <infiniband/verbs.h>
#include <infiniband/arch.h>
#include <infiniband/umad.h>
#include "ibdiag_common.h"
static struct nodedesc_read_info_s {
int nd_read_info_cnt = 0;
static int
static int
static void
{
int j;
for (j = 0; j < nd_read_info_cnt; j++) {
continue;
printf("%s: %-16s\n",
}
}
static void
{
int i;
char *dev_name;
for (i = 0; dev_list[i] != 0 && i < num_devices; ++i) {
int j;
ibv_get_device_guid(dev_list[i]));
for (j = 0; j < nd_read_info_cnt; j++) {
break;
}
}
}
}
static void
{
}
static void
{
int rc;
/* Get the context for the device */
if (!context) {
IBEXIT("Unable to open the device.\n");
/* NOTREACHED */
}
IBEXIT("Device not set.\n");
/* NOTREACHED */
}
/* Allocate the memory for node descriptor */
sizeof (sol_uverbs_nodedesc_t));
IBEXIT("Memory allocation failed.\n");
/* NOTREACHED */
}
/* Get the guid for the device */
if (!hca_guid) {
IBEXIT("ibv_get_device_guid failed.\n");
/* NOTREACHED */
}
/* Read node descriptor */
if (rc != 0) {
IBEXIT("Failed to read node descriptor.\n");
/* NOTREACHED */
}
hca_guid);
/* release the allocated memory */
/* Close the device */
}
static int
{
int rc;
char *desc_str;
/* Get context for the device */
if (!context) {
IBEXIT("Unable to open the device.\n");
/* NOTREACHED */
}
IBEXIT("Device not set.\n");
/* NOTREACHED */
}
/* Allocate the memory for node descriptor */
sizeof (sol_uverbs_nodedesc_t));
IBEXIT("Memory allocation failed.\n");
/* NOTREACHED */
}
if (rc != 0)
IBEXIT("Failed to set node descriptor.\n");
return (rc);
}
static void
{
int i;
for (i = 0; device_list[i] != 0 && i < num_devices; i++)
}
static int
{
for (i = 0; i < num_devices; i++) {
if (rc != 0)
continue;
else
break;
}
if (rc != 0 && i == num_devices)
IBEXIT("Failed to set the node descriptor.\n");
return (rc);
}
if (hca_nodedesc && guid) {
for (i = 0; i < num_devices; i++) {
device_list[i]));
if (!dev_guid) {
continue;
}
break;
} else {
continue;
}
}
IBEXIT("No guid matched.\n");
/* NOTREACHED */
}
if (rc != 0) {
IBEXIT("Failed to set the node descriptor.\n");
/* NOTREACHED */
}
}
return (rc);
}
static int
{
int ret;
/*
* Use ioctl call to sol_uverbs module.
*/
return (-1);
}
if (ret != 0) {
IBEXIT("ABI version check failed.\n");
else
IBEXIT("UVERBS_IOCTL_GET_NODEDESC ioctl failed.\n");
/* NOTREACHED */
}
return (0);
}
static int
{
int ret;
/*
* Use ioctl call to sol_uverbs module.
*/
return (-1);
if (ret != 0) {
IBEXIT("ABI version check failed.\n");
else
IBEXIT("UVERBS_IOCTL_SET_NODEDESC ioctl failed.\n");
/* NOTREACHED */
}
return (0);
}
static void
usage(void)
{
char *basename;
else
basename++;
basename);
"-G(UID) HCA_GUID]\n", basename);
"-G(UID) HCA_GUID -N(ode_Descriptor) CmnString]\n",
basename);
}
/*
* Return the Node descriptor string by concatinating
* many substrings. The first substring is "optarg" and
* the index of the last sub-string is "optind".
*
* For common nodedescription, add a space at the end,
* if there is none.
*/
static char *
{
char *nodedesc_str;
/* Get the index for first sub-string. */
continue;
start_opt = i;
break;
}
}
if (start_opt == 0)
return (NULL);
/* Get the index for last sub-string */
end_opt = i - 1;
break;
}
}
if (end_opt == 0)
return (NULL);
start_opt++;
/*
* strcat a space string and then strcat the
* next sub-string.
*/
}
/*
* Add a space at the end, if the caller has set
* space_at_end and the nodedesc string doesn't
* contain a space at the end.
*/
if (space_at_end == B_TRUE &&
return (nodedesc_str);
}
int
{
int rc;
extern int ibdebug;
int num_devices = 0;
{ "Node_Descriptor", 1, 0, 'N'},
{ "HCA_Description", 1, 0, 'H'},
{ "GUID", 1, 0, 'G'},
{ "verbose", 0, 0, 'v'},
{ "debug", 0, 0, 'd'},
{ }
};
while (1) {
if (ch == -1)
break;
switch (ch) {
case 'N':
if (!nodedesc) {
usage();
rc = -1;
goto free_and_ret_2;
}
break;
case 'H':
if (!hcadesc) {
usage();
rc = -1;
goto free_and_ret_2;
}
break;
case 'G':
break;
case 'v' :
break;
case 'd':
ibdebug++;
break;
default:
usage();
rc = -1;
goto free_and_ret_2;
}
}
if (update_flag & NODEDESC_READ) {
usage();
rc = -1;
goto free_and_ret_2;
}
if (!device_list) {
IBEXIT("ibv_get_device_list failed.\n");
/* NOTREACHED */
}
rc = 0;
goto free_and_ret_1;
}
IBEXIT("No GUID specified for HCA Node descriptor");
/* NOTREACHED */
}
if (!device_list) {
IBEXIT("ibv_get_device_list failed.\n");
/* NOTREACHED */
}
if (nodedesc) {
if (rc) {
IBEXIT("write common node descriptor "
"failed");
/* NOTREACHED */
}
}
if (hcadesc) {
if (rc) {
IBEXIT("update_hca_noddesc failed");
/* NOTREACHED */
}
rc = 0;
goto free_and_ret_1;
}
IBEXIT("Node descriptor unspecified"
"& uts_name failed");
/* NOTREACHED */
}
/*
* The common nodedesc string can have max 64 chars.
* We can accomodate 63 chars from uname and alike
* option -N, we append a space to the nodename.
*/
if (rc) {
IBEXIT("write common node descriptor failed");
/* NOTREACHED */
}
}
if (nodedesc)
if (hcadesc)
return (rc);
}
#endif