[openib-general] [PATCH] osm: support for trivial PKey manager
Ofer Gigi
oferg at mellanox.co.il
Thu Dec 29 02:20:31 PST 2005
Hi Hal,
My name is Ofer Gigi, and I am a new software engineer in Mellanox
working on OpenSM.
This patch provides a new manager that solves the following problem:
OpenSM is not currently compliant to the spec statement:
C14.62.1.1 Table 183 p870 l34:
"However, the SM shall ensure that one of the P_KeyTable entries in every
node contains either the value 0xFFFF (the default P_Key, full membership)
or the value 0x7FFF (the default P_Key, partial membership)."
Luckily, all IB devices comes up from reset with preconfigured 0xffff key.
This was discovered during last plugfest.
To overcome this limitation I implemented a simple elementary PKey manager
that will enforce the above rule (currently adds 0xffff if missing).
This additional manager would be used for a full PKey policy manager
in the future.
We have tested this patch
Thanks
Ofer G.
Signed-off-by: Ofer Gigi <oferg at mellanox.co.il>
Index: include/opensm/osm_pkey_mgr.h
===================================================================
--- include/opensm/osm_pkey_mgr.h (revision 0)
+++ include/opensm/osm_pkey_mgr.h (revision 0)
@@ -0,0 +1,259 @@
+/*
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id: osm_pkey_mgr.h 1743 2005-12-15 09:38:35Z oferg $
+ */
+
+
+/*
+ * Abstract:
+ * Declaration of osm_pkey_mgr_t.
+ * This object represents the P_Key Manager object.
+ * This object is part of the OpenSM family of objects.
+ *
+ * Environment:
+ * Linux User Mode
+ *
+ * $Revision: 1.4 $
+ */
+
+
+#ifndef _OSM_PKEY_MGR_H_
+#define _OSM_PKEY_MGR_H_
+
+#include <complib/cl_passivelock.h>
+#include <opensm/osm_subnet.h>
+#include <opensm/osm_req.h>
+#include <opensm/osm_log.h>
+
+#ifdef __cplusplus
+# define BEGIN_C_DECLS extern "C" {
+# define END_C_DECLS }
+#else /* !__cplusplus */
+# define BEGIN_C_DECLS
+# define END_C_DECLS
+#endif /* __cplusplus */
+
+BEGIN_C_DECLS
+
+/****h* OpenSM/P_Key Manager
+* NAME
+* P_Key Manager
+*
+* DESCRIPTION
+* The P_Key Manager object manage the p_key tables of all
+* objects in the subnet
+*
+* AUTHOR
+* Ofer Gigi, Mellanox
+*
+*********/
+/****s* OpenSM: P_Key Manager/osm_pkey_mgr_t
+* NAME
+* osm_pkey_mgr_t
+*
+* DESCRIPTION
+* p_Key Manager structure.
+*
+*
+* SYNOPSIS
+*/
+
+typedef struct _osm_pkey_mgr
+{
+ osm_subn_t *p_subn;
+ osm_log_t *p_log;
+ osm_req_t *p_req;
+ cl_plock_t *p_lock;
+
+} osm_pkey_mgr_t;
+
+/*
+* FIELDS
+* p_subn
+* Pointer to the Subnet object for this subnet.
+*
+* p_log
+* Pointer to the log object.
+*
+* p_req
+* Pointer to the Request object.
+*
+* p_lock
+* Pointer to the serializing lock.
+*
+* SEE ALSO
+* P_Key Manager object
+*********/
+
+/****** OpenSM: P_Key Manager/osm_pkey_mgr_construct
+* NAME
+* osm_pkey_mgr_construct
+*
+* DESCRIPTION
+* This function constructs a P_Key Manager object.
+*
+* SYNOPSIS
+*/
+void
+osm_pkey_mgr_construct(
+ IN osm_pkey_mgr_t* const p_mgr );
+/*
+* PARAMETERS
+* p_mgr
+* [in] Pointer to a P_Key Manager object to construct.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Allows calling osm_pkey_mgr_init, osm_pkey_mgr_destroy
+*
+* Calling osm_pkey_mgr_construct is a prerequisite to calling any other
+* method except osm_pkey_mgr_init.
+*
+* SEE ALSO
+* P_Key Manager object, osm_pkey_mgr_init,
+* osm_pkey_mgr_destroy
+*********/
+
+/****f* OpenSM: P_Key Manager/osm_pkey_mgr_destroy
+* NAME
+* osm_pkey_mgr_destroy
+*
+* DESCRIPTION
+* The osm_pkey_mgr_destroy function destroys the object, releasing
+* all resources.
+*
+* SYNOPSIS
+*/
+void
+osm_pkey_mgr_destroy(
+ IN osm_pkey_mgr_t* const p_mgr );
+/*
+* PARAMETERS
+* p_mgr
+* [in] Pointer to the object to destroy.
+*
+* RETURN VALUE
+* This function does not return a value.
+*
+* NOTES
+* Performs any necessary cleanup of the specified
+* P_Key Manager object.
+* Further operations should not be attempted on the destroyed object.
+* This function should only be called after a call to
+* osm_pkey_mgr_construct or osm_pkey_mgr_init.
+*
+* SEE ALSO
+* P_Key Manager object, osm_pkey_mgr_construct,
+* osm_pkey_mgr_init
+*********/
+
+/****f* OpenSM: P_Key Manager/osm_pkey_mgr_init
+* NAME
+* osm_pkey_mgr_init
+*
+* DESCRIPTION
+* The osm_pkey_mgr_init function initializes a
+* P_Key Manager object for use.
+*
+* SYNOPSIS
+*/
+ib_api_status_t
+osm_pkey_mgr_init(
+ IN osm_pkey_mgr_t* const p_mgr,
+ IN osm_subn_t* const p_subn,
+ IN osm_log_t* const p_log,
+ IN osm_req_t* const p_req,
+ IN cl_plock_t* const p_lock );
+/*
+* PARAMETERS
+* p_mgr
+* [in] Pointer to an osm_pkey_mgr_t object to initialize.
+*
+* p_subn
+* [in] Pointer to the Subnet object for this subnet.
+*
+* p_log
+* [in] Pointer to the log object.
+*
+* p_req
+* [in] Pointer to an osm_req_t object.
+*
+* p_lock
+* [in] Pointer to the OpenSM serializing lock.
+*
+* RETURN VALUES
+* IB_SUCCESS if the P_Key Manager object was initialized
+* successfully.
+*
+* NOTES
+* Allows calling other P_Key Manager methods.
+*
+* SEE ALSO
+* P_Key Manager object, osm_pkey_mgr_construct,
+* osm_pkey_mgr_destroy
+*********/
+
+/****f* OpenSM: P_Key Manager/osm_pkey_mgr_process
+* NAME
+* osm_pkey_mgr_process
+*
+* DESCRIPTION
+* This function enforce pkey rules on the SM DB.
+*
+* SYNOPSIS
+*/
+osm_signal_t
+osm_pkey_mgr_process(
+ IN const osm_pkey_mgr_t* const p_mgr );
+/*
+* PARAMETERS
+* p_mgr
+* [in] Pointer to an osm_pkey_mgr_t object.
+*
+* RETURN VALUES
+* None
+*
+* NOTES
+* Current Operations:
+* - Inserts IB_DEFAULT_PKEY to all node objects that don't have
+* IB_DEFAULT_PARTIAL_PKEY or IB_DEFAULT_PKEY as part
+* of their p_key table
+*
+* SEE ALSO
+* P_Key Manager
+*********/
+
+END_C_DECLS
+
+#endif /* _OSM_PKEY_MGR_H_ */
Index: include/opensm/osm_state_mgr.h
===================================================================
--- include/opensm/osm_state_mgr.h (revision 4651)
+++ include/opensm/osm_state_mgr.h (working copy)
@@ -60,6 +60,7 @@
#include <opensm/osm_mcast_mgr.h>
#include <opensm/osm_link_mgr.h>
#include <opensm/osm_drop_mgr.h>
+#include <opensm/osm_pkey_mgr.h>
#include <opensm/osm_sm_mad_ctrl.h>
#include <opensm/osm_log.h>
@@ -112,6 +113,7 @@ typedef struct _osm_state_mgr
osm_mcast_mgr_t *p_mcast_mgr;
osm_link_mgr_t *p_link_mgr;
osm_drop_mgr_t *p_drop_mgr;
+ osm_pkey_mgr_t *p_pkey_mgr;
osm_req_t *p_req;
osm_stats_t *p_stats;
struct _osm_sm_state_mgr *p_sm_state_mgr;
@@ -149,6 +151,9 @@ typedef struct _osm_state_mgr
* p_drop_mgr
* Pointer to the Drop Manager object.
*
+* p_pkey_mgr
+* Pointer to the P_Key Manager object.
+*
* p_req
* Pointer to the Requester object sending SMPs.
*
@@ -374,6 +379,7 @@ osm_state_mgr_init(
IN osm_mcast_mgr_t* const p_mcast_mgr,
IN osm_link_mgr_t* const p_link_mgr,
IN osm_drop_mgr_t* const p_drop_mgr,
+ IN osm_pkey_mgr_t* const p_pkey_mgr,
IN osm_req_t* const p_req,
IN osm_stats_t* const p_stats,
IN struct _osm_sm_state_mgr* const p_sm_state_mgr,
@@ -405,6 +411,9 @@ osm_state_mgr_init(
* p_drop_mgr
* [in] Pointer to the Drop Manager object.
*
+* p_pkey_mgr
+* [in] Pointer to the P_Key Manager object.
+*
* p_req
* [in] Pointer to the Request Controller object.
*
Index: include/opensm/osm_base.h
===================================================================
--- include/opensm/osm_base.h (revision 4651)
+++ include/opensm/osm_base.h (working copy)
@@ -578,8 +578,10 @@ typedef enum _osm_sm_state
OSM_SM_STATE_PROCESS_REQUEST_WAIT,
OSM_SM_STATE_PROCESS_REQUEST_DONE,
OSM_SM_STATE_MASTER_OR_HIGHER_SM_DETECTED,
+ OSM_SM_STATE_SET_PKEY,
+ OSM_SM_STATE_SET_PKEY_WAIT,
+ OSM_SM_STATE_SET_PKEY_DONE,
OSM_SM_STATE_MAX
-
} osm_sm_state_t;
/***********/
Index: include/opensm/osm_sm.h
===================================================================
--- include/opensm/osm_sm.h (revision 4651)
+++ include/opensm/osm_sm.h (working copy)
@@ -74,6 +74,7 @@
#include <opensm/osm_ucast_mgr.h>
#include <opensm/osm_link_mgr.h>
#include <opensm/osm_drop_mgr.h>
+#include <opensm/osm_pkey_mgr.h>
#include <opensm/osm_lin_fwd_rcv_ctrl.h>
#include <opensm/osm_mcast_fwd_rcv_ctrl.h>
#include <opensm/osm_sweep_fail_ctrl.h>
@@ -161,6 +162,7 @@ typedef struct _osm_sm
osm_link_mgr_t link_mgr;
osm_state_mgr_t state_mgr;
osm_drop_mgr_t drop_mgr;
+ osm_pkey_mgr_t pkey_mgr;
osm_lft_rcv_t lft_rcv;
osm_lft_rcv_ctrl_t lft_rcv_ctrl;
osm_mft_rcv_t mft_rcv;
Index: include/opensm/osm_pkey.h
===================================================================
--- include/opensm/osm_pkey.h (revision 4651)
+++ include/opensm/osm_pkey.h (working copy)
@@ -164,7 +164,7 @@ void osm_pkey_tbl_destroy(
* osm_pkey_get_num_blocks
*
* DESCRIPTION
-* Obtain the pointer to the IB PKey table block stored in the object
+* Obtain the number of blocks in IB PKey table
*
* SYNOPSIS
*/
Index: include/iba/ib_types.h
===================================================================
--- include/iba/ib_types.h (revision 4651)
+++ include/iba/ib_types.h (working copy)
@@ -368,7 +368,7 @@ BEGIN_C_DECLS
*
* SOURCE
*/
-#define IB_PKEY_BASE_MASK (CL_NTOH16(0x7FFF))
+#define IB_PKEY_BASE_MASK (CL_HTON16(0x7FFF))
/*********/
/****d* IBA Base: Constants/IB_PKEY_TYPE_MASK
@@ -383,6 +383,18 @@ BEGIN_C_DECLS
#define IB_PKEY_TYPE_MASK (CL_NTOH16(0x8000))
/*********/
+/****d* IBA Base: Constants/IB_DEFAULT_PARTIAL_PKEY
+* NAME
+* IB_DEFAULT_PARTIAL_PKEY
+*
+* DESCRIPTION
+* 0x7fff in network order
+*
+* SOURCE
+*/
+#define IB_DEFAULT_PARTIAL_PKEY (CL_HTON16(0x7fff))
+/**********/
+
/****d* IBA Base: Constants/IB_MCLASS_SUBN_LID
* NAME
* IB_MCLASS_SUBN_LID
Index: opensm/osm_state_mgr.c
===================================================================
--- opensm/osm_state_mgr.c (revision 4651)
+++ opensm/osm_state_mgr.c (working copy)
@@ -108,6 +108,7 @@ osm_state_mgr_init(
IN osm_mcast_mgr_t * const p_mcast_mgr,
IN osm_link_mgr_t * const p_link_mgr,
IN osm_drop_mgr_t * const p_drop_mgr,
+ IN osm_pkey_mgr_t * const p_pkey_mgr,
IN osm_req_t * const p_req,
IN osm_stats_t * const p_stats,
IN osm_sm_state_mgr_t * const p_sm_state_mgr,
@@ -127,6 +128,7 @@ osm_state_mgr_init(
CL_ASSERT( p_mcast_mgr );
CL_ASSERT( p_link_mgr );
CL_ASSERT( p_drop_mgr );
+ CL_ASSERT( p_pkey_mgr );
CL_ASSERT( p_req );
CL_ASSERT( p_stats );
CL_ASSERT( p_sm_state_mgr );
@@ -143,6 +145,7 @@ osm_state_mgr_init(
p_mgr->p_mcast_mgr = p_mcast_mgr;
p_mgr->p_link_mgr = p_link_mgr;
p_mgr->p_drop_mgr = p_drop_mgr;
+ p_mgr->p_pkey_mgr = p_pkey_mgr;
p_mgr->p_mad_ctrl = p_mad_ctrl;
p_mgr->p_req = p_req;
p_mgr->p_stats = p_stats;
@@ -2216,9 +2219,11 @@ osm_state_mgr_process(
}
}
}
+
/* Need to continue with lid assigning */
osm_drop_mgr_process( p_mgr->p_drop_mgr );
- p_mgr->state = OSM_SM_STATE_SET_SM_UCAST_LID;
+
+ p_mgr->state = OSM_SM_STATE_SET_PKEY;
/*
* If we are not MASTER already - this means that we are
@@ -2229,6 +2234,62 @@ osm_state_mgr_process(
osm_sm_state_mgr_process( p_mgr->p_sm_state_mgr,
OSM_SM_SIGNAL_DISCOVERY_COMPLETED );
+ /* signal = osm_lid_mgr_process_sm( p_mgr->p_lid_mgr ); */
+ /* the returned signal might be DONE or DONE_PENDING */
+ signal = osm_pkey_mgr_process( p_mgr->p_pkey_mgr );
+ break;
+
+ default:
+ __osm_state_mgr_signal_error( p_mgr, signal );
+ signal = OSM_SIGNAL_NONE;
+ break;
+ }
+ break;
+
+ case OSM_SM_STATE_SET_PKEY:
+ switch ( signal )
+ {
+ case OSM_SIGNAL_DONE:
+ p_mgr->state = OSM_SM_STATE_SET_PKEY_DONE;
+ break;
+
+ case OSM_SIGNAL_DONE_PENDING:
+ /*
+ * There are outstanding transactions, so we
+ * must wait for the wire to clear.
+ */
+ p_mgr->state = OSM_SM_STATE_SET_PKEY_WAIT;
+ signal = OSM_SIGNAL_NONE;
+ break;
+
+ default:
+ __osm_state_mgr_signal_error( p_mgr, signal );
+ signal = OSM_SIGNAL_NONE;
+ break;
+ }
+ break;
+
+ case OSM_SM_STATE_SET_PKEY_WAIT:
+ switch ( signal )
+ {
+ case OSM_SIGNAL_NO_PENDING_TRANSACTIONS:
+ p_mgr->state = OSM_SM_STATE_SET_PKEY_DONE;
+ break;
+
+ default:
+ __osm_state_mgr_signal_error( p_mgr, signal );
+ signal = OSM_SIGNAL_NONE;
+ break;
+ }
+ break;
+
+ case OSM_SM_STATE_SET_PKEY_DONE:
+ switch ( signal )
+ {
+ case OSM_SIGNAL_NO_PENDING_TRANSACTIONS:
+ case OSM_SIGNAL_DONE:
+
+ p_mgr->state = OSM_SM_STATE_SET_SM_UCAST_LID;
signal = osm_lid_mgr_process_sm( p_mgr->p_lid_mgr );
break;
@@ -2237,6 +2298,7 @@ osm_state_mgr_process(
signal = OSM_SIGNAL_NONE;
break;
}
+
break;
case OSM_SM_STATE_SET_SM_UCAST_LID:
Index: opensm/osm_helper.c
===================================================================
--- opensm/osm_helper.c (revision 4651)
+++ opensm/osm_helper.c (working copy)
@@ -1698,19 +1698,22 @@ const char* const __osm_sm_state_str[] =
"OSM_SM_STATE_SET_LINK_PORTS", /* 19 */
"OSM_SM_STATE_SET_LINK_PORTS_WAIT", /* 20 */
"OSM_SM_STATE_SET_LINK_PORTS_DONE", /* 21 */
- "OSM_SM_STATE_SET_ARMED", /* 19 */
- "OSM_SM_STATE_SET_ARMED_WAIT", /* 20 */
- "OSM_SM_STATE_SET_ARMED_DONE", /* 21 */
- "OSM_SM_STATE_SET_ACTIVE", /* 22 */
- "OSM_SM_STATE_SET_ACTIVE_WAIT", /* 23 */
- "OSM_SM_STATE_LOST_NEGOTIATION", /* 24 */
- "OSM_SM_STATE_STANDBY", /* 25 */
- "OSM_SM_STATE_SUBNET_UP", /* 26 */
- "OSM_SM_STATE_PROCESS_REQUEST", /* 27 */
- "OSM_SM_STATE_PROCESS_REQUEST_WAIT", /* 28 */
- "OSM_SM_STATE_PROCESS_REQUEST_DONE", /* 29 */
- "OSM_SM_STATE_MASTER_OR_HIGHER_SM_DETECTED", /* 30 */
- "UNKNOWN STATE!!" /* 31 */
+ "OSM_SM_STATE_SET_ARMED", /* 22 */
+ "OSM_SM_STATE_SET_ARMED_WAIT", /* 23 */
+ "OSM_SM_STATE_SET_ARMED_DONE", /* 24 */
+ "OSM_SM_STATE_SET_ACTIVE", /* 25 */
+ "OSM_SM_STATE_SET_ACTIVE_WAIT", /* 26 */
+ "OSM_SM_STATE_LOST_NEGOTIATION", /* 27 */
+ "OSM_SM_STATE_STANDBY", /* 28 */
+ "OSM_SM_STATE_SUBNET_UP", /* 29 */
+ "OSM_SM_STATE_PROCESS_REQUEST", /* 30 */
+ "OSM_SM_STATE_PROCESS_REQUEST_WAIT", /* 31 */
+ "OSM_SM_STATE_PROCESS_REQUEST_DONE", /* 32 */
+ "OSM_SM_STATE_MASTER_OR_HIGHER_SM_DETECTED",/* 33 */
+ "OSM_SM_STATE_SET_PKEY", /* 34 */
+ "OSM_SM_STATE_SET_PKEY_WAIT", /* 35 */
+ "OSM_SM_STATE_SET_PKEY_DONE", /* 36 */
+ "UNKNOWN STATE!!" /* 37 */
};
const char* const __osm_sm_signal_str[] =
Index: opensm/osm_sm.c
===================================================================
--- opensm/osm_sm.c (revision 4651)
+++ opensm/osm_sm.c (working copy)
@@ -67,6 +67,7 @@
#include <opensm/osm_node.h>
#include <opensm/osm_msgdef.h>
#include <opensm/osm_mcast_mgr.h>
+#include <opensm/osm_pkey_mgr.h>
#include <opensm/osm_mcm_info.h>
#include <complib/cl_thread.h>
#include <signal.h>
@@ -164,6 +165,7 @@ osm_sm_construct(
osm_state_mgr_construct( &p_sm->state_mgr );
osm_state_mgr_ctrl_construct( &p_sm->state_mgr_ctrl );
osm_drop_mgr_construct( &p_sm->drop_mgr );
+ osm_pkey_mgr_construct( &p_sm->pkey_mgr );
osm_lft_rcv_construct( &p_sm->lft_rcv );
osm_lft_rcv_ctrl_construct( &p_sm->lft_rcv_ctrl );
osm_mft_rcv_construct( &p_sm->mft_rcv );
@@ -253,6 +255,7 @@ osm_sm_destroy(
osm_ucast_mgr_destroy( &p_sm->ucast_mgr );
osm_link_mgr_destroy( &p_sm->link_mgr );
osm_drop_mgr_destroy( &p_sm->drop_mgr );
+ osm_pkey_mgr_destroy( &p_sm->pkey_mgr );
osm_lft_rcv_destroy( &p_sm->lft_rcv );
osm_mft_rcv_destroy( &p_sm->mft_rcv );
osm_slvl_rcv_destroy( &p_sm->slvl_rcv );
@@ -410,6 +413,7 @@ osm_sm_init(
&p_sm->mcast_mgr,
&p_sm->link_mgr,
&p_sm->drop_mgr,
+ &p_sm->pkey_mgr,
&p_sm->req,
p_stats,
&p_sm->sm_state_mgr,
@@ -432,6 +436,12 @@ osm_sm_init(
if( status != IB_SUCCESS )
goto Exit;
+ status = osm_pkey_mgr_init( &p_sm->pkey_mgr,
+ p_sm->p_subn,
+ p_sm->p_log, &p_sm->req, p_sm->p_lock );
+ if( status != IB_SUCCESS )
+ goto Exit;
+
status = osm_lft_rcv_init( &p_sm->lft_rcv, p_subn, p_log, p_lock );
if( status != IB_SUCCESS )
goto Exit;
Index: opensm/osm_indent
===================================================================
--- opensm/osm_indent (revision 4651)
+++ opensm/osm_indent (working copy)
@@ -63,8 +63,8 @@
# -i3 Substitute indent with 3 spaces
# -npcs No space after procedure calls
# -prs Space after parenthesis
-# -nsai No space after if keyword
-# -nsaw No space after while keyword
+# -nsai No space after if keyword - removed
+# -nsaw No space after while keyword - removed
# -sc Put * at left of comments in a block comment style
# -nsob Don't swallow unnecessary blank lines
# -ts3 Tab size is 3
@@ -81,7 +81,7 @@ for sourcefile in $*; do
perl -piW -e's/\x0D//' "$sourcefile"
echo Processing $sourcefile
indent -bad -bap -bbb -nbbo -bl -bli0 -bls -cbi0 -ci3 -cli0 -ncs \
- -hnl -i3 -npcs -prs -nsai -nsaf -nsaw -sc -nsob -ts3 -psl -bfda -nut $sourcefile
+ -hnl -i3 -npcs -prs -sc -nsob -ts3 -psl -bfda -nut $sourcefile
rm ${sourcefile}W
Index: opensm/Makefile.am
===================================================================
--- opensm/Makefile.am (revision 4651)
+++ opensm/Makefile.am (working copy)
@@ -32,7 +32,7 @@ opensm_SOURCES = main.c osm_console.c os
osm_mcm_port.c osm_mtree.c osm_multicast.c osm_node.c \
osm_node_desc_rcv.c osm_node_desc_rcv_ctrl.c \
osm_node_info_rcv.c osm_node_info_rcv_ctrl.c \
- osm_opensm.c osm_pkey.c osm_pkey_rcv.c \
+ osm_opensm.c osm_pkey.c osm_pkey_mgr.c osm_pkey_rcv.c \
osm_pkey_rcv_ctrl.c osm_port.c \
osm_port_info_rcv.c osm_port_info_rcv_ctrl.c \
osm_remote_sm.c osm_req.c osm_req_ctrl.c \
Index: opensm/osm_pkey_mgr.c
===================================================================
--- opensm/osm_pkey_mgr.c (revision 0)
+++ opensm/osm_pkey_mgr.c (revision 0)
@@ -0,0 +1,294 @@
+/*
+ * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses. You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * $Id: osm_pkey_mgr.c 4278 2005-12-15 13:50:55Z oferg $
+ */
+
+
+/*
+ * Abstract:
+ * Implementation of osm_pkey_mgr_t.
+ * This object represents the P_Key Manager object.
+ * This object is part of the opensm family of objects.
+ *
+ * Environment:
+ * Linux User Mode
+ *
+ * $Revision: 1.7 $
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <iba/ib_types.h>
+#include <complib/cl_qmap.h>
+#include <complib/cl_debug.h>
+#include <opensm/osm_node.h>
+#include <opensm/osm_pkey_mgr.h>
+
+/**********************************************************************
+ **********************************************************************/
+void
+osm_pkey_mgr_construct(
+ IN osm_pkey_mgr_t * const p_mgr )
+{
+ CL_ASSERT( p_mgr );
+ cl_memclr( p_mgr, sizeof( *p_mgr ) );
+}
+
+/**********************************************************************
+ **********************************************************************/
+void
+osm_pkey_mgr_destroy(
+ IN osm_pkey_mgr_t * const p_mgr )
+{
+ CL_ASSERT( p_mgr );
+
+ OSM_LOG_ENTER( p_mgr->p_log, osm_pkey_mgr_destroy );
+
+ OSM_LOG_EXIT( p_mgr->p_log );
+}
+
+/**********************************************************************
+ **********************************************************************/
+ib_api_status_t
+osm_pkey_mgr_init(
+ IN osm_pkey_mgr_t * const p_mgr,
+ IN osm_subn_t * const p_subn,
+ IN osm_log_t * const p_log,
+ IN osm_req_t * const p_req,
+ IN cl_plock_t * const p_lock )
+{
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER( p_log, osm_pkey_mgr_init );
+
+ osm_pkey_mgr_construct( p_mgr );
+
+ p_mgr->p_log = p_log;
+ p_mgr->p_subn = p_subn;
+ p_mgr->p_lock = p_lock;
+ p_mgr->p_req = p_req;
+
+ OSM_LOG_EXIT( p_mgr->p_log );
+ return ( status );
+}
+
+/**********************************************************************
+ **********************************************************************/
+boolean_t
+__osm_pkey_mgr_process_physical_port(
+ IN const osm_pkey_mgr_t * const p_mgr,
+ IN osm_node_t * p_node,
+ IN uint8_t port_num,
+ IN osm_physp_t * p_physp )
+{
+ boolean_t return_val = FALSE; /* TRUE if IB_DEFAULT_PKEY was inserted */
+ osm_madw_context_t context;
+ ib_pkey_table_t *block;
+ uint16_t block_index;
+ uint16_t num_of_blocks;
+ const osm_pkey_tbl_t *p_pkey_tbl;
+ uint32_t attr_mod;
+ uint32_t i;
+ ib_net16_t pkey;
+ ib_api_status_t status;
+ boolean_t block_with_empty_entry_found;
+
+ OSM_LOG_ENTER( p_mgr->p_log, __osm_pkey_mgr_process_physical_port );
+
+ /*
+ * Send a new entry for the pkey table for this node that includes
+ * IB_DEFAULT_PKEY when IB_DEFAULT_PARTIAL_PKEY or IB_DEFAULT_PKEY
+ * doesn't exist
+ */
+
+ if ( ( osm_physp_has_pkey( p_mgr->p_log,
+ IB_DEFAULT_PKEY,
+ p_physp ) == FALSE ) &&
+ ( osm_physp_has_pkey( p_mgr->p_log,
+ IB_DEFAULT_PARTIAL_PKEY, p_physp ) == FALSE ) )
+ {
+ context.pkey_context.node_guid = osm_node_get_node_guid( p_node );
+ context.pkey_context.port_guid = osm_physp_get_port_guid( p_physp );
+ context.pkey_context.set_method = TRUE;
+
+ p_pkey_tbl = osm_physp_get_pkey_tbl( p_physp );
+ num_of_blocks = osm_pkey_tbl_get_num_blocks( p_pkey_tbl );
+ block_with_empty_entry_found = FALSE;
+
+ for ( block_index = 0; block_index < num_of_blocks; block_index++ )
+ {
+ block = osm_pkey_tbl_block_get( p_pkey_tbl, block_index );
+ for ( i = 0; i < IB_NUM_PKEY_ELEMENTS_IN_BLOCK; i++ )
+ {
+ pkey = block->pkey_entry[i];
+ if ( ib_pkey_is_invalid( pkey ) )
+ {
+ block->pkey_entry[i] = IB_DEFAULT_PKEY;
+ block_with_empty_entry_found = TRUE;
+ break;
+ }
+ }
+ if ( block_with_empty_entry_found )
+ {
+ break;
+ }
+ }
+
+ if ( block_with_empty_entry_found == FALSE )
+ {
+ osm_log( p_mgr->p_log, OSM_LOG_ERROR,
+ "__osm_pkey_mgr_process_physical_port: ERR 0501: "
+ "No empty block was found to insert IB_DEFAULT_PKEY for node "
+ "0x%016" PRIx64 " and port %u.\n",
+ cl_ntoh64( osm_node_get_node_guid( p_node ) ), port_num );
+ }
+ else
+ {
+ /* Building the attribute modifier */
+ if ( osm_node_get_type( p_node ) == IB_NODE_TYPE_SWITCH )
+ {
+ /* Port num | Block Index */
+ attr_mod = port_num << 16 | block_index;
+ }
+ else
+ {
+ attr_mod = block_index;
+ }
+
+ status = osm_req_set( p_mgr->p_req,
+ osm_physp_get_dr_path_ptr( p_physp ),
+ ( uint8_t * ) block,
+ sizeof( *block ),
+ IB_MAD_ATTR_P_KEY_TABLE,
+ cl_hton32( attr_mod ),
+ CL_DISP_MSGID_NONE, &context );
+ return_val = TRUE; /*IB_DEFAULT_PKEY was inserted */
+
+ if ( osm_log_is_active( p_mgr->p_log, OSM_LOG_VERBOSE ) )
+ {
+ osm_log( p_mgr->p_log, OSM_LOG_VERBOSE,
+ "__osm_pkey_mgr_process_physical_port: "
+ "IB_DEFAULT_PKEY was inserted for node 0x%016" PRIx64
+ " and port %u.\n",
+ cl_ntoh64( osm_node_get_node_guid( p_node ) ),
+ port_num );
+ }
+ }
+ }
+ else
+ {
+ /* default key or partial default key already exist */
+ if ( osm_log_is_active( p_mgr->p_log, OSM_LOG_VERBOSE ) )
+ {
+ osm_log( p_mgr->p_log, OSM_LOG_VERBOSE,
+ "__osm_pkey_mgr_process_physical_port: "
+ "No need to insert IB_DEFAULT_PKEY for node 0x%016" PRIx64
+ " port %u.\n",
+ cl_ntoh64( osm_node_get_node_guid( p_node ) ), port_num );
+ }
+ }
+
+ OSM_LOG_EXIT( p_mgr->p_log );
+ return ( return_val );
+}
+
+/**********************************************************************
+ **********************************************************************/
+osm_signal_t
+osm_pkey_mgr_process(
+ IN const osm_pkey_mgr_t * const p_mgr )
+{
+ cl_qmap_t *p_node_guid_tbl;
+ osm_node_t *p_node;
+ osm_node_t *p_next_node;
+
+ uint32_t port_num;
+ osm_physp_t *p_physp;
+ osm_signal_t result = OSM_SIGNAL_DONE;
+
+ CL_ASSERT( p_mgr );
+
+ OSM_LOG_ENTER( p_mgr->p_log, osm_pkey_mgr_process );
+
+ p_node_guid_tbl = &p_mgr->p_subn->node_guid_tbl;
+
+ CL_PLOCK_EXCL_ACQUIRE( p_mgr->p_lock );
+
+ p_next_node = ( osm_node_t * ) cl_qmap_head( p_node_guid_tbl );
+ while ( p_next_node != ( osm_node_t * ) cl_qmap_end( p_node_guid_tbl ) )
+ {
+ p_node = p_next_node;
+ p_next_node = ( osm_node_t * ) cl_qmap_next( &p_next_node->map_item );
+
+ for ( port_num = 0; port_num < osm_node_get_num_physp( p_node );
+ port_num++ )
+ {
+ p_physp = osm_node_get_physp_ptr( p_node, port_num );
+ if ( osm_physp_is_valid( p_physp ) )
+ {
+
+ if ( __osm_pkey_mgr_process_physical_port
+ ( p_mgr, p_node, port_num, p_physp ) )
+ {
+ if ( osm_log_is_active( p_mgr->p_log, OSM_LOG_VERBOSE ) )
+ {
+ osm_log( p_mgr->p_log, OSM_LOG_VERBOSE,
+ "osm_pkey_mgr_process: "
+ "Adding IB_DEFAULT_PKEY for pkey table of node "
+ "0x%016" PRIx64 " port %u.\n",
+ cl_ntoh64( osm_node_get_node_guid( p_node ) ),
+ port_num );
+ }
+ result = OSM_SIGNAL_DONE_PENDING;
+ }
+ }
+ else
+ {
+ osm_log( p_mgr->p_log, OSM_LOG_ERROR,
+ "osm_pkey_mgr_process: ERR 0502: "
+ "Non-Valid physical port for node 0x%016" PRIx64
+ " port %u.\n",
+ cl_ntoh64( osm_node_get_node_guid( p_node ) ),
+ port_num );
+ }
+ }
+ }
+
+
+ CL_PLOCK_RELEASE( p_mgr->p_lock );
+ OSM_LOG_EXIT( p_mgr->p_log );
+ return ( result );
+}
More information about the general
mailing list