From e20217eccc6a6b5f4ad20d37319c28426fcc2d9a Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Mon, 11 Nov 2013 22:25:30 +0000 Subject: [PATCH] Expand the "btl_usnic" MPI_T enumeration to have strings of the form: ,,/ For example: usnic_0,eth4,10.1.0.15/16 This is just handy for mapping the usnic_X device back to the IP network to which it corresponds. This commit was SVN r29656. --- ompi/mca/btl/usnic/btl_usnic_stats.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/ompi/mca/btl/usnic/btl_usnic_stats.c b/ompi/mca/btl/usnic/btl_usnic_stats.c index 44c1c31ecc..03d11cc4d9 100644 --- a/ompi/mca/btl/usnic/btl_usnic_stats.c +++ b/ompi/mca/btl/usnic/btl_usnic_stats.c @@ -379,15 +379,29 @@ static void setup_mpit_pvars_enum(void) mca_base_var_enum_value_t *devices; static mca_base_var_enum_t *devices_enum; struct ibv_device *device; + ompi_btl_usnic_module_t *m; + unsigned char *c; devices = calloc(mca_btl_usnic_component.num_modules + 1, sizeof(*devices)); assert(devices != NULL); for (i = 0; i < mca_btl_usnic_component.num_modules; ++i) { - device = mca_btl_usnic_component.usnic_active_modules[i]->device; + char *str; + + m = mca_btl_usnic_component.usnic_active_modules[i]; + c = (unsigned char*) &m->if_ipv4_addr; + + device = m->device; devices[i].value = i; - devices[i].string = ibv_get_device_name(device); + rc = asprintf(&str, "%s,%s,%u.%u.%u.%u/%d", + ibv_get_device_name(device), + m->if_name, + c[0], c[1], c[2], c[3], + m->if_cidrmask); + assert(rc > 0); + devices[i].string = str; + opal_output(0, "Set string: %s", str); } devices[i].string = NULL; @@ -410,6 +424,14 @@ static void setup_mpit_pvars_enum(void) NULL /* context */); assert(rc >= 0); + /* Free the strings (mca_base_var_enum_create() strdup()'ed them + into private storage, so we don't need them any more) */ + for (i = 0; i < mca_btl_usnic_component.num_modules; ++i) { + m = mca_btl_usnic_component.usnic_active_modules[i]; + device = m->device; + free((char*) devices[i].string); + } + /* The devices_enum has been RETAIN'ed by the pvar, so we can RELEASE it here, and the enum will be destroyed when the pvar is destroyed. */