Beispiel #1
0
boolean_t osm_physp_share_pkey(IN osm_log_t * p_log,
			       IN const osm_physp_t * p_physp_1,
			       IN const osm_physp_t * p_physp_2,
			       IN boolean_t allow_both_pkeys)
{
	const osm_pkey_tbl_t *pkey_tbl1, *pkey_tbl2;

	if (p_physp_1 == p_physp_2)
		return TRUE;

	pkey_tbl1 = osm_physp_get_pkey_tbl(p_physp_1);
	pkey_tbl2 = osm_physp_get_pkey_tbl(p_physp_2);

	/*
	   The spec: 10.9.2 does not require each phys port to have PKey Table.
	   So actually if it does not, we need to use the default port instead.

	   HACK: meanwhile we will ignore the check
	 */
	if (cl_is_map_empty(&pkey_tbl1->keys)
	    || cl_is_map_empty(&pkey_tbl2->keys))
		return TRUE;

	return
	    !ib_pkey_is_invalid(osm_physp_find_common_pkey
				(p_physp_1, p_physp_2, allow_both_pkeys));
}
Beispiel #2
0
boolean_t osm_pkey_find_next_free_entry(IN osm_pkey_tbl_t * p_pkey_tbl,
					OUT uint16_t * p_block_idx,
					OUT uint8_t * p_pkey_idx)
{
	ib_pkey_table_t *p_new_block;

	CL_ASSERT(p_block_idx);
	CL_ASSERT(p_pkey_idx);

	while (*p_block_idx < p_pkey_tbl->max_blocks) {
		if (*p_pkey_idx > IB_NUM_PKEY_ELEMENTS_IN_BLOCK - 1) {
			*p_pkey_idx = 0;
			(*p_block_idx)++;
			if (*p_block_idx >= p_pkey_tbl->max_blocks)
				return FALSE;
		}

		p_new_block =
		    osm_pkey_tbl_new_block_get(p_pkey_tbl, *p_block_idx);

		if (!p_new_block ||
		    ib_pkey_is_invalid(p_new_block->pkey_entry[*p_pkey_idx]))
			return TRUE;
		else
			(*p_pkey_idx)++;
	}
	return FALSE;
}
Beispiel #3
0
/** ===========================================================================
 */
static void extract_host_port(osm_port_t *p_port, uint64_t *p_pkey_base_offset,
			      uint64_t *p_pkey_offset, uint64_t *p_port_offset,
			      uint64_t *p_link_offset,
			      struct ssa_db_extract *p_ssa_db)
{
	const osm_pkey_tbl_t *p_pkey_tbl;
	const ib_pkey_table_t *block;
	osm_physp_t *p_physp = p_port->p_physp;
	ib_net16_t pkey;
	uint16_t block_index, pkey_idx;

	p_pkey_tbl = osm_physp_get_pkey_tbl(p_physp);
	for (block_index = 0; block_index < p_pkey_tbl->used_blocks;
	     block_index++) {
		block = osm_pkey_tbl_block_get(p_pkey_tbl, block_index);
		if (!block)
			continue;
		for (pkey_idx = 0; pkey_idx < IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
		     pkey_idx++) {
			pkey = block->pkey_entry[pkey_idx];
			if (ib_pkey_is_invalid(pkey))
				continue;

			p_ssa_db->p_pkey_tbl[*p_pkey_base_offset + *p_pkey_offset] = pkey;
			*p_pkey_offset = *p_pkey_offset + 1;
		}
	}

	if (*p_pkey_offset >= SSA_EXTRACT_PKEYS_MAX) {
		ssa_log_err(SSA_LOG_DEFAULT,
			    "ERROR - truncating number of pkeys "
			    "from %d to %d (maximum) for LID %u\n",
			    *p_pkey_offset, SSA_EXTRACT_PKEYS_MAX - 1,
			    ntohs(osm_physp_get_base_lid(p_physp)));
		*p_pkey_offset = SSA_EXTRACT_PKEYS_MAX - 1;
	}

	extract_port(p_physp, NULL, htonll(*p_pkey_base_offset * sizeof(pkey)),
		     htons(*p_pkey_offset * sizeof(pkey)),
		     p_port_offset, p_ssa_db);

	if (!osm_physp_get_remote(p_physp))
		return;

	extract_link(p_physp, NULL, p_link_offset, p_ssa_db);
}
Beispiel #4
0
boolean_t osm_physp_has_pkey(IN osm_log_t * p_log, IN ib_net16_t pkey,
			     IN const osm_physp_t * p_physp)
{
	ib_net16_t *p_pkey, pkey_base;
	const osm_pkey_tbl_t *pkey_tbl;
	boolean_t res = FALSE;

	OSM_LOG_ENTER(p_log);

	OSM_LOG(p_log, OSM_LOG_DEBUG,
		"Search for PKey: 0x%04x\n", cl_ntoh16(pkey));

	/* if the pkey given is an invalid pkey - return TRUE. */
	if (ib_pkey_is_invalid(pkey)) {
		OSM_LOG(p_log, OSM_LOG_DEBUG,
			"Given invalid PKey - we treat it loosely and allow it\n");
		res = TRUE;
		goto Exit;
	}

	pkey_base = ib_pkey_get_base(pkey);

	pkey_tbl = osm_physp_get_pkey_tbl(p_physp);

	p_pkey = cl_map_get(&pkey_tbl->keys, pkey_base);
	if (p_pkey) {
		res = TRUE;
		OSM_LOG(p_log, OSM_LOG_DEBUG,
			"PKey 0x%04x was found\n", cl_ntoh16(pkey));
	} else
		OSM_LOG(p_log, OSM_LOG_DEBUG,
			"PKey 0x%04x was not found\n", cl_ntoh16(pkey));

Exit:
	OSM_LOG_EXIT(p_log);
	return res;
}
Beispiel #5
0
/** ===========================================================================
 */
static void extract_switch_port(osm_port_t *p_port, uint64_t *p_pkey_base_offset,
				uint64_t *p_pkey_offset, uint64_t *p_port_offset,
				uint64_t *p_link_offset,
				struct ssa_db_extract *p_ssa_db)
{
	osm_node_t *p_node = p_port->p_physp->p_node;
	const osm_pkey_tbl_t *p_pkey_tbl;
	const ib_pkey_table_t *block;
	osm_physp_t *p_physp;
	uint32_t i;
	ib_net16_t pkey;
	uint16_t lid_ho, block_index, pkey_idx;

	for (i = 0; i < p_node->physp_tbl_size; i++) {
		p_physp = osm_node_get_physp_ptr(p_node, i);
		if (!p_physp)
			continue;

		/* TODO: add filtering for down ports */

		if (i == 0) {
			lid_ho = ntohs(osm_physp_get_base_lid(p_physp));

			p_pkey_tbl = osm_physp_get_pkey_tbl(p_physp);
			for (block_index = 0; block_index < p_pkey_tbl->used_blocks;
			     block_index++) {
				block = osm_pkey_tbl_block_get(p_pkey_tbl, block_index);
				if (!block)
					continue;
				for (pkey_idx = 0; pkey_idx < IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
				     pkey_idx++) {
					pkey = block->pkey_entry[pkey_idx];
					if (ib_pkey_is_invalid(pkey))
						continue;

					p_ssa_db->p_pkey_tbl[*p_pkey_base_offset + *p_pkey_offset] = pkey;
					*p_pkey_offset = *p_pkey_offset + 1;
				}
			}

			if (*p_pkey_offset >= SSA_EXTRACT_PKEYS_MAX) {
				ssa_log_err(SSA_LOG_DEFAULT,
					    "ERROR - truncating number of pkeys "
					    "from %d to %d (maximum) for LID %u\n",
					    *p_pkey_offset, SSA_EXTRACT_PKEYS_MAX - 1, lid_ho);
				*p_pkey_offset = SSA_EXTRACT_PKEYS_MAX - 1;
			}

			extract_port(p_physp, &lid_ho,
				     htonll(*p_pkey_base_offset * sizeof(pkey)),
				     htons(*p_pkey_offset * sizeof(pkey)),
				     p_port_offset, p_ssa_db);
		} else {
			extract_port(p_physp, &lid_ho, 0, 0, p_port_offset,
				     p_ssa_db);
		}

		if (!osm_physp_get_remote(p_physp))
			continue;

		extract_link(p_physp, &lid_ho, p_link_offset, p_ssa_db);
	}
}
Beispiel #6
0
/** ===========================================================================
 */
static void dump_port_qos(osm_port_t *p_port)
{
#ifdef SSA_PLUGIN_VERBOSE_LOGGING
	const osm_pkey_tbl_t *p_pkey_tbl;
	const ib_pkey_table_t *block;
	//char *header_line =    "#in out : 0  1  2  3  4  5  6  7  8  9  10 11 12 13 14 15";
	//char *separator_line = "#--------------------------------------------------------";
	//ib_slvl_table_t *p_tbl;
	ib_net16_t pkey;
	uint16_t block_index, max_pkeys, pkey_idx;
	//uint8_t out_port, in_port, num_ports;
	//uint8_t n;

//	ssa_log(SSA_LOG_VERBOSE, "\t\t\tSLVL tables\n");
//	ssa_log(SSA_LOG_VERBOSE, "%s\n", header_line);
//	ssa_log(SSA_LOG_VERBOSE, "%s\n", separator_line);
//
//	out_port = p_port->p_physp->port_num;
//	num_ports = p_port->p_physp->p_node->node_info.num_ports;
//	if (osm_node_get_type(p_port->p_physp->p_node) ==
//		IB_NODE_TYPE_SWITCH) {
//		/* no need to print SL2VL table for port that is down */
//		/* TODO: not sure if it is needed */
//		/*if (!p_port->p_physp->p_remote_physp)
//			continue; */
//
//		for (in_port = 0; in_port <= num_ports; in_port++) {
//			p_tbl = osm_physp_get_slvl_tbl(p_port->p_physp,
//						       in_port);
//			for (i = 0, n = 0; i < 16; i++)
//				n += sprintf(buffer + n, " %-2d",
//					ib_slvl_table_get(p_tbl, i));
//				ssa_log(SSA_LOG_VERBOSE, "%-3d %-3d :%s\n",
//					in_port, out_port, buffer);
//		}
//	} else {
//		p_tbl = osm_physp_get_slvl_tbl(p_port->p_physp, 0);
//		for (i = 0, n = 0; i < 16; i++)
//			n += sprintf(buffer + n, " %-2d",
//					ib_slvl_table_get(p_tbl, i));
//			ssa_log(SSA_LOG_VERBOSE, "%-3d %-3d :%s\n", out_port,
//				out_port, buffer);
//	}
//
	max_pkeys = ntohs(p_port->p_node->node_info.partition_cap);
	ssa_log(SSA_LOG_VERBOSE, "PartitionCap %u\n", max_pkeys);
	p_pkey_tbl = osm_physp_get_pkey_tbl(p_port->p_physp);
	ssa_log(SSA_LOG_VERBOSE, "PKey Table %u used blocks\n",
		p_pkey_tbl->used_blocks);
	for (block_index = 0; block_index < p_pkey_tbl->used_blocks;
	     block_index++) {
		block = osm_pkey_tbl_new_block_get(p_pkey_tbl, block_index);
		if (!block)
			continue;
		for (pkey_idx = 0; pkey_idx < IB_NUM_PKEY_ELEMENTS_IN_BLOCK;
		     pkey_idx++) {
			pkey = block->pkey_entry[pkey_idx];
			if (ib_pkey_is_invalid(pkey))
				continue;
			ssa_log(SSA_LOG_VERBOSE, "PKey 0x%04x at block %u "
				"index %u\n", ntohs(pkey), block_index,
				pkey_idx);
		}
	}
#else
	(void)(p_port);
#endif
}
Beispiel #7
0
ib_api_status_t osm_pkey_tbl_set(IN osm_pkey_tbl_t * p_pkey_tbl,
				 IN uint16_t block, IN ib_pkey_table_t * p_tbl,
				 IN boolean_t allow_both_pkeys)
{
	uint16_t b, i;
	ib_pkey_table_t *p_pkey_block;
	uint16_t *p_prev_pkey;
	ib_net16_t pkey, pkey_base;

	/* make sure the block is allocated */
	if (cl_ptr_vector_get_size(&p_pkey_tbl->blocks) > block)
		p_pkey_block =
		    (ib_pkey_table_t *) cl_ptr_vector_get(&p_pkey_tbl->blocks,
							  block);
	else
		p_pkey_block = NULL;

	if (!p_pkey_block) {
		p_pkey_block =
		    (ib_pkey_table_t *) malloc(sizeof(ib_pkey_table_t));
		if (!p_pkey_block)
			return IB_ERROR;
		memset(p_pkey_block, 0, sizeof(ib_pkey_table_t));
		cl_ptr_vector_set(&p_pkey_tbl->blocks, block, p_pkey_block);
	}

	/* sets the block values */
	memcpy(p_pkey_block, p_tbl, sizeof(ib_pkey_table_t));

	/*
	   NOTE: as the spec does not require uniqueness of PKeys in
	   tables there is no other way but to refresh the entire keys map.

	   Moreover, if the same key exists but with full membership it should
	   have precedence over the key with limited membership !
	 */
	cl_map_remove_all(&p_pkey_tbl->keys);

	for (b = 0; b < cl_ptr_vector_get_size(&p_pkey_tbl->blocks); b++) {

		p_pkey_block = cl_ptr_vector_get(&p_pkey_tbl->blocks, b);
		if (!p_pkey_block)
			continue;

		for (i = 0; i < IB_NUM_PKEY_ELEMENTS_IN_BLOCK; i++) {
			pkey = p_pkey_block->pkey_entry[i];
			if (ib_pkey_is_invalid(pkey))
				continue;

			if (allow_both_pkeys)
				pkey_base = pkey;
			else
				pkey_base = ib_pkey_get_base(pkey);

			/*
			   If allow_both_pkeys is FALSE,
			   ignore the PKey Full Member bit in the key but store
			   the pointer to the table element as the map value
			 */
			p_prev_pkey = cl_map_get(&p_pkey_tbl->keys, pkey_base);

			/* we only insert if no previous or it is not full member and allow_both_pkeys is FALSE */
			if ((p_prev_pkey == NULL) ||
			    (allow_both_pkeys == FALSE &&
			     cl_ntoh16(*p_prev_pkey) < cl_ntoh16(pkey)))
				cl_map_insert(&p_pkey_tbl->keys, pkey_base,
					      &(p_pkey_block->pkey_entry[i])
				    );
		}
	}
	return IB_SUCCESS;
}