/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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
*/
/*
*/
/*
*
* ibt_get_paths() implement the Path Informations related functionality.
*/
/* 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. */
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)
{
func);
"NULL - ERROR ");
return (IBT_INVALID_PARAM);
}
/* Memory for path info will be allocated in ibcm_process_get_paths() */
}
/*
* ibt_get_paths() cache consists of one or more of:
*
* ib_gid_t dgid (attrp->pa_dgids[0])
* ibt_path_attr_t attr
* ibt_path_flags_t flags
* ibt_path_info_t path
*
* If the first 3 match, max_paths is 1, sname is NULL, and sid is 0,
* then the path is returned immediately.
*
* Note that a compare of "attr" is non-trivial. Only accept ones
* that memcmp() succeeds, i.e., basically assume a bzero was done.
*
* Cache must be invalidated if PORT_DOWN event or GID_UNAVAIL occurs.
* Cache must be freed as part of _fini.
*/
typedef struct ibcm_path_cache_s {
int ibcm_path_cache_size;
/* tunable, set to 1 to not allow link-local address */
int ibcm_ip6_linklocal_addr_ok = 0;
struct ibcm_path_cache_stat_s {
int hits;
int misses;
int adds;
int already_in_cache;
int bad_path_for_cache;
int purges;
int timeouts;
/*ARGSUSED*/
static void
{
/* else we're in _fini */
}
void
ibcm_path_cache_init(void)
{
}
void
ibcm_path_cache_fini(void)
{
int cache_size;
if (ibcm_path_cache_timeout_id) {
ibcm_path_cache_timeout_id = 0; /* no more timeouts */
}
if (tmp_timeout_id)
(void) untimeout(tmp_timeout_id);
}
static ibcm_status_t
{
int i;
return (IBCM_FAILURE);
}
return (IBCM_FAILURE);
if (ibcm_path_cache_invalidate) { /* invalidate all entries */
for (i = 0; i < ibcm_path_cache_size; i++, path_cachep++) {
}
return (IBCM_FAILURE);
}
for (i = 0; i < ibcm_path_cache_size; i++, path_cachep++) {
break; /* end of search, no more valid cache entries */
/* make pa_dgids pointers match, so we can use memcmp */
/* make pa_dgids NULL again */
continue;
}
/* else we have a match */
/* make pa_dgids NULL again */
if (num_paths_p)
return (IBCM_SUCCESS);
}
return (IBCM_FAILURE);
}
static void
{
int i;
return;
return;
for (i = 0; i < ibcm_path_cache_size; i++, path_cachep++) {
/* already in cache */
return;
}
continue;
}
/* else the rest of the entries are free, so use this one */
return;
}
}
void
ibcm_path_cache_purge(void)
{
}
/*
* 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;
num_paths_p) == IBCM_SUCCESS)
return (IBT_SUCCESS);
if (retval == IBT_SUCCESS)
return (retval);
}
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
{
int len;
/*
* 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);
/*
* Get list of active HCA<->Port list, that matches input specified attr
*/
if (retval != IBT_SUCCESS) {
"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. */
if (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;
}
if (extra)
extra--;
}
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. */
if ((retval != IBT_SUCCESS) &&
(retval != IBT_INSUFF_DATA) &&
}
}
"Failed to get PathRec: Status %d", retval);
} else {
}
}
if (rec_found == 0) {
if (retval == IBT_SUCCESS)
else if (rec_found != 0)
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;
"ibcm_get_single_pathrec: SGID_pfx="
"%llX, DGID_pfx=%llX doesn't match",
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\nSGID %llX:%llX "
/* 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 */
p_fnd = 0;
} else {
"ibcm_get_single_pathrec: "
"Fill Primary Path");
break;
if (retval != IBT_SUCCESS)
continue;
p_fnd = 1;
found++;
}
}
/* Deallocate the memory for results_p. */
if (idx != 0xFF)
break; /* We r here for MGID */
}
break; /* We r here for MGID */
}
if (found == 0)
else
return (retval);
}
static ibt_status_t
{
void *results_p;
int template_len;
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 */
for (i = 0; i < sgid_cnt; i++) {
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,
}
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;
} else if ((!p_tmp_found) &&
p_tmp_found = 1;
"ibcm_get_multi_pathrec: "
"Tmp Pri Path Found");
}
"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;
} else if ((!a_tmp_found) &&
a_tmp_found = 1;
"ibcm_get_multi_pathrec:"
"Tmp Alt Path Found ");
}
"ibcm_get_multi_pathrec:"
"Alt SGID Don't Match.. ");
}
}
(p_tmp_found == 0) && (a_tmp_found == 0)) {
" Path to desired node points NOT "
"Available.");
goto get_mpr_end;
}
}
}
}
}
/* Fill in Primary Path */
if (retval != IBT_SUCCESS)
goto get_mpr_end;
/* Fill in Alternate Path */
/*
* a_resp will point to AltPathInfo
* buffer.
*/
if (retval != IBT_SUCCESS)
goto get_mpr_end;
/* Update some leftovers */
} else {
"ibcm_get_multi_pathrec:"
" Alternate Path NOT Available.");
}
found++;
found++;
/* Fill in second Path */
if (retval != IBT_SUCCESS)
goto get_mpr_end;
else
found++;
} else {
"ibcm_get_multi_pathrec: "
"SecondPath NOT Available");
}
}
}
} 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) {
/* For all DGIDs */
continue;
gid_guid ==
break;
}
}
if (!match_found)
continue;
}
/* Fill in Primary Path */
if (retval != IBT_SUCCESS)
continue;
break;
}
}
}
if (found == 0)
else
return (retval);
}
/*
* 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_get_module_failure(IBT_FAILURE_IBSM, 0));
}
return (ibt_get_module_failure(IBT_FAILURE_IBSM, 0));
}
/* Source Node Information. */
/* Convert P_Key to P_Key_Index */
if (retval != IBT_SUCCESS) {
/* Failed to get pkey_index from pkey */
"Pkey2Index (PKey = %X) conversion failed: %d",
return (ibt_get_module_failure(IBT_FAILURE_IBSM, 0));
}
/* 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 "
"(PKey = %X) conversion failed: %d",
return (ibt_get_module_failure(
IBT_FAILURE_IBSM, 0));
}
sl[i].p_port_num;
break;
}
}
} else {
"must be non-null");
return (IBT_INVALID_PARAM);
}
} else {
return (ibt_get_module_failure(IBT_FAILURE_IBSM, 0));
}
/*
* 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;
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;
/* 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)
continue;
else
return (retval);
continue;
} else
return (IBT_SERVICE_RECORDS_NOT_FOUND);
}
/* if we are here, we got some records. so break. */
break;
}
if (retval != IBT_SUCCESS)
return (retval);
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's avoid LoopBack Nodes. */
"ibcm_saa_service_rec: ServiceGID "
"%llX:%llX is on Local Node, "
"search for remote.",
}
}
if (is_this_on_local_node) {
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 ((a_pkey != 0) &&
"ibcm_saa_service_rec: "
"Pri(0x%X) & Alt (0x%X) "
"PKey must match.",
p_pkey = 0;
continue;
}
rec_found++;
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;
}
/* Let's avoid LoopBack Nodes. */
"ibcm_saa_service_rec: ServiceGID "
"%llX:%llX is on Local Node, "
"search for remote.",
}
}
if ((i + 1) < num_req)
continue;
"Found ServiceGID = %llX:%llX",
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;
/* 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. */
&c_hp)) {
"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);
}
/*
* IP Path API
*/
typedef struct ibcm_ip_path_tqargs_s {
void *arg;
/* Holds destination information needed to fill in ibt_path_info_t. */
typedef struct ibcm_ip_dinfo_s {
/* Prototype Declarations. */
static void ibcm_process_get_ip_paths(void *tq_arg);
uint8_t *, ibt_path_info_t *);
/*
* Perform SA Access to retrieve Path Records.
*/
static ibt_status_t
{
uint8_t i, j;
return (IBT_INVALID_PARAM);
}
num_path);
/*
* 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)
else if (rec_found != 0)
for (i = 0; i < rec_found; i++) {
sizeof (ibt_ip_addr_t));
}
/* Is Alt Path present */
sizeof (ibt_ip_addr_t));
}
}
}
}
}
return (retval);
}
static ibt_status_t
{
int s;
if (retval != IBT_SUCCESS)
return (retval);
/* Update some leftovers */
}
/* Set Alternate Path to invalid state. */
paths->pi_hca_guid);
return (retval);
}
static ibt_status_t
{
void *results_p;
int i, j, k;
/* Is Flow Label Specified. */
}
/* Is HopLimit Specified. */
}
/* Is TClass Specified. */
if (attrp->ipa_tclass) {
}
/* 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. */
/* SGID */
"SGID_pfx=%llX DGID_pfx=%llX doesn't match",
continue;
}
"Get %d Path(s) between\n SGID %llX:%llX "
/* Contact SA Access to retrieve Path Records. */
sizeof (sa_path_record_t);
if (retval != IBT_SUCCESS) {
*num_path = 0;
return (retval);
}
continue;
/* Update the PathInfo from the response. */
if ((p_fnd != 0) &&
": Fill Alternate Path");
if (retval != IBT_SUCCESS)
continue;
/* Update some leftovers */
p_fnd = 0;
} else {
": Fill Primary Path");
break;
if (retval != IBT_SUCCESS)
continue;
p_fnd = 1;
found++;
}
}
/* Deallocate the memory for results_p. */
}
}
if (found == 0)
else
return (retval);
}
static ibt_status_t
{
void *results_p;
int template_len;
int i;
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 */
for (i = 0; i < sgid_cnt; i++) {
gid_ptr++;
}
/* DGIDs */
for (i = 0; i < dgid_cnt; i++) {
gid_ptr++;
}
/* Is Flow Label Specified. */
}
/* Is HopLimit Specified. */
}
/* Is TClass Specified. */
if (attrp->ipa_tclass) {
}
/* 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. */
}
/* 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);
}
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;
s_spec =
if (sgid_cnt > 1)
else
if (dgid_cnt > 1)
else
/*
* he gets his primary-path on those node points.
*/
"PF %d, AF %d,\n\t\t P[%d] = SG: %llX, "
if ((!p_found) &&
": Pri DGID Match.. ");
p_found = 1;
"ibcm_get_ip_mpr: "
"Primary Path Found");
if (a_found)
break;
else
continue;
}
": Pri SGID Don't Match.. ");
}
if ((!a_found) &&
": Alt DGID Match.. ");
a_found = 1;
"ibcm_get_ip_mpr:"
"Alternate Path Found ");
if (p_found)
break;
else
continue;
}
": Alt SGID Don't Match.. ");
}
}
"to desired node points NOT Available.");
goto get_ip_mpr_end;
}
}
/* Fill in Primary Path */
if (retval != IBT_SUCCESS)
goto get_ip_mpr_end;
/* Fill in Alternate Path */
/* a_resp will point to AltPathInfo buffer. */
if (retval != IBT_SUCCESS)
goto get_ip_mpr_end;
/* Update some leftovers */
} else {
"Alternate Path NOT Available.");
}
found++;
} else { /* If NOT APM */
/* Fill in Primary Path */
if (retval != IBT_SUCCESS)
continue;
break;
}
}
}
if (found == 0)
else
return (retval);
}
static void
{
int len = 0;
uint8_t i;
/*
* Prepare the Source and Destination GID list based on the input
* attributes. We contact ARP module to perform IP to MAC
* i.e. GID conversion. We use this GID for path look-up.
*
* If APM is requested and if multiple Dest IPs are specified, check
* out whether they are companion to each other. But, if only one
* Dest IP is specified, then it is beyond our scope to verify that
* the companion port GID obtained has IP-Service enabled.
*/
if (retval) {
"ibcm_arp_get_ibaddr() failed: %d", retval);
goto ippath_error;
}
sizeof (ibt_pkt_lt_req_t));
if (retval == IBT_SUCCESS) {
} else {
"ibtl_cm_get_active_plist: Failed %d", retval);
goto ippath_error;
}
i = 1;
/* Get DGID for all specified Dest IP Addr */
if (retval) {
"ibcm_process_get_ip_paths: "
"ibcm_arp_get_ibaddr failed: %d", retval);
goto ippath_error2;
}
}
if ((retval != IBT_SUCCESS) &&
(retval != IBT_GIDS_NOT_FOUND)) {
"ibcm_process_get_ip_paths: "
"Invalid DGIDs specified w/ APM Flag");
goto ippath_error2;
}
"Found %d Comp DGID", dnum);
if (dnum) {
i++;
}
}
}
/* "i" will get us num_dest count. */
/*
* IBTF allocates memory for path_info & src_ip in case of
* Async Get IP Paths
*/
KM_SLEEP);
}
"NO HCA found");
goto ippath_error2;
}
/* Get SA Access Handle. */
if (i == 0) {
/* Validate whether this HCA supports APM */
"ibcm_process_get_ip_paths: HCA (%llX): "
goto ippath_error3;
}
}
if (saa_handle == NULL) {
"SAA HDL NULL, HCA (%llX:%d) NOT ACTIVE",
goto ippath_error3;
}
}
/* Get Path Records. */
if (sl)
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);
num_path * sizeof (ibt_path_ip_src_t));
sizeof (ibt_path_ip_src_t) * max_paths);
} else if (retval != IBT_SUCCESS) {
sizeof (ibt_path_info_t) * max_paths);
sizeof (ibt_path_ip_src_t) * max_paths);
tmp_path_p = NULL;
tmp_src_ip_p = NULL;
} else {
}
} else {
}
}
static ibt_status_t
{
uint_t i;
return (IBT_INVALID_PARAM);
}
/*
* Validate Path Flags.
* IBT_PATH_AVAIL & IBT_PATH_PERF are mutually exclusive.
*/
"\n\t AVAIL and PERF flags specified together", flags);
return (IBT_INVALID_PARAM);
}
/*
* Validate number of records requested.
*
* Max_paths of "0" is invalid.
* Max_paths <= IBT_MAX_SPECIAL_PATHS, if AVAIL or PERF is set.
*/
if (attrp->ipa_max_paths == 0) {
return (IBT_INVALID_PARAM);
}
"requested is <%d> \n when IBT_PATH_AVAIL or IBT_PATH_PERF"
" flag is specified.", IBT_MAX_SPECIAL_PATHS);
return (IBT_INVALID_PARAM);
}
/* Only 2 destinations can be specified w/ APM flag. */
"APM flag");
return (IBT_INVALID_PARAM);
}
/* Validate the destination info */
return (IBT_INVALID_PARAM);
}
/* Basic validation of Source IPADDR (if provided). */
return (IBT_NOT_SUPPORTED);
return (IBT_NOT_SUPPORTED);
}
if (ibcm_ip6_linklocal_addr_ok &&
"Link Local Address: NOT SUPPORTED");
return (IBT_NOT_SUPPORTED);
}
/* Basic validation of Dest IPADDR. */
"Invalid DstIP specified");
return (IBT_INVALID_PARAM);
return (IBT_NOT_SUPPORTED);
return (IBT_NOT_SUPPORTED);
}
/*
* If SrcIP is specified, make sure that SrcIP and DstIP
* belong to same family.
*/
"Specified SrcIP (%d) and DstIP(%d) family diffs.",
return (IBT_INVALID_PARAM);
}
}
return (IBT_SUCCESS);
}
static ibt_status_t
{
if (retval != IBT_SUCCESS)
return (retval);
sizeof (ibcm_ip_path_tqargs_t);
"Unable to allocate memory for local usage.");
return (IBT_INSUFF_KERNEL_RESOURCE);
}
sizeof (ibcm_ip_path_tqargs_t));
/* Ignore IBT_PATH_AVAIL flag, if only one path is requested. */
flags &= ~IBT_PATH_AVAIL;
"IBT_PATH_AVAIL flag, as only ONE path info is requested.");
}
}
if (ret == 0) {
"the TaskQ");
}
} else {
} else { /* Blocking */
}
}
return (retval);
}
{
"NULL - ERROR ");
return (IBT_INVALID_PARAM);
}
/* path info will be allocated in ibcm_process_get_ip_paths() */
}
{
"NULL - ERROR ");
return (IBT_INVALID_PARAM);
}
if (num_paths_p != NULL)
*num_paths_p = 0;
}
{
void *results_p;
/* 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) {
/* Get SGID and DGID for the specified input ip-addr */
if (retval) {
"ibcm_arp_get_ibaddr() failed: %d", retval);
return (retval);
}
} 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_ip_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_ip_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_ip_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_ip_alt_proceed;
}
}
/* Current DGID */
if (sgids_p[i].gid_prefix ==
goto get_ip_alt_proceed;
}
} else {
if (sgids_p[i].gid_prefix ==
goto get_ip_alt_proceed;
}
}
}
/* Current SGID */
for (j = 0; j < dnum; j++) {
if (cur_sgid.gid_prefix ==
dgids_p[j].gid_prefix) {
goto get_ip_alt_proceed;
}
}
}
for (i = 0; i < dnum; i++) {
if (dgids_p[i].gid_prefix ==
goto get_ip_alt_proceed;
}
}
/* Current DGID */
goto get_ip_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_ip_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) {
"Failed: %d", retval);
goto get_ip_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_ip_alt_path_done;
}
/* Contact SA Access to retrieve Path Records. */
&results_p);
if (retval != IBT_SUCCESS) {
goto get_ip_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. */
&c_hp)) {
"ibt_get_ip_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
{
}
/* ARGSUSED */
static void
{
}