Esempio n. 1
0
static void __osm_al_ca_err_callback(IN ib_async_event_rec_t * p_async_rec)
{
	osm_vendor_t *p_vend = (osm_vendor_t *) p_async_rec->context;
	OSM_LOG_ENTER(p_vend->p_log);

	osm_log(p_vend->p_log, OSM_LOG_ERROR,
		"__osm_al_ca_err_callback: ERR 3B01: "
		"Event on channel adapter (%s).\n",
		ib_get_async_event_str(p_async_rec->code));

	OSM_LOG_EXIT(p_vend->p_log);
}
void
osm_pkt_randomizer_destroy(IN OUT osm_pkt_randomizer_t ** pp_pkt_randomizer,
			   IN osm_log_t * p_log)
{
	OSM_LOG_ENTER(p_log);

	if (*pp_pkt_randomizer != NULL) {
		free((*pp_pkt_randomizer)->fault_dr_paths);
		free(*pp_pkt_randomizer);
	}
	OSM_LOG_EXIT(p_log);
}
Esempio n. 3
0
uint8_t
osm_vendor_get_port_num(IN osm_vendor_t * const p_vend,
			IN const ib_net64_t port_guid)
{
	uint8_t index;
	uint8_t num_ports;
	uint32_t num_guids = 0;
	osm_ca_info_t *p_ca_info;
	uint32_t ca;

	OSM_LOG_ENTER(p_vend->p_log);

	CL_ASSERT(port_guid);
	/*
	   First, locate the HCA that owns this port.
	 */
	if (p_vend->p_ca_info == NULL) {
		/*
		   Initialize the osm_ca_info_t array which allows
		   us to match port GUID to CA.
		 */
		osm_vendor_get_all_port_attr(p_vend, NULL, &num_guids);
	}

	CL_ASSERT(p_vend->p_ca_info);
	CL_ASSERT(p_vend->ca_count);

	for (ca = 0; ca < p_vend->ca_count; ca++) {
		p_ca_info = &p_vend->p_ca_info[ca];

		num_ports = osm_ca_info_get_num_ports(p_ca_info);
		CL_ASSERT(num_ports);

		for (index = 0; index < num_ports; index++) {
			if (port_guid ==
			    osm_ca_info_get_port_guid(p_ca_info, index)) {
				OSM_LOG_EXIT(p_vend->p_log);
				return (osm_ca_info_get_port_num
					(p_ca_info, index));
			}
		}
	}

	/*
	   No local CA owns this guid!
	 */
	osm_log(p_vend->p_log, OSM_LOG_ERROR,
		"osm_vendor_get_port_num: ERR 3B30: "
		"Unable to determine CA guid.\n");

	OSM_LOG_EXIT(p_vend->p_log);
	return (0);
}
Esempio n. 4
0
int osm_db_store(IN osm_db_domain_t * p_domain)
{
	osm_log_t *p_log = p_domain->p_db->p_log;
	osm_db_domain_imp_t *p_domain_imp;
	FILE *p_file;
	int status = 0;
	char *p_tmp_file_name;

	OSM_LOG_ENTER(p_log);

	p_domain_imp = (osm_db_domain_imp_t *) p_domain->p_domain_imp;
	p_tmp_file_name =
	    (char *)malloc(sizeof(char) *
			   (strlen(p_domain_imp->file_name) + 8));
	strcpy(p_tmp_file_name, p_domain_imp->file_name);
	strcat(p_tmp_file_name, ".tmp");

	cl_spinlock_acquire(&p_domain_imp->lock);

	/* open up the output file */
	p_file = fopen(p_tmp_file_name, "w");
	if (!p_file) {
		OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6107: "
			"Failed to open the db file:%s for writing\n",
			p_domain_imp->file_name);
		status = 1;
		goto Exit;
	}

	st_foreach(p_domain_imp->p_hash, __osm_dump_tbl_entry,
		   (st_data_t) p_file);
	fclose(p_file);

	/* move the domain file */
	status = remove(p_domain_imp->file_name);
	if (status) {
		OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6109: "
			"Failed to remove file:%s (err:%u)\n",
			p_domain_imp->file_name, status);
	}

	status = rename(p_tmp_file_name, p_domain_imp->file_name);
	if (status) {
		OSM_LOG(p_log, OSM_LOG_ERROR, "ERR 6108: "
			"Failed to rename the db file to:%s (err:%u)\n",
			p_domain_imp->file_name, status);
	}
Exit:
	cl_spinlock_release(&p_domain_imp->lock);
	free(p_tmp_file_name);
	OSM_LOG_EXIT(p_log);
	return status;
}
Esempio n. 5
0
static ib_api_status_t
__osm_vendor_open_ca(IN osm_vendor_t * const p_vend,
		     IN const ib_net64_t port_guid)
{
	ib_net64_t ca_guid;
	ib_api_status_t status;

	OSM_LOG_ENTER(p_vend->p_log);

	ca_guid = osm_vendor_get_ca_guid(p_vend, port_guid);
	if (ca_guid == 0) {
		osm_log(p_vend->p_log, OSM_LOG_ERROR,
			"__osm_vendor_open_ca: ERR 3B31: "
			"Bad port GUID value 0x%" PRIx64 ".\n",
			cl_ntoh64(port_guid));
		status = IB_ERROR;
		goto Exit;
	}

	osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
		"__osm_vendor_open_ca: "
		"Opening HCA 0x%" PRIx64 ".\n", cl_ntoh64(ca_guid));

	status = ib_open_ca(p_vend->h_al,
			    ca_guid,
			    __osm_al_ca_err_callback, p_vend, &p_vend->h_ca);

	if (status != IB_SUCCESS) {
		osm_log(p_vend->p_log, OSM_LOG_ERROR,
			"__osm_vendor_open_ca: ERR 3B15: "
			"Unable to open CA (%s).\n", ib_get_err_str(status));
		goto Exit;
	}

	CL_ASSERT(p_vend->h_ca);

	status = ib_alloc_pd(p_vend->h_ca, IB_PDT_ALIAS, p_vend, &p_vend->h_pd);

	if (status != IB_SUCCESS) {
		ib_close_ca(p_vend->h_ca, __osm_al_ca_destroy_callback);
		osm_log(p_vend->p_log, OSM_LOG_ERROR,
			"__osm_vendor_open_ca: ERR 3B16: "
			"Unable to allocate protection domain (%s).\n",
			ib_get_err_str(status));
		goto Exit;
	}

	CL_ASSERT(p_vend->h_pd);

Exit:
	OSM_LOG_EXIT(p_vend->p_log);
	return (status);
}
Esempio n. 6
0
static void __osm_al_ca_destroy_callback(IN void *context)
{
	osm_al_bind_info_t *p_bind = (osm_al_bind_info_t *) context;
	osm_vendor_t *p_vend = p_bind->p_vend;
	OSM_LOG_ENTER(p_vend->p_log);

	osm_log(p_vend->p_log, OSM_LOG_INFO,
		"__osm_al_ca_destroy_callback: "
		"Closing local channel adapter.\n");

	OSM_LOG_EXIT(p_vend->p_log);
}
Esempio n. 7
0
static void
__osm_ucast_mgr_process_neighbors(IN cl_map_item_t * const p_map_item,
				  IN void *context)
{
	osm_switch_t *const p_sw = (osm_switch_t *) p_map_item;
	osm_ucast_mgr_t *const p_mgr = (osm_ucast_mgr_t *) context;
	osm_node_t *p_node;
	osm_node_t *p_remote_node;
	uint32_t port_num;
	uint8_t remote_port_num;
	uint32_t num_ports;
	osm_physp_t *p_physp;

	OSM_LOG_ENTER(p_mgr->p_log);

	p_node = p_sw->p_node;

	CL_ASSERT(p_node);
	CL_ASSERT(osm_node_get_type(p_node) == IB_NODE_TYPE_SWITCH);

	OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG,
		"Processing switch with GUID 0x%" PRIx64 "\n",
		cl_ntoh64(osm_node_get_node_guid(p_node)));

	num_ports = osm_node_get_num_physp(p_node);

	/*
	   Start with port 1 to skip the switch's management port.
	 */
	for (port_num = 1; port_num < num_ports; port_num++) {
		p_remote_node = osm_node_get_remote_node(p_node,
							 (uint8_t) port_num,
							 &remote_port_num);

		if (p_remote_node && p_remote_node->sw
		    && (p_remote_node != p_node)) {
			/* make sure the link is healthy. If it is not - don't
			   propagate through it. */
			p_physp = osm_node_get_physp_ptr(p_node, port_num);
			if (!p_physp || !osm_link_is_healthy(p_physp))
				continue;

			__osm_ucast_mgr_process_neighbor(p_mgr, p_sw,
							 p_remote_node->sw,
							 (uint8_t) port_num,
							 remote_port_num);

		}
	}

	OSM_LOG_EXIT(p_mgr->p_log);
}
Esempio n. 8
0
void
osm_ca_info_destroy(IN osm_vendor_t * const p_vend,
		    IN osm_ca_info_t * const p_ca_info)
{
	OSM_LOG_ENTER(p_vend->p_log);

	if (p_ca_info->p_attr)
		free(p_ca_info->p_attr);

	free(p_ca_info);

	OSM_LOG_EXIT(p_vend->p_log);
}
Esempio n. 9
0
/**********************************************************************
 * DEALOCATE osm_vendor_t
 **********************************************************************/
void osm_vendor_destroy(IN osm_vendor_t * const p_vend)
{
	OSM_LOG_ENTER(p_vend->p_log);
	osm_transaction_mgr_destroy(p_vend);

	/* Destroy the poller threads */
	/* HACK: can you destroy an un-initialized thread ? */
	pthread_cancel(p_vend->smi_bind.poller.osd.id);
	pthread_cancel(p_vend->gsi_bind.poller.osd.id);
	cl_thread_destroy(&(p_vend->smi_bind.poller));
	cl_thread_destroy(&(p_vend->gsi_bind.poller));
	OSM_LOG_EXIT(p_vend->p_log);
}
Esempio n. 10
0
/**********************************************************************
 * the idea here is to change the content of the bind such that it
 * will hold the local address used for sending directed route by the SMA.
 **********************************************************************/
ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
{
	osm_vendor_t *p_vend = ((osm_ts_bind_info_t *) h_bind)->p_vend;

	OSM_LOG_ENTER(p_vend->p_log);

	osm_log(p_vend->p_log, OSM_LOG_DEBUG,
		"osm_vendor_local_lid_change: DEBUG 2202: " "Change of LID.\n");

	OSM_LOG_EXIT(p_vend->p_log);

	return (IB_SUCCESS);
}
ib_api_status_t
osm_vendor_get_ports(IN osm_vendor_t * const p_vend,
		     IN ib_net64_t * const p_guids,
		     IN uint32_t * const num_guids)
{
	OSM_LOG_ENTER(p_vend->p_log);

	*p_guids = CL_NTOH64(0x0000000000001234);
	*num_guids = 1;

	OSM_LOG_EXIT(p_vend->p_log);
	return (IB_SUCCESS);
}
Esempio n. 12
0
static ib_net16_t mpr_rcv_get_end_points(IN osm_sa_t * sa,
					 IN const osm_madw_t * p_madw,
					 OUT osm_alias_guid_t ** pp_alias_guids,
					 OUT int *nsrc, OUT int *ndest)
{
	const ib_multipath_rec_t *p_mpr;
	const ib_sa_mad_t *p_sa_mad;
	ib_net64_t comp_mask;
	ib_net16_t sa_status = IB_SA_MAD_STATUS_SUCCESS;
	ib_gid_t *gids;

	OSM_LOG_ENTER(sa->p_log);

	/*
	   Determine what fields are valid and then get a pointer
	   to the source and destination port objects, if possible.
	 */
	p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
	p_mpr = (ib_multipath_rec_t *) ib_sa_mad_get_payload_ptr(p_sa_mad);
	gids = (ib_gid_t *) p_mpr->gids;

	comp_mask = p_sa_mad->comp_mask;

	/*
	   Check a few easy disqualifying cases up front before getting
	   into the endpoints.
	 */
	*nsrc = *ndest = 0;

	if (comp_mask & IB_MPR_COMPMASK_SGIDCOUNT) {
		*nsrc = p_mpr->sgid_count;
		if (*nsrc > IB_MULTIPATH_MAX_GIDS)
			*nsrc = IB_MULTIPATH_MAX_GIDS;
		sa_status = mpr_rcv_get_gids(sa, gids, *nsrc, 1, pp_alias_guids);
		if (sa_status != IB_SUCCESS)
			goto Exit;
	}

	if (comp_mask & IB_MPR_COMPMASK_DGIDCOUNT) {
		*ndest = p_mpr->dgid_count;
		if (*ndest + *nsrc > IB_MULTIPATH_MAX_GIDS)
			*ndest = IB_MULTIPATH_MAX_GIDS - *nsrc;
		sa_status =
		    mpr_rcv_get_gids(sa, gids + *nsrc, *ndest, 0,
				     pp_alias_guids + *nsrc);
	}

Exit:
	OSM_LOG_EXIT(sa->p_log);
	return sa_status;
}
Esempio n. 13
0
static ib_api_status_t
__osm_ca_info_init(IN osm_vendor_t * const p_vend,
		   IN osm_ca_info_t * const p_ca_info,
		   IN const ib_net64_t ca_guid)
{
	ib_api_status_t status;

	OSM_LOG_ENTER(p_vend->p_log);

	p_ca_info->guid = ca_guid;

	if (osm_log_is_active(p_vend->p_log, OSM_LOG_VERBOSE)) {
		osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
			"__osm_ca_info_init: "
			"Querying CA 0x%" PRIx64 ".\n", cl_ntoh64(ca_guid));
	}

	status = ib_query_ca_by_guid(p_vend->h_al, ca_guid, NULL,
				     &p_ca_info->attr_size);
	if ((status != IB_INSUFFICIENT_MEMORY) && (status != IB_SUCCESS)) {
		osm_log(p_vend->p_log, OSM_LOG_ERROR,
			"__osm_ca_info_init: ERR 3B05: "
			"Unexpected status getting CA attributes (%s).\n",
			ib_get_err_str(status));
		goto Exit;
	}

	CL_ASSERT(p_ca_info->attr_size);

	p_ca_info->p_attr = malloc(p_ca_info->attr_size);
	if (p_ca_info->p_attr == NULL) {
		osm_log(p_vend->p_log, OSM_LOG_ERROR,
			"__osm_ca_info_init: ERR 3B06: "
			"Unable to allocate attribute storage.\n");
		goto Exit;
	}

	status = ib_query_ca_by_guid(p_vend->h_al, ca_guid, p_ca_info->p_attr,
				     &p_ca_info->attr_size);
	if (status != IB_SUCCESS) {
		osm_log(p_vend->p_log, OSM_LOG_ERROR,
			"__osm_ca_info_init: ERR 3B07: "
			"Unexpected status getting CA attributes (%s).\n",
			ib_get_err_str(status));
		goto Exit;
	}

Exit:
	OSM_LOG_EXIT(p_vend->p_log);
	return (status);
}
Esempio n. 14
0
/* //////////////////////////////////////////////////////////////////////// */
ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
			 IN const uint32_t mad_size,
			 IN osm_vend_wrap_t * p_vend_wrap)
{
	/* FSTATUS Status; */
	/* uint32_t mad_count = 0; */
	/* MadtStruct *p_madt_struct; */
	mad_bind_info_t *p_mad_bind_info = (mad_bind_info_t *) h_bind;
	umadt_obj_t *p_umadt_obj = p_mad_bind_info->p_umadt_obj;
	ib_mad_t *p_mad;
	OSM_LOG_ENTER(p_umadt_obj->p_log);

	CL_ASSERT(h_bind);

	p_umadt_obj = p_mad_bind_info->p_umadt_obj;

	/*  Sanity check */
	CL_ASSERT(p_umadt_obj->init_done);
	CL_ASSERT(p_vend_wrap);
	CL_ASSERT(__valid_mad_handle(p_mad_bind_info));

#if 0
	mad_count = 1;
	Status =
	    p_umadt_obj->uMadtInterface.uMadtGetSendMad(p_mad_bind_info->
							umadt_handle,
							&mad_count,
							&p_madt_struct);

	if (Status != FSUCCESS || p_madt_struct == NULL) {
		p_vend_wrap->p_madt_struct = NULL;
		return NULL;
	}
	p_vend_wrap->p_madt_struct = p_madt_struct;
	p_vend_wrap->direction = SEND;
	return ((ib_mad_t *) & p_madt_struct->IBMad);
#endif				/*  0 */
	p_mad = (ib_mad_t *) malloc(mad_size);
	if (!p_mad) {
		p_vend_wrap->p_madt_struct = NULL;
		return NULL;
	}

	memset(p_mad, 0, mad_size);

	p_vend_wrap->p_madt_struct = NULL;
	p_vend_wrap->direction = SEND;
	p_vend_wrap->size = mad_size;
	return (p_mad);

}
/**********************************************************************
 The plock must be held before calling this function.
**********************************************************************/
static void pi_rcv_process_switch_port0(IN osm_sm_t * sm,
					IN osm_node_t * p_node,
					IN osm_physp_t * p_physp,
					IN ib_port_info_t * p_pi)
{
	ib_api_status_t status;
	osm_madw_context_t context;
	uint8_t port, num_ports;

	OSM_LOG_ENTER(sm->p_log);

	if (p_physp->need_update)
		sm->p_subn->ignore_existing_lfts = TRUE;

	pi_rcv_check_and_fix_lid(sm->p_log, p_pi, p_physp);

	/* Update the PortInfo attribute */
	osm_physp_set_port_info(p_physp, p_pi, sm);

	/* Determine if base switch port 0 */
	if (p_node->sw &&
	    !ib_switch_info_is_enhanced_port0(&p_node->sw->switch_info))
		/* PortState is not used on BSP0 but just in case it is DOWN */
		p_physp->port_info = *p_pi;

	/* Now, query PortInfo for the switch external ports */
	num_ports = osm_node_get_num_physp(p_node);

	context.pi_context.node_guid = osm_node_get_node_guid(p_node);
	context.pi_context.port_guid = osm_physp_get_port_guid(p_physp);
	context.pi_context.set_method = FALSE;
	context.pi_context.light_sweep = FALSE;
	context.pi_context.active_transition = FALSE;
	context.pi_context.client_rereg = FALSE;

	for (port = 1; port < num_ports; port++) {
		status = osm_req_get(sm, osm_physp_get_dr_path_ptr(p_physp),
				     IB_MAD_ATTR_PORT_INFO, cl_hton32(port),
				     FALSE,
				     ib_port_info_get_m_key(&p_physp->port_info),
				     CL_DISP_MSGID_NONE, &context);
		if (status != IB_SUCCESS)
			OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0F16: "
				"Failure initiating PortInfo request (%s)\n",
				ib_get_err_str(status));
	}

	pi_rcv_process_endport(sm, p_physp, p_pi);
	OSM_LOG_EXIT(sm->p_log);
}
Esempio n. 16
0
static void __osm_al_err_callback(IN ib_async_event_rec_t * p_async_rec)
{
	osm_al_bind_info_t *p_bind =
	    (osm_al_bind_info_t *) p_async_rec->context;
	osm_vendor_t *p_vend = p_bind->p_vend;
	OSM_LOG_ENTER(p_vend->p_log);

	osm_log(p_vend->p_log, OSM_LOG_ERROR,
		"__osm_al_err_callback: ERR 3B02: "
		"Error on QP (%s).\n",
		ib_get_async_event_str(p_async_rec->code));

	OSM_LOG_EXIT(p_vend->p_log);
}
Esempio n. 17
0
/**********************************************************************
 * Go over all remote SMs (as updated in the sm_guid_tbl).
 * Find the one with the highest priority and lowest guid.
 * Compare this SM to the local SM. If the local SM is higher -
 * return NULL, if the remote SM is higher - return a pointer to it.
 **********************************************************************/
static osm_remote_sm_t *state_mgr_get_highest_sm(IN osm_sm_t * sm)
{
	cl_qmap_t *p_sm_tbl;
	osm_remote_sm_t *p_sm = NULL;
	osm_remote_sm_t *p_highest_sm;
	uint8_t highest_sm_priority;
	ib_net64_t highest_sm_guid;
	osm_node_t *p_node;

	OSM_LOG_ENTER(sm->p_log);

	p_sm_tbl = &sm->p_subn->sm_guid_tbl;

	/* Start with the local sm as the standard */
	p_highest_sm = NULL;
	highest_sm_priority = sm->p_subn->opt.sm_priority;
	highest_sm_guid = sm->p_subn->sm_port_guid;

	/* go over all the remote SMs */
	for (p_sm = (osm_remote_sm_t *) cl_qmap_head(p_sm_tbl);
	     p_sm != (osm_remote_sm_t *) cl_qmap_end(p_sm_tbl);
	     p_sm = (osm_remote_sm_t *) cl_qmap_next(&p_sm->map_item)) {

		/* If the sm is in NOTACTIVE state - continue */
		if (ib_sminfo_get_state(&p_sm->smi) ==
		    IB_SMINFO_STATE_NOTACTIVE)
			continue;

		if (osm_sm_is_greater_than(ib_sminfo_get_priority(&p_sm->smi),
					   p_sm->smi.guid, highest_sm_priority,
					   highest_sm_guid)) {
			/* the new p_sm is with higher priority - update the highest_sm */
			/* to this sm */
			p_highest_sm = p_sm;
			highest_sm_priority =
			    ib_sminfo_get_priority(&p_sm->smi);
			highest_sm_guid = p_sm->smi.guid;
		}
	}

	if (p_highest_sm != NULL) {
		p_node = osm_get_node_by_guid(sm->p_subn, p_highest_sm->smi.guid);
		OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
			"Found higher SM with guid: %016" PRIx64 " (node %s)\n",
			cl_ntoh64(p_highest_sm->smi.guid),
			p_node ? p_node->print_desc : "UNKNOWN");
	}
	OSM_LOG_EXIT(sm->p_log);
	return p_highest_sm;
}
ib_api_status_t
osm_vendor_init(IN osm_vendor_t * const p_vend,
		IN osm_log_t * const p_log, IN const uint32_t timeout)
{
	OSM_LOG_ENTER(p_log);

	CL_ASSERT(p_vend);
	CL_ASSERT(p_log);

	p_vend->p_log = p_log;
	p_vend->timeout = timeout;
	OSM_LOG_EXIT(p_log);
	return (IB_SUCCESS);
}
Esempio n. 19
0
/*
 * Close the QP
 */
void
osmt_unbind_inform_qp(IN osmtest_t * const p_osmt, IN osmt_qp_ctx_t * p_qp_ctx)
{
	osm_log_t *p_log = &p_osmt->log;

	OSM_LOG_ENTER(p_log);

	osmt_mtl_mad_cleanup(&p_qp_ctx->qp_bind_hndl);

	IB_MGT_release_handle(p_qp_ctx->ib_mgt_qp0_handle);

	OSM_LOG(p_log, OSM_LOG_DEBUG, "Unbind QP handles\n");
	OSM_LOG_EXIT(&p_osmt->log);
}
Esempio n. 20
0
static ib_api_status_t
__osm_vendor_get_ca_guids(IN osm_vendor_t * const p_vend,
			  IN ib_net64_t ** const p_guids,
			  IN uintn_t * const p_num_guids)
{
	ib_api_status_t status;

	OSM_LOG_ENTER(p_vend->p_log);

	CL_ASSERT(p_guids);
	CL_ASSERT(p_num_guids);

	status = ib_get_ca_guids(p_vend->h_al, NULL, p_num_guids);
	if ((status != IB_INSUFFICIENT_MEMORY) && (status != IB_SUCCESS)) {
		osm_log(p_vend->p_log, OSM_LOG_ERROR,
			"__osm_vendor_get_ca_guids: ERR 3B08: "
			"Unexpected status getting CA GUID array (%s).\n",
			ib_get_err_str(status));
		goto Exit;
	}

	if (*p_num_guids == 0) {
		osm_log(p_vend->p_log, OSM_LOG_ERROR,
			"__osm_vendor_get_ca_guids: ERR 3B09: "
			"No available channel adapters.\n");
		status = IB_INSUFFICIENT_RESOURCES;
		goto Exit;
	}

	*p_guids = malloc(*p_num_guids * sizeof(**p_guids));
	if (*p_guids == NULL) {
		osm_log(p_vend->p_log, OSM_LOG_ERROR,
			"__osm_vendor_get_ca_guids: ERR 3B10: "
			"Unable to allocate CA GUID array.\n");
		goto Exit;
	}

	status = ib_get_ca_guids(p_vend->h_al, *p_guids, p_num_guids);
	CL_ASSERT(*p_num_guids);

	if (osm_log_is_active(p_vend->p_log, OSM_LOG_VERBOSE)) {
		osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
			"__osm_vendor_get_ca_guids: "
			"Detected %u local channel adapters.\n", *p_num_guids);
	}

Exit:
	OSM_LOG_EXIT(p_vend->p_log);
	return (status);
}
Esempio n. 21
0
ib_api_status_t
osm_transaction_mgr_get_madw_for_tid(IN osm_vendor_t * const p_vend,
				     IN ib_mad_t * const p_mad,
				     OUT osm_madw_t ** req_madw_p)
{
	osm_transaction_mgr_t *trans_mgr_p;
	osm_madw_req_t *osm_madw_req_p;
	cl_map_item_t *p_map_item;
	uint64_t key;
	OSM_LOG_ENTER(p_vend->p_log);

	trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;

	*req_madw_p = NULL;

	osm_log(p_vend->p_log, OSM_LOG_DEBUG,
		"osm_transaction_mgr_get_madw_for_tid: "
		"Looking for TID:<0x%" PRIx64 ">.\n", p_mad->trans_id);

	key = (uint64_t) p_mad->trans_id;
	cl_spinlock_acquire(&(trans_mgr_p->transaction_mgr_lock));
	p_map_item = cl_qmap_get(trans_mgr_p->madw_by_tid_map_p, key);
	if (p_map_item != cl_qmap_end(trans_mgr_p->madw_by_tid_map_p)) {
		/*  we found such an item.  */
		/*  get the osm_madw_req_p  */
		osm_madw_req_p =
		    PARENT_STRUCT(p_map_item, osm_madw_req_t, map_item);

		/*  Since the Transaction was looked up and provided for */
		/*  processing we retire it */
		cl_qlist_remove_item(trans_mgr_p->madw_reqs_list_p,
				     &(osm_madw_req_p->list_item));
		/*  remove the item from the qmap */
		cl_qmap_remove_item(trans_mgr_p->madw_by_tid_map_p,
				    &(osm_madw_req_p->map_item));

		osm_log(p_vend->p_log, OSM_LOG_DEBUG,
			"osm_transaction_mgr_get_madw_for_tid: "
			"Removed TID:<0x%" PRIx64 ">.\n", p_mad->trans_id);

		*req_madw_p = osm_madw_req_p->p_madw;
	}

	cl_spinlock_release(&(trans_mgr_p->transaction_mgr_lock));
	osm_log(p_vend->p_log, OSM_LOG_DEBUG,
		"osm_transaction_mgr_get_madw_for_tid: "
		"Got MADW:%p.\n", *req_madw_p);
	OSM_LOG_EXIT(p_vend->p_log);
	return (IB_SUCCESS);
}
Esempio n. 22
0
ib_api_status_t
osm_transaction_mgr_erase_madw(IN osm_vendor_t * const p_vend,
			       IN ib_mad_t * p_mad)
{
	osm_transaction_mgr_t *trans_mgr_p;
	osm_madw_req_t *osm_madw_req_p;
	uint64_t key;
	cl_map_item_t *p_map_item;
	OSM_LOG_ENTER(p_vend->p_log);

	trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;

	key = (uint64_t) p_mad->trans_id;
	osm_log(p_vend->p_log, OSM_LOG_DEBUG,
		"osm_transaction_mgr_erase_madw: "
		"Removing TID:<0x%" PRIx64 ">.\n", p_mad->trans_id);

	cl_spinlock_acquire(&trans_mgr_p->transaction_mgr_lock);
	p_map_item = cl_qmap_get(trans_mgr_p->madw_by_tid_map_p, key);
	if (p_map_item != cl_qmap_end(trans_mgr_p->madw_by_tid_map_p)) {
		/*  we found such an item.  */
		/*  get the osm_madw_req_p  */
		osm_madw_req_p =
		    PARENT_STRUCT(p_map_item, osm_madw_req_t, map_item);

		/*  remove the item from the qlist */
		cl_qlist_remove_item(trans_mgr_p->madw_reqs_list_p,
				     &(osm_madw_req_p->list_item));
		/*  remove the item from the qmap */
		cl_qmap_remove_item(trans_mgr_p->madw_by_tid_map_p,
				    &(osm_madw_req_p->map_item));

		osm_log(p_vend->p_log, OSM_LOG_DEBUG,
			"osm_transaction_mgr_erase_madw: "
			"Removed TID:<0x%" PRIx64 ">.\n", p_mad->trans_id);

		/*  free the item */
		free(osm_madw_req_p);
	} else {
		osm_log(p_vend->p_log, OSM_LOG_DEBUG,
			"osm_transaction_mgr_erase_madw: "
			"osm_transaction_mgr_erase_madw:<0x%" PRIx64
			"> NOT FOUND.\n", p_mad->trans_id);
	}
	cl_spinlock_release(&trans_mgr_p->transaction_mgr_lock);
	OSM_LOG_EXIT(p_vend->p_log);

	return (IB_SUCCESS);
}
ib_api_status_t
osmv_txn_init(IN osm_bind_handle_t h_bind,
	      IN uint64_t tid, IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn)
{
	ib_api_status_t st;
	osmv_txn_ctx_t *p_txn;
	osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;

	OSM_LOG_ENTER(p_bo->p_vendor->p_log);

	CL_ASSERT(NULL != h_bind && NULL != pp_txn);

	osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
		"Starting transaction 0x%016" PRIx64
		" (key=0x%016" PRIx64 ")\n", tid, key);

	p_txn = malloc(sizeof(osmv_txn_ctx_t));
	if (!p_txn) {
		return IB_INSUFFICIENT_MEMORY;
	}

	memset(p_txn, 0, sizeof(osmv_txn_ctx_t));
	p_txn->p_log = p_bo->txn_mgr.p_log;
	p_txn->tid = tid;
	p_txn->key = key;
	p_txn->p_madw = NULL;
	p_txn->rmpp_txfr.rmpp_state = OSMV_TXN_RMPP_NONE;

	/* insert into transaction manager DB */
	st = __osmv_txnmgr_insert_txn(&p_bo->txn_mgr, p_txn, key);
	if (IB_SUCCESS != st) {
		osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
			"osmv_txn_init: ERR 6703: "
			"Failed to insert to transaction 0x%016" PRIx64
			" (key=0x%016" PRIx64 ") to manager DB\n",
			tid, key);
		goto insert_txn_failed;
	}

	*pp_txn = p_txn;
	OSM_LOG_EXIT(p_bo->p_vendor->p_log);
	return IB_SUCCESS;

insert_txn_failed:
	free(p_txn);

	OSM_LOG_EXIT(p_bo->p_vendor->p_log);
	return st;
}
Esempio n. 24
0
/**********************************************************************
 Returns true if the SM port is down.
 The SM's port object must exist in the port_guid table.
**********************************************************************/
static boolean_t state_mgr_is_sm_port_down(IN osm_sm_t * sm)
{
	ib_net64_t port_guid;
	osm_port_t *p_port;
	osm_physp_t *p_physp;
	uint8_t state;

	OSM_LOG_ENTER(sm->p_log);

	port_guid = sm->p_subn->sm_port_guid;

	/*
	 * If we don't know our own port guid yet, assume the port is down.
	 */
	if (port_guid == 0) {
		OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3308: "
			"SM port GUID unknown\n");
		state = IB_LINK_DOWN;
		goto Exit;
	}

	CL_ASSERT(port_guid);

	CL_PLOCK_ACQUIRE(sm->p_lock);
	p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
	if (!p_port) {
		OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3309: "
			"SM port with GUID:%016" PRIx64 " is unknown\n",
			cl_ntoh64(port_guid));
		state = IB_LINK_DOWN;
		CL_PLOCK_RELEASE(sm->p_lock);
		goto Exit;
	}

	p_physp = p_port->p_physp;

	CL_ASSERT(p_physp);

	if (p_port->p_node->sw &&
	    !ib_switch_info_is_enhanced_port0(&p_port->p_node->sw->switch_info))
		state = IB_LINK_ACTIVE;	/* base SP0 */
	else
		state = osm_physp_get_port_state(p_physp);
	CL_PLOCK_RELEASE(sm->p_lock);

Exit:
	OSM_LOG_EXIT(sm->p_log);
	return (state == IB_LINK_DOWN);
}
Esempio n. 25
0
void osm_lft_rcv_process(IN void *context, IN void *data)
{
	osm_sm_t *sm = context;
	osm_madw_t *p_madw = data;
	ib_smp_t *p_smp;
	uint32_t block_num;
	osm_switch_t *p_sw;
	osm_lft_context_t *p_lft_context;
	uint8_t *p_block;
	ib_net64_t node_guid;
	ib_api_status_t status;

	CL_ASSERT(sm);

	OSM_LOG_ENTER(sm->p_log);

	CL_ASSERT(p_madw);

	p_smp = osm_madw_get_smp_ptr(p_madw);
	p_block = ib_smp_get_payload_ptr(p_smp);
	block_num = cl_ntoh32(p_smp->attr_mod);

	/*
	   Acquire the switch object for this switch.
	 */
	p_lft_context = osm_madw_get_lft_context_ptr(p_madw);
	node_guid = p_lft_context->node_guid;

	CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
	p_sw = osm_get_switch_by_guid(sm->p_subn, node_guid);

	if (!p_sw) {
		OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0401: "
			"LFT received for nonexistent node "
			"0x%" PRIx64 "\n", cl_ntoh64(node_guid));
	} else {
		status = osm_switch_set_lft_block(p_sw, p_block, block_num);
		if (status != IB_SUCCESS) {
			OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0402: "
				"Setting forwarding table block failed (%s)"
				", Switch 0x%" PRIx64 " %s\n",
				ib_get_err_str(status), cl_ntoh64(node_guid),
				p_sw->p_node->print_desc);
		}
	}

	CL_PLOCK_RELEASE(sm->p_lock);
	OSM_LOG_EXIT(sm->p_log);
}
Esempio n. 26
0
/**********************************************************************
 The plock must be held before calling this function.
**********************************************************************/
static void ni_rcv_process_existing_switch(IN osm_sm_t * sm,
					   IN osm_node_t * p_node,
					   IN const osm_madw_t * p_madw)
{
	OSM_LOG_ENTER(sm->p_log);

	/*
	   If this switch has already been probed during this sweep,
	   then don't bother reprobing it.
	 */
	if (p_node->discovery_count == 1)
		ni_rcv_process_switch(sm, p_node, p_madw);

	OSM_LOG_EXIT(sm->p_log);
}
Esempio n. 27
0
/* this is the callback function the "server" will call on incoming
   messages */
void __osmv_ibms_receiver_callback(void *p_ctx, ibms_mad_msg_t * p_mad)
{
	osm_mad_addr_t mad_addr;
	osmv_bind_obj_t *const p_bo = (osmv_bind_obj_t *) p_ctx;
	ib_api_status_t status = IB_SUCCESS;

	/* Make sure the p_bo object is still relevant */
	if ((p_bo->magic_ptr != p_bo) || p_bo->is_closing)
		return;

	{
		OSM_LOG_ENTER(p_bo->p_vendor->p_log);

		/* some logging */
		osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
			"__osmv_ibms_receiver_callback: "
			"MAD QPN:%d SLID:0x%04x class:0x%02x "
			"method:0x%02x attr:0x%04x status:0x%04x "
			"tid:0x%016" PRIx64 "\n",
			p_mad->addr.dqpn,
			cl_ntoh16(p_mad->addr.slid),
			p_mad->header.mgmt_class,
			p_mad->header.method,
			cl_ntoh16(p_mad->header.attr_id),
			cl_ntoh16(p_mad->header.status),
			cl_ntoh64(p_mad->header.trans_id));

		/* first arrange an address */
		__osmv_ibms_mad_addr_to_osm_addr(p_bo->p_vendor,
						 &p_mad->addr,
						 (((ib_mad_t *) & p_mad->
						   header)->mgmt_class ==
						  IB_MCLASS_SUBN_LID)
						 ||
						 (((ib_mad_t *) & p_mad->
						   header)->mgmt_class ==
						  IB_MCLASS_SUBN_DIR),
						 &mad_addr);

		/* call the receiver callback */

		status =
		    osmv_dispatch_mad((osm_bind_handle_t) p_bo,
				      (void *)&p_mad->header, &mad_addr);

		OSM_LOG_EXIT(p_bo->p_vendor->p_log);
	}
}
static void __osm_vendor_internal_unbind(osm_bind_handle_t h_bind)
{
	osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
	osm_log_t *p_log = p_bo->p_vendor->p_log;

	OSM_LOG_ENTER(p_log);

	/* "notifying" all that from now on no new sends can be done */
	p_bo->txn_mgr.p_event_wheel->closing = TRUE;

	osmv_txn_lock(p_bo);

	/*
	   the is_closing is set under lock we we know we only need to
	   check for it after obtaining the lock
	 */
	p_bo->is_closing = TRUE;

	/* notifying all sleeping rmpp sends to exit */
	osmv_txn_abort_rmpp_txns(h_bind);

	/* unlock the bo to allow for any residual mads to be dispatched */
	osmv_txn_unlock(p_bo);
	osm_log(p_log, OSM_LOG_DEBUG,
		"__osm_vendor_internal_unbind: destroying transport mgr.. \n");
	/* wait for the receiver thread to exit */
	osmv_transport_done(h_bind);

	/* lock to avoid any collissions while we cleanup the structs */
	osmv_txn_lock(p_bo);
	osm_log(p_log, OSM_LOG_DEBUG,
		"__osm_vendor_internal_unbind: destroying txn mgr.. \n");
	osmv_txnmgr_done(h_bind);
	osm_log(p_log, OSM_LOG_DEBUG,
		"__osm_vendor_internal_unbind: destroying bind lock.. \n");
	osmv_txn_unlock(p_bo);

	/*
	   we intentionally let the p_bo and its lock leak -
	   as we did not implement a way to track active bind handles provided to
	   the client - and the client might use them

	   cl_spinlock_destroy(&p_bo->lock);
	   free(p_bo);
	 */

	OSM_LOG_EXIT(p_log);
}
Esempio n. 29
0
static void sm_state_mgr_send_master_sm_info_req(osm_sm_t * sm)
{
	osm_madw_context_t context;
	const osm_port_t *p_port;
	ib_api_status_t status;

	OSM_LOG_ENTER(sm->p_log);

	memset(&context, 0, sizeof(context));
	if (sm->p_subn->sm_state == IB_SMINFO_STATE_STANDBY) {
		/*
		 * We are in STANDBY state - this means we need to poll the
		 * master SM (according to master_guid).
		 * Send a query of SubnGet(SMInfo) to the subn
		 * master_sm_base_lid object.
		 */
		p_port = osm_get_port_by_guid(sm->p_subn, sm->master_sm_guid);
	} else {
		/*
		 * We are not in STANDBY - this means we are in MASTER state -
		 * so we need to poll the SM that is saved in p_polling_sm
		 * under sm.
		 * Send a query of SubnGet(SMInfo) to that SM.
		 */
		p_port = sm->p_polling_sm->p_port;
	}
	if (p_port == NULL) {
		OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3203: "
			"No port object for GUID 0x%016" PRIx64 "\n",
			cl_ntoh64(sm->master_sm_guid));
		goto Exit;
	}

	context.smi_context.port_guid = p_port->guid;
	context.smi_context.set_method = FALSE;

	status = osm_req_get(sm, osm_physp_get_dr_path_ptr(p_port->p_physp),
			     IB_MAD_ATTR_SM_INFO, 0, CL_DISP_MSGID_NONE,
			     &context);

	if (status != IB_SUCCESS)
		OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 3204: "
			"Failure requesting SMInfo (%s)\n",
			ib_get_err_str(status));

Exit:
	OSM_LOG_EXIT(sm->p_log);
}
static void sa_pkey_create(IN osm_sa_t * sa, IN osm_physp_t * p_physp,
			   IN osm_pkey_search_ctxt_t * p_ctxt,
			   IN uint16_t block)
{
	osm_pkey_item_t *p_rec_item;
	uint16_t lid;
	ib_pkey_table_t *tbl;

	OSM_LOG_ENTER(sa->p_log);

	p_rec_item = malloc(sizeof(*p_rec_item));
	if (p_rec_item == NULL) {
		OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 4602: "
			"rec_item alloc failed\n");
		goto Exit;
	}

	if (p_physp->p_node->node_info.node_type != IB_NODE_TYPE_SWITCH)
		lid = p_physp->port_info.base_lid;
	else
		lid = osm_node_get_base_lid(p_physp->p_node, 0);

	OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
		"New P_Key table for: port 0x%016" PRIx64
		", lid %u, port %u Block:%u\n",
		cl_ntoh64(osm_physp_get_port_guid(p_physp)),
		cl_ntoh16(lid), osm_physp_get_port_num(p_physp), block);

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

	p_rec_item->rec.lid = lid;
	p_rec_item->rec.block_num = block;
	p_rec_item->rec.port_num = osm_physp_get_port_num(p_physp);
	/* FIXME: There are ninf.PartitionCap or swinf.PartitionEnforcementCap
	   pkey entries so everything in that range is a valid block number
	   even if opensm is not using it. Return 0. However things outside
	   that range should return no entries.. Not sure how to figure that
	   here? The range of pkey_tbl can be less than the cap, so
	   this falsely triggers. */
	tbl = osm_pkey_tbl_block_get(osm_physp_get_pkey_tbl(p_physp), block);
	if (tbl)
		p_rec_item->rec.pkey_tbl = *tbl;

	cl_qlist_insert_tail(p_ctxt->p_list, &p_rec_item->list_item);

Exit:
	OSM_LOG_EXIT(sa->p_log);
}