/*
* 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
*/
/*
* Copyright (c) 2002-2003, Network Appliance, Inc. All rights reserved.
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
*
* MODULE: dapl_ia_open.c
*
* PURPOSE: Interface Adapter management
* Description: Interfaces in this file are completely described in
* the DAPL 1.1 API, Chapter 6, section 2
*
* $Id: dapl_ia_open.c,v 1.30 2003/07/31 14:04:17 jlentini Exp $
*/
#include "dapl.h"
#include "dapl_provider.h"
#include "dapl_evd_util.h"
#include "dapl_hca_util.h"
#include "dapl_ia_util.h"
#include "dapl_adapter_util.h"
#include <sys/systeminfo.h>
#include <libdevinfo.h>
/*
* LOCAL PROTOTYPES
*/
#if defined(IBHOSTS_NAMING)
char *device_name);
#endif /* IBHOSTS_NAMING */
/*
* Determine whether the platform supports RO (Relaxed ordering)
* Return B_TRUE if it does support RO and B_FALSE if it does not support RO
*
* udapl_ro_disallowed is an out paramter returning whether or not
* relaxed ordering should be disabled (regardless of whether the platform
* is capable of supporting relaxed ordering)
*
*/
static boolean_t
dapl_ro_disallowed(void)
{
static const char * const non_ro_capable_platforms[] = {
"i86pc",
"i86xpv",
"SUNW,Sun-Fire-V215",
"SUNW,Sun-Fire-V245",
"SUNW,Sun-Fire-V445",
"SUNW,Sun-Fire-T1000",
"SUNW,Sun-Fire-T200",
"SUNW,Sun-Blade-T6300",
"SUNW,Sun-Blade-T6320",
"SUNW,SPARC-Enterprise-T1000",
"SUNW,SPARC-Enterprise-T2000",
"SUNW,SPARC-Enterprise-T5120",
"SUNW,SPARC-Enterprise-T5220",
};
register int i;
register const char *cp;
int ret;
static const char *ro_disallowed_property =
"pci-relaxed-ordering-disallowed";
int bool;
int *boolp = &bool;
return (B_TRUE);
}
}
/*
* This function only finds and looks at the FIRST udapl node.
* It is assumed that there can only be one such node.
*/
return (B_FALSE);
if (node != DI_NODE_NIL) {
switch (ret) {
case 0:
case 1:
break;
default:
break;
}
}
else
return (ro_disallowed);
}
/*
* dapl_ia_open
*
* DAPL Requirements Version xxx, 6.2.1.1
*
* Open a provider and return a handle. The handle enables the user
* to invoke operations on this provider.
*
* The dat_ia_open call is actually part of the DAT registration module.
* That function maps the DAT_NAME parameter of dat_ia_open to a DAT_PROVIDER,
* and calls this function.
*
* Input:
* provider
* async_evd_qlen
* async_evd_handle_ptr
*
* Output:
* async_evd_handle
* ia_handle
*
* Return Values:
* DAT_SUCCESS
* DAT_INSUFFICIENT_RESOURCES
* DAT_INVALID_PARAMETER
* DAT_INVALID_HANDLE
* DAT_NAME_NOT_FOUND (returned by dat registry if necessary)
*/
{
"dapl_ia_open(%s, %d, %p, %p, %d)\n",
name,
if (DAT_SUCCESS != dat_status) {
"dapl_ia_open: dapl_provider_list_search(\"%s\") returned "
"%d\n",
name,
goto bail;
}
/* ia_handle_ptr and async_evd_handle_ptr cannot be NULL */
if (ia_handle_ptr == NULL) {
goto bail;
}
if (async_evd_handle_ptr == NULL) {
goto bail;
}
/* initialize the caller's OUT param */
/* get the hca_ptr */
/*
* Open the HCA if it has not been done before.
*/
/* register with the HW */
&hca_ptr->ib_hca_handle);
if (dat_status != DAT_SUCCESS) {
"dapls_ib_open_hca failed %d\n", dat_status);
goto bail;
}
/* create a cq domain for this HCA */
if (dat_status != DAT_SUCCESS) {
"ERR: Cannot allocate CQD: err %x\n", dat_status);
goto bail;
}
/*
* Obtain the IP address associated with this name and HCA.
*/
#ifdef IBHOSTS_NAMING
#endif /* IBHOSTS_NAMING */
/*
* Obtain IA attributes from the HCA to limit certain
* operations.
* If using DAPL_ATS naming, ib_query_hca will also set the ip
* address.
*/
NULL,
if (dat_status != DAT_SUCCESS) {
goto bail;
}
}
/* is the IA going to use the ConnectX? */
if (hca_ptr->hermon_resize_cq != 0) {
/*
* We are running with a ConnectX.
* Determine whether platform is RO capable.
* If platform support RO and client does not
* support RO and we are not disabling RO, reject the open.
*/
if (! ro_aware_client && ! ro_disallowed) {
"dapl_ia_open: failing ro_disallowed %d "
"ro_aware_client %d \n",
goto bail;
}
} else {
/* We are not running with a Connect X */
}
/* Take a reference on the hca_handle */
/* Allocate and initialize ia structure */
if (!ia_ptr) {
goto bail;
}
/*
* Note when we should be disabling relaxed ordering.
* If the property indicates that we should not use relaxed ordering
* we remember that fact. If the platform is supposed to be
* non relaxed ordering capable, we disable relaxed ordering as
* well, just in case the property or the list indicating that
* this platform is not relaxed ordering capable is mistaken.
*/
if (ro_disallowed)
/*
* we need an async EVD for this IA
* use the one passed in (if non-NULL) or create one
*/
if (evd_ptr) {
goto bail;
}
/*
* InfiniBand allows only 1 asychronous event handler per HCA
* (see InfiniBand Spec, release 1.1, vol I, section 11.5.2,
* page 559).
*
* We only need to make sure that this EVD's CQ belongs to
* the same HCA as is being opened.
*/
hca_ptr->ib_hca_handle) {
goto bail;
}
} else {
/*
* Verify we have >0 length, and let the provider check the
* size
*/
if (async_evd_qlen <= 0) {
goto bail;
}
NULL, /* CNO ptr */
&evd_ptr);
if (dat_status != DAT_SUCCESS) {
goto bail;
}
#if 0
/*
* The async EVD for this HCA has already been assigned.
* It's an error to try and assign another one.
*
* However, we need to somehow allow multiple IAs
* off of the same HCA. The right way to do this
* is by dispatching events off the HCA to the
* appropriate IA, but we aren't there yet. So for
* now we create the EVD but don't connect it to
* anything.
*/
goto bail;
#endif
} else {
/*
* Register the handlers associated with the async EVD.
*/
if (dat_status != DAT_SUCCESS) {
/* Assign the EVD so it gets cleaned up */
goto bail;
}
}
}
*ia_handle_ptr = ia_ptr;
bail:
if (dat_status != DAT_SUCCESS) {
if (ia_ptr) {
/* This will release the async EVD if needed. */
}
}
"dapl_ia_open () returns 0x%x\n",
return (dat_status);
}
/*
* dapli_hca_cleanup
*
* Clean up partially allocated HCA stuff. Strictly to make cleanup
* simple.
*/
void
{
}
}
#if defined(IBHOSTS_NAMING)
char *dapli_get_adapter_num(
char *device_name);
void dapli_setup_dummy_addr(
/*
* dapli_assign_hca_ip_address
*
* Obtain the IP address of the passed in name, which represents a
* port on the hca. There are three methods here to obtain the
* appropriate IP address, each with their own shortcoming:
* 1) IPOIB_NAMING. Requires the implementation of the IPoIB
* interface defined in include/dapl/ipoib_names.h. This is
* not the recommended interface as IPoIB is limited at
* the point we need to obtain an IP address on the
* passive side of a connection. The code supporting this
* implementation has been removed.
*
* file. The immediate drawback here is that we must dictate
* how to name the interface, which is a stated DAPL non-goal.
* In the broader perspective, this method requires us to xmit
* the IP address in the private data of a connection, which has
* other fun problems. This is the default method and is known to
* work, but it has problems.
*
* 3) Obtain the IP address from the driver, which has registered
* the address with the SA for retrieval.
*
*
* Input:
* hca_ptr Pointer to HCA structure
* device_name Name of device as reported by the provider
*
* Output:
* none
*
* Returns:
* char * to string number
*/
void
char *device_name)
{
char *adapter_num;
char *str;
int rc;
/*
* Obtain the IP address of the adapter. This is a simple
* scheme that creates a name that must appear available to
* DNS, e.g. it must be in the local site DNS or in the local
*
* <hostname>-ib<index>
*
* This scheme obviously doesn't work with adapters from
* multiple vendors, but will suffice in common installations.
*/
/*
* Strip off domain info if it exists (e.g. mynode.mydomain.com)
*/
str++;
}
if (*str == '.') {
*str = '\0';
}
if (rc != 0) {
/* Not registered in DNS, provide a dummy value */
} else {
/*
* hca_address is defined as a DAT_SOCK_ADDR6 whereas ai_addr
* is a sockaddr
*/
}
}
/*
* dapli_stup_dummy_addr
*
* Set up a dummy local address for the HCA. Things are not going
* to work too well if this happens.
* We call this routine if:
* - remote host adapter name is not in DNS
* - IPoIB implementation is not correctly set up
* - Similar nonsense.
*
* Input:
* hca_ptr
* rhost_name Name of remote adapter
*
* Output:
* none
*
* Returns:
* none
*/
void
IN char *rhost_name)
{
/* Not registered in DNS, provide a dummy value */
" using dummy IP value\n", rhost_name);
}
/*
* dapls_get_adapter_num
*
* Given a device name, return a string of the device number
*
* Input:
* device_name Name of device as reported by the provider
*
* Output:
* none
*
* Returns:
* char * to string number
*/
char *
char *device_name)
{
char *p;
/*
* Optimisticaly simple algorithm: the device number appears at
* the end of the device name string. Device that do not end
* in a number are by default "0".
*/
for (p = device_name; *p; p++) {
if (isdigit(*p)) {
return (p);
}
}
return (zero);
}
#endif /* IBHOSTS_NAMING */
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* tab-width: 8
* End:
*/