ibcm_path.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
* ibt_get_paths() implement the Path Informations related functionality.
*/
/* Externs. */
extern char cmlog[];
/* ibcm_saa_service_rec() fills in ServiceID and DGID. */
typedef struct ibcm_dest_s {
} ibcm_dest_t;
/* Holds Destination information needed to fill in ibt_path_info_t. */
typedef struct ibcm_dinfo_s {
} ibcm_dinfo_t;
typedef struct ibcm_path_tqargs_s {
void *arg;
/* Prototype Declarations. */
uint8_t *, ibt_path_info_t *);
ibtl_cm_port_list_t *, ibcm_dinfo_t *);
uint8_t *, ibt_path_info_t *);
uint8_t *, ibt_path_info_t *);
static void ibcm_process_async_get_paths(void *tq_arg);
/*
* Function:
* ibt_aget_paths
* Input:
* ibt_hdl The handle returned to the client by the IBTF from an
* ibt_attach() call. Can be used by the IBTF Policy module
* and CM in the determination of the "best" path to the
* specified destination for this class of driver.
* flags Path flags.
* attrp Points to an ibt_path_attr_t struct that contains
* required and optional attributes.
* func A pointer to an ibt_path_handler_t function to call
* when ibt_aget_paths() completes.
* arg The argument to 'func'.
* Returns:
* IBT_SUCCESS on early validation of attributes else appropriate error.
* Description:
* Finds the best path to a specified destination or service
* asynchronously (as determined by the IBTL) that satisfies the
* requirements specified in an ibt_path_attr_t struct.
* ibt_aget_paths() is a Non-Blocking version of ibt_get_paths().
*/
void *arg)
{
"NULL - ERROR ");
return (IBT_INVALID_PARAM);
}
/* Memory for path info will be allocated in ibcm_process_get_paths() */
}
/*
* Function:
* ibt_get_paths
* Input:
* ibt_hdl The handle returned to the client by the IBTF from an
* ibt_attach() call. Can be used by the IBTF Policy module
* and CM in the determination of the "best" path to the
* specified destination for this class of driver.
* flags Path flags.
* attrp Points to an ibt_path_attr_t struct that contains
* required and optional attributes.
* max_paths The size of the "paths" array argument. Also, this
* is the limit on the number of paths returned.
* max_paths indicates the number of requested paths to
* the specified destination(s).
* Output:
* paths An array of ibt_path_info_t structs filled in by
* ibt_get_paths() as output parameters. Upon return,
* array elements with non-NULL HCA GUIDs are valid.
* num_paths_p If non-NULL, return the actual number of paths found.
* Returns:
* IBT_SUCCESS on Success else appropriate error.
* Description:
* Finds the best path to a specified destination (as determined by the
* IBTL) that satisfies the requirements specified in an ibt_path_attr_t
* struct.
*
* This routine can not be called from interrupt context.
*/
{
"NULL - ERROR ");
return (IBT_INVALID_PARAM);
}
if (num_paths_p != NULL)
*num_paths_p = 0;
}
static ibt_status_t
{
int len;
if (retval != IBT_SUCCESS)
return (retval);
sizeof (ibcm_path_tqargs_t);
"Unable to allocate memory for local usage.");
return (IBT_INSUFF_KERNEL_RESOURCE);
}
if (attrp->pa_num_dgids) {
sizeof (ibcm_path_tqargs_t));
} else {
}
/* Ignore IBT_PATH_AVAIL flag, if only one path is requested. */
flags &= ~IBT_PATH_AVAIL;
"Ignoring IBT_PATH_AVAIL flag, as only ONE path "
"information is requested.");
}
path_tq, TQ_NOSLEEP) == 0) {
"Failed to dispatch the TaskQ");
return (IBT_INSUFF_KERNEL_RESOURCE);
} else
return (IBT_SUCCESS);
} else { /* Blocking */
return (ibcm_process_get_paths(path_tq));
}
}
static void
{
(void) ibcm_process_get_paths(tq_arg);
}
static ibt_status_t
{
uint_t i;
"HCA (%llX, %d),\n\tSGID(%llX:%llX), SName=\"%s\",\n\tSID= %llX, "
"Maxpath= %d, Flags= 0x%X, #Dgid= %d, SDFlag= 0x%llX",
/*
* Validate Path Flags.
* IBT_PATH_AVAIL & IBT_PATH_PERF are mutually exclusive.
*/
"Invalid Flags: 0x%X,\n\t AVAIL and PERF flags cannot "
"specified together.", flags);
return (IBT_INVALID_PARAM);
}
/* Validate number of records requested. */
(max_paths > IBT_MAX_SPECIAL_PATHS)) {
"Max records that can be requested is <%d> \n"
"when IBT_PATH_AVAIL or IBT_PATH_PERF flag is specified.",
return (IBT_INVALID_PARAM);
}
/* Only 2 destinations can be specified w/ APM flag. */
return (IBT_INVALID_PARAM);
}
/*
* Max_paths of "0" is invalid.
* w/ IBT_PATH_MULTI_SVC_DEST flag, max_paths must be greater than "1".
*/
if ((max_paths == 0) ||
"Invalid number of records requested:\n flags 0x%X, "
return (IBT_INVALID_PARAM);
}
/*
* must be specified and DGIDs SHOULD NOT be specified.
*/
"Invalid Flags: 0x%X, IBT_PATH_MULTI_SVC_DEST flag set "
"but Service Name \n or Service ID NOT specified or DGIDs "
"are specified.", flags);
return (IBT_INVALID_PARAM);
}
/*
* User need to specify the destination information, which can be
* provided as one or more of the following.
* o ServiceName
* o ServiceID
*/
/* Destination information not provided, bail out. */
"Client's MUST supply DestInfo.");
return (IBT_INVALID_PARAM);
}
/* If DGIDs are provided, validate them. */
if (attrp->pa_num_dgids > 0) {
"pa_dgids NULL, but pa_num_dgids : %d",
return (IBT_INVALID_PARAM);
}
/* Validate DGIDs */
for (i = 0; i < attrp->pa_num_dgids; i++) {
/* APM request for MultiCast destination is invalid. */
if (flags & IBT_PATH_APM) {
"ibcm_validate_path_attributes: "
"APM for MGIDs not supported.");
return (IBT_INVALID_PARAM);
}
} else if ((gid.gid_prefix == 0) ||
"ibcm_validate_path_attributes: ERROR: "
"Invalid DGIDs specified");
return (IBT_INVALID_PARAM);
}
}
}
/* Check for valid Service Name length. */
"ServiceName too long");
return (IBT_INVALID_PARAM);
}
/* If P_Key is specified, check for invalid p_key's */
if (flags & IBT_PATH_PKEY) {
/* Limited P_Key is NOT supported as of now!. */
return (IBT_INVALID_PARAM);
}
}
return (IBT_SUCCESS);
}
static ibt_status_t
ibcm_process_get_paths(void *tq_arg)
{
int len;
uint_t i, j;
/*
* Prepare the Destination list based on the input DGIDs and
* other attributes.
*
* APM is requested and pa_dgids are specified. If multiple DGIDs are
* specified, check out whether they are companion to each other or if
* only one DGID is specified, then get the companion port GID for that.
*/
"DGIDs specified w/ APM Flag");
else
&dnum);
if ((retval != IBT_SUCCESS) &&
(retval != IBT_GIDS_NOT_FOUND)) {
" Invalid DGIDs specified w/ APM Flag");
goto path_error2;
}
"Found %d Comp DGID", dnum);
}
if (dnum) {
len = 1;
} else {
}
} else {
"IBT_PATH_MULTI_SVC_DEST flags set");
len = 1;
} else {
len = 0;
}
num_dest = 0;
}
/* Allocate memory and accumulate all destination information */
for (i = 0, j = 0; i < num_dest; i++) {
else
}
/* IBTF allocates memory for path_info in case of Async Get Paths */
KM_SLEEP);
/* Checkout whether user has specified SGID. */
/* For the specified SGID, get HCA information. */
if (retval != IBT_SUCCESS) {
"Get HCA Port Failed: %d", retval);
goto path_error;
}
"Mis-match input HCA PortNum v/s SGID");
goto path_error;
}
/*
* If a specific MTU is desired, then first check out whether
* this source port is capable of this MTU.
*/
" Required MTU not available on this Port. "
"Requested IBT_GT 0x%x but avail 0x%x",
goto path_error;
" Required MTU not available on this Port "
"Requested IBT_EQU to 0x%x but avail 0x%x",
goto path_error;
}
}
if (retval != IBT_SUCCESS) {
" ibtl_cm_get_active_plist returned error "
" %d", retval);
goto path_error;
}
} else {
KM_SLEEP);
}
} else {
/* Source GID is not specified, but so let's find them. */
else
/*
* Get list of active HCA<->Port list, that matches input
* specified attr.
*/
&slistp);
if (retval != IBT_SUCCESS) {
"HCA capable of requested source attributes NOT "
"available.");
goto path_error;
}
}
"NO HCA found");
goto path_error;
}
/* Get SA Access Handle. */
if (i == 0) {
/* Validate whether this HCA supports APM */
" HCA (%llX): APM NOT SUPPORTED ",
slistp[i].p_hca_guid);
goto path_error1;
}
}
if (saa_handle == NULL) {
"SAA HDL NULL, HCA (%llX:%d) NOT ACTIVE",
goto path_error1;
}
}
/*
* If Service Name or Service ID are specified, first retrieve
* Service Records.
*/
/* Get Service Records. */
"%d, Failed to get Service Record for \n\t"
goto path_error1;
}
}
/* Get Path Records. */
if (slistp)
if (dinfo)
num_path = 0;
if (retval == IBT_INSUFF_DATA) {
/*
* We allocated earlier memory based on "max_paths",
* but we got lesser path-records, so re-adjust that
* buffer so that caller can free the correct memory.
*/
num_path * sizeof (ibt_path_info_t));
sizeof (ibt_path_info_t) * max_paths);
} else if (retval != IBT_SUCCESS) {
sizeof (ibt_path_info_t) * max_paths);
tmp_path_p = NULL;
} else {
}
}
sizeof (ibcm_path_tqargs_t);
return (retval);
}
/*
* Perform SA Access to retrieve Path Records.
*/
static ibt_status_t
{
int unicast_dgid_present = 0;
uint8_t i;
return (IBT_INVALID_PARAM);
}
/*
* Of the total needed "X" number of paths to "Y" number of destination
* we need to get X/Y plus X%Y extra paths to each destination,
* We do this so that we can choose the required number of path records
* for the specific destination.
*/
/*
* Find out whether we need to get PathRecord for a MGID as DGID or
* qualifies for a LoopBack.
*/
if (extra) {
extra--;
} else
"- MGID(%016llX%016llX)", num_path_plus,
/* Yes, it's Single PathRec query for MGID as DGID. */
if ((retval != IBT_SUCCESS) &&
(retval != IBT_INSUFF_DATA)) {
"Failed to get PathRec for MGID %d",
retval);
continue;
}
} else {
/*
* Check out whether we are looking for loop-back path
* info. In this case, we should not contact SA Access
* for Path Records, but instead we need to "synthesize"
* a loop back path record.
*/
dgid.gid_prefix) &&
/* Yes, it's loop back case. */
if (retval != IBT_SUCCESS)
break;
/*
* We update only one record for
* loop-back case.
*/
rec_found++;
break;
}
}
}
break;
}
}
}
if ((unicast_dgid_present != 0) && (num_path_plus > 0)) {
/*
* Use SinglePathRec if we are dealing w/ MultiSM or
* request is for one SGID to one DGID.
*/
} else {
/* MultiPathRec will be used for other queries. */
}
"Failed to get PathRec: Status %d", retval);
} else {
}
}
if (rec_found == 0) {
if (retval == IBT_SUCCESS)
return (retval);
}
{
int retry;
int sa_retval;
if (sa_retval != IBMF_TRANS_TIMEOUT)
break;
"ibmf_sa_access() - Timed Out (%d)", sa_retval);
}
(sa_retval == IBMF_REQ_INVALID)) {
"ibmf_sa_access() returned (%d)", sa_retval);
return (IBT_SUCCESS);
} else {
"ibmf_sa_access(): Failed (%d)", sa_retval);
return (ibcm_ibmf_analyze_error(sa_retval));
}
}
static ibt_status_t
{
int d, s;
if (retval != IBT_SUCCESS)
return (retval);
/* Update some leftovers */
}
break;
}
}
}
}
/* Set Alternate Path to invalid state. */
return (retval);
}
static ibt_status_t
{
void *results_p;
int i, j, k;
/* Is Flow Label Specified. */
}
/* Is HopLimit Specified. */
}
/* Is P_Key Specified. */
}
/* Is TClass Specified. */
}
/* Is SL specified. */
}
/* If IBT_PATH_PERF is set, then mark all selectors to BEST. */
} else {
}
}
}
}
/*
* Honor individual selection of these attributes,
* even if IBT_PATH_PERF is set.
*/
/* Check out whether Packet Life Time is specified. */
}
/* Is SRATE specified. */
}
/* Is MTU specified. */
}
/* We always get REVERSIBLE paths. */
if (idx != 0xFF) {
/* MGID */
}
/* SGID */
continue;
/*
* If we had performed Service Look-up, then we
* got P_Key from ServiceRecord, so get path
* records that satisfy this particular P_Key.
*/
}
}
"Get %d Path(s) between\n\tSGID(%llX:%llX) "
": SGID_pfx=%llX, DGID_pfx=%llX doesn't "
continue;
": Why LoopBack request came here!!!! "
"GID(%llX:%llX)",
continue;
}
/* Contact SA Access to retrieve Path Records. */
sizeof (sa_path_record_t);
if (retval != IBT_SUCCESS) {
*num_path = 0;
return (retval);
}
if (idx != 0xFF)
break;
else
continue;
}
/* Update the PathInfo from the response. */
if ((p_fnd != 0) &&
"ibcm_get_single_pathrec: "
"Fill Alternate Path");
if (retval != IBT_SUCCESS)
continue;
/* Update some leftovers */
} else {
"ibcm_get_single_pathrec: "
"Fill Primary Path");
if (retval != IBT_SUCCESS)
continue;
}
break;
}
/* Deallocate the memory for results_p. */
if (idx != 0xFF)
break; /* We r here for MGID */
}
if (p_fnd == 0)
else
break;
else
found = 0;
}
}
return (retval);
}
static ibt_status_t
{
void *results_p;
int i, k;
dgid_cnt++;
}
return (IBT_INVALID_PARAM);
}
/*
* Calculate the size for multi-path records template, which includes
* constant portion of the multipath record, plus variable size for
* SGID (sgid_cnt) and DGID (dgid_cnt).
*/
sizeof (sa_multipath_record_t);
sizeof (sa_multipath_record_t));
/* Get the starting pointer where GIDs are stored. */
/* SGID */
gid_ptr++;
}
/* DGIDs */
gid_ptr++;
}
}
/* Is Flow Label Specified. */
}
/* Is HopLimit Specified. */
}
/* Is TClass Specified. */
}
/* Is SL specified. */
}
} else {
}
}
}
}
/*
* Honor individual selection of these attributes,
* even if IBT_PATH_PERF is set.
*/
/* Check out whether Packet Life Time is specified. */
}
/* Is SRATE specified. */
}
/* Is MTU specified. */
}
/* Is P_Key Specified or obtained during Service Look-up. */
}
/* We always get REVERSIBLE paths. */
}
/* we will not specify how many records we want. */
/* Contact SA Access to retrieve Path Records. */
&results_p);
if (retval != IBT_SUCCESS) {
*num_path = 0; /* Update the return count. */
return (retval);
}
num_rec);
found = 0;
/* Update the PathInfo with the response Path Records */
for (i = 0; i < num_rec; i++) {
"P[%d]: SG %llX, DG %llX", i,
}
int s_spec;
if (sgid_cnt > 1)
else
"REQ: P_SG: %llX, A_SG: %llX",
if (dgid_cnt > 1)
else
"REQ: P_DG: %llX, A_DG: %llX",
/*
* he gets his primary-path on those node points.
*/
" PF %d, AF %d,\n\t\t P[%d] = SG: %llX, "
if ((!p_found) &&
"ibcm_get_multi_pathrec: "
"Pri DGID Match.. ");
p_found = 1;
"ibcm_get_multi_pathrec: "
"Primary Path Found");
if (a_found)
break;
else
continue;
}
"ibcm_get_multi_pathrec:"
"Pri SGID Don't Match.. ");
}
if ((!a_found) &&
"ibcm_get_multi_pathrec:"
"Alt DGID Match.. ");
a_found = 1;
"ibcm_get_multi_pathrec:"
"Alternate Path Found ");
if (p_found)
break;
else
continue;
}
"ibcm_get_multi_pathrec:"
"Alt SGID Don't Match.. ");
}
}
" Path to desired node points NOT "
"Available.");
goto get_multi_pathrec_end;
}
}
/* Fill in Primary Path */
if (retval != IBT_SUCCESS)
goto get_multi_pathrec_end;
/* Fill in Alternate Path */
/* a_resp will point to AltPathInfo buffer. */
if (retval != IBT_SUCCESS)
goto get_multi_pathrec_end;
/* Update some leftovers */
} else {
" Alternate Path NOT Available.");
}
found++;
} else { /* If NOT APM */
/* mark flag whether to validate PKey or not. */
check_pkey = B_TRUE;
" PKeyCheck - %s, PKey=0x%X, DGID(%llX)",
if (check_pkey == B_TRUE) {
/* For all DGIDs */
continue;
gid_guid ==
break;
}
}
if (match_found == B_FALSE)
continue;
}
/* Fill in Primary Path */
if (retval != IBT_SUCCESS)
continue;
break;
}
}
}
if (retval == IBT_SUCCESS) {
if (found == 0)
}
return (retval);
}
/*
* Here we "synthesize" loop back path record information.
*
* Currently the synthesize values are assumed as follows:
* SLID, DLID = Base LID from Query HCA Port.
* FlowLabel, HopLimit, TClass = 0, as GRH is False.
* RawTraffic = 0.
* P_Key = first valid one in P_Key table as obtained from Query HCA Port.
* SL = as from Query HCA Port.
* MTU = from Query HCA Port.
* Rate = 2 (arbitrary).
* PacketLifeTime = 0 (4.096 usec).
*/
static ibt_status_t
{
/* Synthesize path record with appropriate loop back information. */
else
if (pkey) {
/* Convert P_Key to P_Key_Index */
if (retval != IBT_SUCCESS) {
/* Failed to get pkey_index from pkey */
"Pkey2Index (P_Key = %X) conversion failed: %d",
return (retval);
}
} else {
sl->p_port_num);
"1st Full Member P_Key_ix = %d",
}
/* SLID and DLID will be equal to BLID. */
sizeof (ibt_srv_data_t));
/* Set Alternate Path to invalid state. */
return (IBT_SUCCESS);
}
/*
* Update the output path records buffer with the values as obtained from
* SA Access retrieve call results for Path Records.
*/
static ibt_status_t
{
int i;
/*
* If path's packet life time is more than 4 seconds, IBCM cannot
* handle this path connection, so discard this path record.
*/
"LifeTime too high %d, Maximum allowed %d IB Time (4 sec)",
return (IBT_PATH_PKT_LT_TOO_HIGH);
}
return (ibt_get_module_failure(IBT_FAILURE_IBCM, 0));
}
/* Source Node Information. */
/* Convert P_Key to P_Key_Index */
if (retval != IBT_SUCCESS) {
/* Failed to get pkey_index from pkey */
"Pkey2Index conversion failed: %d", retval);
return (retval);
}
/* Convert P_Key to P_Key_Index */
&cep_p->cep_pkey_ix);
if (retval != IBT_SUCCESS) {
/* Failed to get pkey_index from pkey */
"ibcm_update_cep_info: Pkey2Index "
"conversion failed: %d", retval);
return (retval);
}
sl[i].p_port_num;
break;
}
}
} else {
"must be non-null");
return (IBT_INVALID_PARAM);
}
case IBT_SRATE_1X:
case IBT_SRATE_4X:
case IBT_SRATE_12X:
break;
default:
return (IBT_STATIC_RATE_INVALID);
}
/*
* If both Source and Destination GID prefix are same, then GRH is not
* valid, so make it as false, else set this field as true.
*/
else
/* SGID and SGID Index. */
/* Address Vector Definition. */
/* DGID */
/* CEP Timeout is NOT filled in by PATH routines. */
cep_p->cep_timeout = 0;
"SGID=%llX:%llX DGID=%llX:%llX",
return (IBT_SUCCESS);
}
static void
{
}
static ib_gid_t
{
int k, l;
for (l = 0; l < ngid; l++) {
break;
}
break;
gidp++;
}
break;
sl++;
}
return (a_gid);
}
/*
* Perform SA Access to retrieve Service Records.
* On Success, returns ServiceID and ServiceGID info in '*dinfo'.
*/
static ibt_status_t
{
void *results_p;
uint64_t component_mask = 0;
/* Service Name */
}
/* Service ID */
}
/* Is P_Key Specified. */
}
/* Is ServiceData Specified. */
/* Handle endianess for service data. */
/*
* Lets not interpret each and every ServiceData flags,
* just pass it on to SAA. Shift the flag, to suit
* SA_SR_COMPMASK_ALL_DATA definition.
*/
}
/* If a single DGID is specified, provide it */
}
"Perform SA Access: Mask: 0x%X", component_mask);
/*
* Call in SA Access retrieve routine to get Service Records.
*
* SA Access framework allocated memory for the "results_p".
* Make sure to deallocate once we are done with the results_p.
* The size of the buffer allocated will be as returned in
* "length" field.
*/
if (retval != IBT_SUCCESS)
return (retval);
return (IBT_SERVICE_RECORDS_NOT_FOUND);
}
num_req);
rec_found = 0;
/* Update the return values. */
for (i = 0; i < num_req; i++, svcrec_resp++) {
/* Limited P_Key is NOT supported as of now!. */
"SvcPkey 0x%X limited, reject the record.",
continue;
}
rec_found++;
}
break;
}
break;
}
"find ServiceRec for all DGIDs: (%d/%d)", rec_found,
}
"find ServiceRec that can satisfy APM");
for (i = 0; i < num_req; i++, svcrec_resp++) {
/* Limited P_Key is NOT supported as of now!. */
"SvcPkey 0x%X limited, reject the record.",
continue;
}
"Let DGID(%llX:%llX) be Primary",
/* Let's avoid LoopBack Nodes. */
"Lets Avoid Local Node, "
"search for remote node.");
}
if (local_node_check_done == B_TRUE) {
if ((i + 1) < num_req) {
p_gid.gid_prefix = 0;
continue;
} else if (last_p_gid.gid_prefix != 0) {
p_gid = last_p_gid;
break;
}
}
"Finally let Primary DGID = %llX:%llX",
if (ret == IBT_SUCCESS) {
"ibcm_saa_service_rec: Found %d "
"CompGID for %llX:%llX", n_gids,
/* validate sn_pfx */
} else {
for (k = 0; k < num_req; k++) {
"ibcm_saa_service_rec: "
"SvcGID[%d] = %llX:%llX", k,
for (j = 0; j < n_gids; j++) {
break;
}
}
break;
stmp++;
}
/* Rec not found for Alt. */
for (j = 0; j < n_gids; j++) {
if (gidp[j].gid_prefix
== p_gid.gid_prefix) {
break;
}
}
}
}
break;
} else if (ret == IBT_GIDS_NOT_FOUND) {
last_p_gid = p_gid;
"ibcm_saa_service_rec: Didn't find "
"CompGID for %llX:%llX, ret=%d",
ret);
} else {
"ibcm_saa_service_rec: Call to "
"ibt_get_companion_port_gids(%llX:"
"%llX) Failed = %d",
ret);
}
}
"Pri DGID(%llX:%llX), Alt DGID(%llX:%llX)",
for (i = 0, j = 0; i < num_req; i++, svcrec_resp++) {
/* Limited P_Key is NOT supported as of now!. */
"SvcPkey 0x%X limited, reject the record.",
continue;
}
if ((pri_fill_done == B_FALSE) &&
if ((a_pkey != 0) &&
"ibcm_saa_service_rec: "
"Pri(0x%X) & Alt (0x%X) "
"PKey must match.",
p_pkey = 0;
continue;
}
rec_found++;
} else if ((alt_fill_done == B_FALSE) &&
if ((p_pkey != 0) &&
"ibcm_saa_service_rec: "
"Pri(0x%X) & Alt (0x%X) "
"PKey must match.",
a_pkey = 0;
continue;
}
rec_found++;
}
if (rec_found == 2)
break;
}
rec_found++;
"Let Alt Pkey=%X, DGID=%llX:%llX", p_pkey,
}
if (rec_found == 1)
for (i = 0; i < num_req; i++, svcrec_resp++) {
/* Limited P_Key is NOT supported as of now!. */
"SvcPkey 0x%X limited, reject the record.",
continue;
}
rec_found++;
break;
}
} else {
for (i = 0; i < num_req; i++) {
/* Limited P_Key is NOT supported as of now!. */
"SvcPkey 0x%X limited, reject the record.",
svcrec_resp++;
continue;
}
rec_found = 1;
/* Avoid having loopback node */
break;
} else {
"avoid LoopBack node.");
svcrec_resp++;
}
}
}
/* Deallocate the memory for results_p. */
/*
* Check out whether all Service Path we looking for are on the same
* P_key. If yes, then set the global p_key field with that value,
* to make it easy during SA Path Query.
*/
} else {
"pk= 0x%X, pk[%d]= 0x%X", pk, i,
break;
} else {
}
}
}
}
if (rec_found == 0) {
"ServiceRec NOT Found");
}
return (retval);
}
static boolean_t
{
return (B_TRUE);
} else {
return (B_FALSE);
}
}
/*
* ibcm_get_comp_pgids() routine gets the companion port for 'gid'.
*
* On success:
* If 'n_gid' is specified, then verify whether 'n_gid' is indeed a
* companion portgid of 'gid'. If matches return success or else error.
*
* If 'n_gid' is NOT specified, then return back SUCCESS along with
* obtained Companion PortGids 'gid_p', where 'num' indicated number
* of companion portgids returned in 'gid_p'.
*/
static ibt_status_t
{
int i;
"ibt_get_companion_port_gids(%llX:%llX) Failed: %d",
"(%llX:%llX) is NOT a Companion \n\t to current channel's "
/*
* We found some Comp GIDs and n_gid is specified. Validate
* whether the 'n_gid' specified is indeed the companion port
* GID of 'gid'.
*/
for (i = 0; i < *num; i++) {
"Matching Found!. Done.");
return (IBT_SUCCESS);
}
}
"\t and (%llX:%llX) are NOT Companion Port GIDS",
} else {
ret = IBT_SUCCESS;
}
return (ret);
}
/*
* Function:
* ibt_get_alt_path
* Input:
* rc_chan An RC channel handle returned in a previous call
* ibt_alloc_rc_channel(9F), specifies the channel to open.
* flags Path flags.
* attrp A pointer to an ibt_alt_path_attr_t(9S) structure that
* specifies required attributes of the selected path(s).
* Output:
* api_p An ibt_alt_path_info_t(9S) struct filled in as output
* parameters.
* Returns:
* IBT_SUCCESS on Success else appropriate error.
* Description:
* Finds the best alternate path to a specified channel (as determined by
* the IBTL) that satisfies the requirements specified in an
* ibt_alt_path_attr_t struct. The specified channel must have been
* previously opened successfully using ibt_open_rc_channel.
* This function also ensures that the service being accessed by the
* channel is available at the selected alternate port.
*
* Note: The apa_dgid must be on the same destination channel adapter,
* if specified.
* This routine can not be called from interrupt context.
*/
{
void *results_p;
int i, j, template_len, rec_found;
/* validate channel */
if (IBCM_INVALID_CHANNEL(rc_chan)) {
return (IBT_CHAN_HDL_INVALID);
}
" AltPathInfo can't be NULL");
return (IBT_INVALID_PARAM);
}
if (retval != IBT_SUCCESS) {
return (retval);
}
"Invalid Channel type: Applicable only to RC Channel");
return (IBT_CHAN_SRV_TYPE_INVALID);
}
cur_dgid =
cur_sgid =
/* If optional attributes are specified, validate them. */
if (attrp) {
} else {
new_dgid.gid_prefix = 0;
new_sgid.gid_prefix = 0;
}
"SNprefix (%llX) doesn't match with \n specified DGID's "
return (IBT_INVALID_PARAM);
}
/* For the specified SGID, get HCA information. */
if (retval != IBT_SUCCESS) {
"Get HCA Port Failed: %d", retval);
return (retval);
}
return (IBT_HCA_BUSY_DETACHING);
}
/* Validate whether this HCA support APM */
goto get_alt_path_done;
}
/* Get Companion Port GID of the current Channel's SGID */
"Get Companion PortGids for - %llX:%llX",
if (retval != IBT_SUCCESS)
goto get_alt_path_done;
}
/* Get Companion Port GID of the current Channel's DGID */
"Get Companion PortGids for - %llX:%llX",
&dnum);
if (retval != IBT_SUCCESS)
goto get_alt_path_done;
}
for (i = 0; i < snum; i++) {
for (j = 0; j < dnum; j++) {
if (sgids_p[i].gid_prefix ==
dgids_p[j].gid_prefix) {
goto get_alt_proceed;
}
}
/* Current DGID */
if (sgids_p[i].gid_prefix ==
goto get_alt_proceed;
}
} else {
if (sgids_p[i].gid_prefix ==
goto get_alt_proceed;
}
}
}
/* Current SGID */
for (j = 0; j < dnum; j++) {
if (cur_sgid.gid_prefix ==
dgids_p[j].gid_prefix) {
goto get_alt_proceed;
}
}
}
for (i = 0; i < dnum; i++) {
if (dgids_p[i].gid_prefix ==
goto get_alt_proceed;
}
}
/* Current DGID */
goto get_alt_proceed;
}
}
/*
* hmm... No Companion Ports available.
* so we will be using current or specified attributes only.
*/
}
if (retval != IBT_SUCCESS) {
"Get HCA Port Failed: %d", retval);
goto get_alt_path_done;
}
}
/* Calculate the size for multi-path records template */
sizeof (sa_multipath_record_t));
/* SGID */
else
gid_ptr++;
/* DGID */
else
/* Is Flow Label Specified. */
if (attrp) {
}
/* Is HopLimit Specified. */
if (flags & IBT_PATH_HOP) {
}
/* Is TClass Specified. */
if (attrp->apa_tclass) {
}
/* Is SL specified. */
}
if (flags & IBT_PATH_PERF) {
} else {
}
}
}
/*
* Honor individual selection of these attributes,
* even if IBT_PATH_PERF is set.
*/
/* Check out whether Packet Life Time is specified. */
}
/* Is SRATE specified. */
}
}
/* Alt PathMTU can be GT or EQU to current channel's Pri PathMTU */
/* P_Key must be same as that of primary path */
if (retval != IBT_SUCCESS) {
retval);
goto get_alt_path_done;
}
/* NOTE: We will **NOT** specify how many records we want. */
"0x%X\n\tSGID = %llX:%llX, DGID = %llX:%llX", prim_mtu,
/* Get SA Access Handle. */
else
if (saa_handle == NULL) {
goto get_alt_path_done;
}
/* Contact SA Access to retrieve Path Records. */
&results_p);
if (retval != IBT_SUCCESS) {
goto get_alt_path_done;
}
rec_found = 0;
/* Update the PathInfo with the response Path Records */
"Alt PathMTU(%d) must be GT or EQU to Pri "
"PathMTU(%d). Ignore this rec",
continue;
}
/* Reject PathRec if it same as Primary Path. */
"ibt_get_alt_path: PathRec obtained"
" is similar to Prim Path, ignore "
"this record");
continue;
}
}
} else {
}
if (retval != IBT_SUCCESS)
continue;
/* Update some leftovers */
rec_found = 1;
break;
}
}
if (rec_found == 0) {
" be established");
} else
return (retval);
}
/* Routines for warlock */
/* ARGSUSED */
static void
{
}