1
1
openmpi/opal/mca/common/verbs/common_verbs_basics.c
Jeff Squyres a2b55e12f2 common verbs: insert fake usnic_verbs libibverbs driver
libibverbs will complain to stderr if it sees device entries in
/sys/class/infiniband for which it has no userspace plugins.

The Cisco usNIC device no longer exports a verbs interface, thereby
causing libibverbs to emit this annoying stderr warning.

To avoid this, use the public ibv API to register a "fake" libibverbs
driver at run-time (right after we call ibv_fork_init(), but --
critically -- *before* we call ibv_get_device_list()).  The purpose of
this driver is solely to convince libibverbs that there *is* a driver
for /sys/class/infininband/usnic_verbs devices.  ...although this
driver will never return a valid ibv context (and therefore will never
be used).
2015-04-29 18:07:12 -07:00

100 строки
2.7 KiB
C

/*
* Copyright (c) 2012-2015 Cisco Systems, Inc. All rights reserved.
*
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "opal_config.h"
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
/* This is crummy, but <infiniband/driver.h> doesn't work on all
platforms with all compilers. Specifically, trying to include it
on RHEL4U3 with the PGI 32 bit compiler will cause problems because
certain 64 bit types are not defined. Per advice from Roland D.,
just include the one prototype that we need in this case
(ibv_get_sysfs_path()). */
#include <infiniband/verbs.h>
#ifdef HAVE_INFINIBAND_DRIVER_H
#include <infiniband/driver.h>
#else
const char *ibv_get_sysfs_path(void);
#endif
#include "common_verbs.h"
#include "opal/runtime/opal_params.h"
#include "opal/util/show_help.h"
#include "opal/util/proc.h"
/***********************************************************************/
bool opal_common_verbs_check_basics(void)
{
#if defined(__linux__)
int rc;
char *file;
struct stat s;
/* Check to see if $sysfsdir/class/infiniband/ exists */
asprintf(&file, "%s/class/infiniband", ibv_get_sysfs_path());
if (NULL == file) {
return false;
}
rc = stat(file, &s);
free(file);
if (0 != rc || !S_ISDIR(s.st_mode)) {
return false;
}
#endif
/* It exists and is a directory -- good enough */
return true;
}
int opal_common_verbs_fork_test(void)
{
int ret = OPAL_SUCCESS;
/* Make sure that ibv_fork_init() is the first ibv_* function to
be invoked in this process. */
#ifdef HAVE_IBV_FORK_INIT
if (0 != opal_common_verbs_want_fork_support) {
/* Check if fork support is requested by the user */
if (0 != ibv_fork_init()) {
/* If the opal_common_verbs_want_fork_support MCA
* parameter is >0 but the call to ibv_fork_init() failed,
* then return an error code.
*/
if (opal_common_verbs_want_fork_support > 0) {
opal_show_help("help-opal-common-verbs.txt",
"ibv_fork_init fail", true,
opal_proc_local_get()->proc_hostname, errno,
strerror(errno));
ret = OPAL_ERROR;
}
}
}
#endif
/* Now rgister any necessary fake libibverbs drivers. We
piggyback loading these fake drivers on the fork test because
they must be loaded before ibv_get_device_list() is invoked. */
opal_common_verbs_register_fake_drivers();
return ret;
}