[openib-general] [PATCH] opensm: pkeys for SA PathRecord
Sasha Khapyorsky
sashak at voltaire.com
Sun Mar 26 15:02:28 PST 2006
Hello,
There is improvements to Pkey support in SA PathRecord - there is
functional P_Key values now instead of IB_DEFAULT_PKEY.
Sasha.
P_Key support in SA PathRecord (due to functional partition manager).
Also there are two new pkey functions osm_physp_share_this_pkey() and
osm_physp_find_common_pkey(), hope the names are descriptive.
Signed-off-by: Sasha Khapyorsky <sahak at voltaire.com>
---
osm/include/opensm/osm_pkey.h | 62 +++++++++++++++++++++++++
osm/opensm/osm_pkey.c | 95 ++++++++++++++++++++++-----------------
osm/opensm/osm_sa_path_record.c | 40 +++++++++++-----
3 files changed, 143 insertions(+), 54 deletions(-)
diff --git a/osm/include/opensm/osm_pkey.h b/osm/include/opensm/osm_pkey.h
index 816542f..3a1d898 100644
--- a/osm/include/opensm/osm_pkey.h
+++ b/osm/include/opensm/osm_pkey.h
@@ -244,6 +244,68 @@ int osm_pkey_tbl_set(
*
*********/
+/****f* OpenSM: osm_physp_share_this_pkey
+* NAME
+* osm_physp_share_this_pkey
+*
+* DESCRIPTION
+* Checks if the given physical ports share the specified pkey.
+*
+* SYNOPSIS
+*/
+boolean_t osm_physp_share_this_pkey(
+ IN const struct _osm_physp * const p_physp1,
+ IN const struct _osm_physp * const p_physp2,
+ IN const ib_net16_t pkey);
+/*
+* PARAMETERS
+*
+* p_physp1
+* [in] Pointer to an osm_physp_t object.
+*
+* p_physp2
+* [in] Pointer to an osm_physp_t object.
+*
+* pkey
+* [in] value if P_Key to check.
+*
+* RETURN VALUES
+* Returns TRUE if the 2 ports are matching.
+* FALSE otherwise.
+*
+* NOTES
+*
+*********/
+
+/****f* OpenSM: osm_physp_find_common_pkey
+* NAME
+* osm_physp_find_common_pkey
+*
+* DESCRIPTION
+* Returns first matching P_Key values for specified physical ports.
+*
+* SYNOPSIS
+*/
+ib_net16_t osm_physp_find_common_pkey(
+ IN const struct _osm_physp * const p_physp1,
+ IN const struct _osm_physp * const p_physp2 );
+/*
+* PARAMETERS
+*
+* p_physp1
+* [in] Pointer to an osm_physp_t object.
+*
+* p_physp2
+* [in] Pointer to an osm_physp_t object.
+*
+* RETURN VALUES
+* Returns value of first shared P_Key or INVALID P_Key (0x0) if not
+* found.
+*
+* NOTES
+*
+*********/
+
/****f* OpenSM: osm_physp_share_pkey
* NAME
* osm_physp_share_pkey
diff --git a/osm/opensm/osm_pkey.c b/osm/opensm/osm_pkey.c
index d9fba12..954e546 100644
--- a/osm/opensm/osm_pkey.c
+++ b/osm/opensm/osm_pkey.c
@@ -179,7 +179,7 @@ int osm_pkey_tbl_set(
/**********************************************************************
**********************************************************************/
-boolean_t __osm_match_pkey (
+static boolean_t __osm_match_pkey (
IN const ib_net16_t *pkey1,
IN const ib_net16_t *pkey2 ) {
@@ -198,41 +198,38 @@ boolean_t __osm_match_pkey (
/**********************************************************************
**********************************************************************/
boolean_t
-osm_physp_share_pkey(
- IN osm_log_t* p_log,
- IN const osm_physp_t* const p_physp_1,
- IN const osm_physp_t* const p_physp_2 ) {
+osm_physp_share_this_pkey(
+ IN const osm_physp_t* const p_physp1,
+ IN const osm_physp_t* const p_physp2,
+ IN const ib_net16_t pkey)
+{
+ ib_net16_t *pkey1, *pkey2;
+ pkey1 = cl_map_get( &(osm_physp_get_pkey_tbl(p_physp1))->keys,
+ ib_pkey_get_base(pkey));
+ pkey2 = cl_map_get( &(osm_physp_get_pkey_tbl(p_physp2))->keys,
+ ib_pkey_get_base(pkey));
+ return (pkey1 && pkey2 && __osm_match_pkey(pkey1, pkey2));
+}
+/**********************************************************************
+ **********************************************************************/
+ib_net16_t
+osm_physp_find_common_pkey(
+ IN const osm_physp_t* const p_physp1,
+ IN const osm_physp_t* const p_physp2 )
+{
ib_net16_t *pkey1, *pkey2;
uint64_t pkey1_base, pkey2_base;
const osm_pkey_tbl_t *pkey_tbl1, *pkey_tbl2;
cl_map_iterator_t map_iter1, map_iter2;
- OSM_LOG_ENTER( p_log, osm_physp_share_pkey );
+ pkey_tbl1 = osm_physp_get_pkey_tbl(p_physp1);
+ pkey_tbl2 = osm_physp_get_pkey_tbl(p_physp2);
- /* If two ports are same, no need to check */
- if (p_physp_1 == p_physp_2)
- return (TRUE);
+ map_iter1 = cl_map_head(&pkey_tbl1->keys);
+ map_iter2 = cl_map_head(&pkey_tbl2->keys);
- 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))
- {
- OSM_LOG_EXIT( p_log );
- return(TRUE);
- }
-
/* we rely on the fact the map are sorted by pkey */
- map_iter1 = cl_map_head( &pkey_tbl1->keys );
- map_iter2 = cl_map_head( &pkey_tbl2->keys );
-
while ( (map_iter1 != cl_map_end( &pkey_tbl1->keys )) &&
(map_iter2 != cl_map_end( &pkey_tbl2->keys )))
{
@@ -240,15 +237,8 @@ osm_physp_share_pkey(
pkey2 = (ib_net16_t *)cl_map_obj( map_iter2 );
if (__osm_match_pkey(pkey1, pkey2))
- {
- osm_log( p_log, OSM_LOG_DEBUG,
- "osm_physp_share_pkey: "
- "Matched pkeys: 0x%04x 0x%04x\n",
- cl_ntoh16(*pkey1), cl_ntoh16(*pkey2));
- OSM_LOG_EXIT( p_log );
- return(TRUE);
- }
-
+ return *pkey1;
+
/* advance the lower value if they are not equal */
pkey1_base = cl_map_key( map_iter1 );
pkey2_base = cl_map_key( map_iter2 );
@@ -263,12 +253,35 @@ osm_physp_share_pkey(
map_iter1 = cl_map_next( map_iter1 );
}
- osm_log( p_log, OSM_LOG_DEBUG,
- "osm_physp_share_pkey: "
- "Ports do not share a pkey\n");
+ return 0;
+}
- OSM_LOG_EXIT( p_log );
- return(FALSE);
+/**********************************************************************
+ **********************************************************************/
+boolean_t
+osm_physp_share_pkey(
+ IN osm_log_t* p_log,
+ IN const osm_physp_t* const p_physp_1,
+ IN const osm_physp_t* const p_physp_2 )
+{
+ 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));
}
/**********************************************************************
diff --git a/osm/opensm/osm_sa_path_record.c b/osm/opensm/osm_sa_path_record.c
index b74f580..0c6bf81 100644
--- a/osm/opensm/osm_sa_path_record.c
+++ b/osm/opensm/osm_sa_path_record.c
@@ -173,6 +173,7 @@ __osm_pr_rcv_get_path_parms(
const cl_qmap_t* p_sw_tbl;
ib_api_status_t status = IB_SUCCESS;
+ ib_net16_t pkey;
uint8_t mtu;
uint8_t rate;
uint8_t pkt_life;
@@ -554,13 +555,38 @@ __osm_pr_rcv_get_path_parms(
}
}
+ if (status != IB_SUCCESS)
+ goto Exit;
+
p_parms->mtu = mtu;
p_parms->rate = rate;
- p_parms->pkey = IB_DEFAULT_PKEY;
/* the pkt_life */
p_parms->pkt_life = pkt_life;
p_parms->sl = OSM_DEFAULT_SL;
+ if (comp_mask&IB_PR_COMPMASK_RAWTRAFFIC &&
+ cl_ntoh32(p_pr->hop_flow_raw)&(1<<31))
+ pkey = 0;
+ else if(comp_mask&IB_PR_COMPMASK_PKEY) {
+ pkey = p_pr->pkey;
+ if (!osm_physp_share_this_pkey(p_physp, p_dest_physp, pkey)) {
+ osm_log( p_rcv->p_log, OSM_LOG_ERROR,
+ "__osm_pr_rcv_get_path_parms: "
+ "Ports do not share specified P_Key\n");
+ status = IB_NOT_FOUND;
+ }
+ }
+ else {
+ pkey = osm_physp_find_common_pkey(p_physp, p_dest_physp);
+ if (!pkey) {
+ osm_log( p_rcv->p_log, OSM_LOG_ERROR,
+ "__osm_pr_rcv_get_path_parms: "
+ "Ports do not have any shared P_Keys\n");
+ status = IB_NOT_FOUND;
+ }
+ }
+ p_parms->pkey = pkey;
+
Exit:
OSM_LOG_EXIT( p_rcv->p_log );
return( status );
@@ -975,18 +1001,6 @@ __osm_pr_rcv_get_end_points(
into the endpoints.
*/
- if( comp_mask & IB_PR_COMPMASK_PKEY )
- {
- if( p_pr->pkey != IB_DEFAULT_PKEY )
- {
- if ( p_sa_mad->method == IB_MAD_METHOD_GET )
- sa_status = IB_SA_MAD_STATUS_NO_RECORDS;
- *pp_src_port = 0;
- *pp_dest_port = 0;
- goto Exit;
- }
- }
-
if( comp_mask & IB_PR_COMPMASK_SL )
{
if( p_pr->sl != OSM_DEFAULT_SL )
More information about the general
mailing list