Esempio n. 1
0
/**
 * Gets the node type for the specified HFI.
 *
 * @param port          The pointer to the port object for which the node type is asked.
 * @param nodeType
 *
 * @return FSTATUS
 */
FSTATUS oib_get_hfi_node_type(IN struct oib_port *port, OUT int *nodeType)
{
	FSTATUS status;
	umad_ca_t cainfo;
	
	if (port == NULL)
	{
		OUTPUT_ERROR("Port must be specified.\n");
		return FINVALID_PARAMETER;
	}
	else if (nodeType == NULL)
	{
		OUTPUT_ERROR("Invalid output pointer.\n");
		return FINVALID_PARAMETER;
	}
	
	status = umad_get_ca(port->hfi_name, &cainfo);
	if (status != FSUCCESS)
	{
		OUTPUT_ERROR("umad_get_ca() failed (returned: %u)\n", status);
		return status;
	}
	
	*nodeType = cainfo.node_type;
	umad_release_ca(&cainfo);
	return FSUCCESS;
}
Esempio n. 2
0
static int
ca_stat(char *ca_name, int portnum, int no_ports)
{
	umad_ca_t ca;
	int r;

	if ((r = umad_get_ca(ca_name, &ca)) < 0)
		return r;

	if (!ca.node_type)
		return 0;

	if (!no_ports && portnum >= 0) {
		if (portnum > ca.numports || !ca.ports[portnum]) {
			IBWARN("%s: '%s' has no port number %d - max (%d)",
				((uint)ca.node_type <= IB_NODE_MAX ? node_type_str[ca.node_type] : "???"),
				ca_name, portnum, ca.numports);
			return -1;
		}
		printf("%s: '%s'\n", ((uint)ca.node_type <= IB_NODE_MAX ? node_type_str[ca.node_type] : "???"), ca.ca_name);
		port_dump(ca.ports[portnum], 1);
		return 0;
	}

	/* print ca header */
	ca_dump(&ca);

	if (no_ports)
		return 0;

	for (portnum = 0; portnum <= ca.numports; portnum++)
		port_dump(ca.ports[portnum], 0);

	return 0;
}
Esempio n. 3
0
/**
 * use libumad to discover IB ports
 */
static void
init_ib_counter(  )
{
	char names[20][UMAD_CA_NAME_LEN];
	int n, i;
	char *ca_name;
	umad_ca_t ca;
	int r;
	int portnum;

	if ( umad_init(  ) < 0 ) {
		fprintf( stderr, "can't init UMAD library\n" );
		exit( 1 );
	}

	if ( ( n = umad_get_cas_names( ( void * ) names, UMAD_CA_NAME_LEN ) ) < 0 ) {
		fprintf( stderr, "can't list IB device names\n" );
		exit( 1 );
	}

	for ( i = 0; i < n; i++ ) {
		ca_name = names[i];

		if ( ( r = umad_get_ca( ca_name, &ca ) ) < 0 ) {
			fprintf( stderr, "can't read ca from IB device\n" );
			exit( 1 );
		}

		if ( !ca.node_type )
			continue;

		/* port numbers are '1' based in OFED */
		for ( portnum = 1; portnum <= ca.numports; portnum++ )
			addIBPort( ca.ca_name, ca.ports[portnum] );
	}
}
Esempio n. 4
0
/**
 * Get the type of a device, from name.
 *
 * Output in hca_type
 *
 */
int hcaNameToType(char *dev_name, HCA_Type* hca_type)
{
    MPIDI_STATE_DECL(MPID_STATE_HCANAMETOTYPE);
    MPIDI_FUNC_ENTER(MPID_STATE_HCANAMETOTYPE);
    int mpi_errno = MPI_SUCCESS;
    int rate;

    *hca_type = UNKNOWN_HCA;

    if (!strncmp(dev_name, "mlx4", 4) || !strncmp(dev_name, "mthca", 5)) {
        umad_ca_t umad_ca;

        *hca_type = MLX_PCI_X;

        if (umad_init() < 0) {
            MPIU_ERR_SETANDJUMP(mpi_errno, MPI_ERR_OTHER, "**umadinit");
        }

        memset(&umad_ca, 0, sizeof(umad_ca_t));
        if (umad_get_ca(dev_name, &umad_ca) < 0) {
            MPIU_ERR_SETANDJUMP(mpi_errno, MPI_ERR_OTHER, "**umadgetca");
        }

        rate = get_rate(&umad_ca);
        if (!rate) {
            umad_release_ca(&umad_ca);
            umad_done();
            MPIU_ERR_SETANDJUMP(mpi_errno, MPI_ERR_OTHER, "**umadgetrate");
        }

        if (!strncmp(dev_name, "mthca", 5)) {
            *hca_type = MLX_PCI_X;

            if (!strncmp(umad_ca.ca_type, "MT25", 4)) {
                switch (rate) {
                case 20:
                    *hca_type = MLX_PCI_EX_DDR;
                    break;
                case 10:
                    *hca_type = MLX_PCI_EX_SDR;
                    break;
                default:
                    *hca_type = MLX_PCI_EX_SDR;
                    break;
                }
            } else if (!strncmp(umad_ca.ca_type, "MT23", 4)) {
                *hca_type = MLX_PCI_X;
            } else {
                *hca_type = MLX_PCI_EX_SDR;
            }
        } else { /* mlx4 */
            switch(rate) {
            case 40:
                *hca_type = MLX_CX_QDR;
                break;
            case 20:
                *hca_type = MLX_CX_DDR;
                break;
            case 10:
                *hca_type = MLX_CX_SDR;
                break;
            default:
                *hca_type = MLX_CX_SDR;
                break;
            }
        }

        umad_release_ca(&umad_ca);
        umad_done();
    } else if(!strncmp(dev_name, "ipath", 5)) {
        *hca_type = PATH_HT;
    } else if(!strncmp(dev_name, "ehca", 4)) {
        *hca_type = IBM_EHCA;
    } else if (!strncmp(dev_name, "cxgb3", 5)) {
        *hca_type = CHELSIO_T3;
    } else if (!strncmp(dev_name, "cxgb4", 5)) {
        *hca_type = CHELSIO_T4;
    } else {
        *hca_type = UNKNOWN_HCA;
    }

fn_fail:
    MPIDI_FUNC_EXIT(MPID_STATE_HCANAMETOTYPE);
    return mpi_errno;
}