Beispiel #1
0
osm_ca_info_t *osm_ca_info_new(IN osm_vendor_t * const p_vend,
			       IN const ib_net64_t ca_guid)
{
	ib_api_status_t status;
	osm_ca_info_t *p_ca_info;

	OSM_LOG_ENTER(p_vend->p_log);

	CL_ASSERT(ca_guid);

	p_ca_info = malloc(sizeof(*p_ca_info));
	if (p_ca_info == NULL)
		goto Exit;

	memset(p_ca_info, 0, sizeof(*p_ca_info));

	status = __osm_ca_info_init(p_vend, p_ca_info, ca_guid);
	if (status != IB_SUCCESS) {
		osm_ca_info_destroy(p_vend, p_ca_info);
		p_ca_info = NULL;
		goto Exit;
	}

Exit:
	OSM_LOG_EXIT(p_vend->p_log);
	return (p_ca_info);
}
Beispiel #2
0
ib_api_status_t
osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
			     IN ib_port_attr_t * const p_attr_array,
			     IN uint32_t * const p_num_ports)
{
	ib_api_status_t status;

	uint32_t ca;
	uintn_t ca_count;
	uint32_t port_count = 0;
	uint8_t port_num;
	uint32_t total_ports = 0;
	ib_net64_t *p_ca_guid = NULL;
	osm_ca_info_t *p_ca_info;

	OSM_LOG_ENTER(p_vend->p_log);

	CL_ASSERT(p_vend);
	CL_ASSERT(p_vend->p_ca_info == NULL);

	/*
	   1) Determine the number of CA's
	   2) Allocate an array big enough to hold the ca info objects.
	   3) Call again to retrieve the guids.
	 */
	status = __osm_vendor_get_ca_guids(p_vend, &p_ca_guid, &ca_count);

	p_vend->p_ca_info = malloc(ca_count * sizeof(*p_vend->p_ca_info));
	if (p_vend->p_ca_info == NULL) {
		osm_log(p_vend->p_log, OSM_LOG_ERROR,
			"osm_vendor_get_all_port_attr: ERR 3B11: "
			"Unable to allocate CA information array.\n");
		goto Exit;
	}

	memset(p_vend->p_ca_info, 0, ca_count * sizeof(*p_vend->p_ca_info));
	p_vend->ca_count = ca_count;

	/*
	   For each CA, retrieve the port info attributes
	 */
	for (ca = 0; ca < ca_count; ca++) {
		p_ca_info = &p_vend->p_ca_info[ca];

		status = __osm_ca_info_init(p_vend, p_ca_info, p_ca_guid[ca]);

		if (status != IB_SUCCESS) {
			osm_log(p_vend->p_log, OSM_LOG_ERROR,
				"osm_vendor_get_all_port_attr: ERR 3B12: "
				"Unable to initialize CA Info object (%s).\n",
				ib_get_err_str(status));
		}

		total_ports += osm_ca_info_get_num_ports(p_ca_info);
	}

	/*
	   If the user supplied enough storage, return the port guids,
	   otherwise, return the appropriate error.
	 */
	if (*p_num_ports >= total_ports) {
		for (ca = 0; ca < ca_count; ca++) {
			uint32_t num_ports;

			p_ca_info = &p_vend->p_ca_info[ca];

			num_ports = osm_ca_info_get_num_ports(p_ca_info);

			for (port_num = 0; port_num < num_ports; port_num++) {
				p_attr_array[port_count] =
				    *__osm_ca_info_get_port_attr_ptr(p_ca_info,
								     port_num);
				port_count++;
			}
		}
	} else {
		status = IB_INSUFFICIENT_MEMORY;
	}

	*p_num_ports = total_ports;

Exit:
	if (p_ca_guid)
		free(p_ca_guid);

	OSM_LOG_EXIT(p_vend->p_log);
	return (status);
}
Beispiel #3
0
/**********************************************************************
 * Fill in the array of port_attr with all available ports on ALL the
 * avilable CAs on this machine.
 * ALSO -
 * Update the vendor object list of ca_info structs
 **********************************************************************/
ib_api_status_t
osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
			     IN ib_port_attr_t * const p_attr_array,
			     IN uint32_t * const p_num_ports)
{
	ib_api_status_t status;

	uint32_t ca;
	uint32_t ca_count = 0;
	uint32_t port_count = 0;
	uint8_t port_num;
	uint32_t total_ports = 0;
	VAPI_hca_id_t *p_ca_ids = NULL;
	osm_ca_info_t *p_ca_infos = NULL;
	uint32_t attr_array_sz = *p_num_ports;

	OSM_LOG_ENTER(p_vend->p_log);

	CL_ASSERT(p_vend);

	/* determine the number of CA's */
	status = __osm_vendor_get_ca_ids(p_vend, &p_ca_ids, &ca_count);
	if (status != IB_SUCCESS) {
		osm_log(p_vend->p_log, OSM_LOG_ERROR,
			"osm_vendor_get_all_port_attr: ERR 3D13: "
			"Fail to get CA Ids.\n");
		goto Exit;
	}

	/* Allocate an array big enough to hold the ca info objects */
	p_ca_infos = malloc(ca_count * sizeof(osm_ca_info_t));
	if (p_ca_infos == NULL) {
		osm_log(p_vend->p_log, OSM_LOG_ERROR,
			"osm_vendor_get_all_port_attr: ERR 3D14: "
			"Unable to allocate CA information array.\n");
		goto Exit;
	}

	memset(p_ca_infos, 0, ca_count * sizeof(osm_ca_info_t));

	/*
	 * For each CA, retrieve the CA info attributes
	 */
	for (ca = 0; ca < ca_count; ca++) {
		status =
		    __osm_ca_info_init(p_vend, p_ca_ids[ca], &p_ca_infos[ca]);
		if (status != IB_SUCCESS) {
			osm_log(p_vend->p_log, OSM_LOG_ERROR,
				"osm_vendor_get_all_port_attr: ERR 3D15: "
				"Unable to initialize CA Info object (%s).\n",
				ib_get_err_str(status));
			goto Exit;
		}
		total_ports += p_ca_infos[ca].p_attr->num_ports;
	}

	*p_num_ports = total_ports;
	osm_log(p_vend->p_log, OSM_LOG_DEBUG,
		"osm_vendor_get_all_port_attr: total ports:%u \n", total_ports);

	/*
	 * If the user supplied enough storage, return the port guids,
	 * otherwise, return the appropriate error.
	 */
	if (attr_array_sz >= total_ports) {
		for (ca = 0; ca < ca_count; ca++) {
			uint32_t num_ports;

			num_ports = p_ca_infos[ca].p_attr->num_ports;

			for (port_num = 0; port_num < num_ports; port_num++) {
				p_attr_array[port_count] =
				    *__osm_ca_info_get_port_attr_ptr(&p_ca_infos
								     [ca],
								     port_num);
				port_count++;
			}
		}
	} else {
		status = IB_INSUFFICIENT_MEMORY;
		goto Exit;
	}

	status = IB_SUCCESS;

Exit:
	if (p_ca_ids)
		free(p_ca_ids);

	if (p_ca_infos) {
		osm_ca_info_destroy(p_vend, p_ca_infos, ca_count);
	}

	OSM_LOG_EXIT(p_vend->p_log);
	return (status);
}