ibcm_arp.c revision af4c679f647cf088543c762e33d41a3ac52cfa14
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <net/if_types.h>
#include <sys/pathname.h>
extern char cmlog[];
int ibcm_printip = 0;
/*
* Function:
* ibcm_ip_print
* Input:
* label Arbitrary qualifying string
* ipa Pointer to IP Address to print
*/
void
{
char buf[INET6_ADDRSTRLEN];
} else {
}
}
{
int ret = 0;
KM_SLEEP);
"returned: %d", ret);
if (ret == 0) {
}
if (sgid)
if (dgid)
" DGID: %llX:%llX",
} else if (ret == 0) {
/*
* We come here only when lookup has returned empty (failed)
* via callback routine.
* i.e. ib_s->status is non-zero, while ret is zero.
*/
if (wqnp)
}
if (ret)
return (IBT_FAILURE);
else
return (IBT_SUCCESS);
}
/*
* IP-ADDR info for that attribute only.
*/
static ibcm_arp_ip_t *
{
int i;
i++, ipp++) {
if (pkey) {
return (ipp);
else
continue;
}
return (ipp);
}
}
return (NULL);
}
static ibt_status_t
{
int i;
i++, ipp++) {
sizeof (in_addr_t)) == 0)) {
}
if (found) {
return (IBT_SUCCESS);
}
} else {
" family keep searching...");
}
}
"NOT Found");
return (IBT_SRC_IP_NOT_FOUND);
}
static int
{
if (i_ddi_devi_attached(dip) &&
}
"hca-guid", 0)) == 0) ||
"port-number", 0)) == 0) ||
NULL) != IBT_SUCCESS) ||
"port-pkey", IB_PKEY_INVALID_LIMITED)) <=
return (DDI_WALK_CONTINUE);
}
ibds->ibcm_arp_ibd_cnt++;
}
return (DDI_WALK_CONTINUE);
}
static void
{
}
/*
* Issue an ioctl down to IP. There are several similar versions of this
* function (e.g., rpcib_do_ip_ioctl()); clearly a utility routine is needed.
*/
static int
{
int err = 0;
return (EPROTO);
return (EPROTO);
}
return (err);
}
/*
* Issue an SIOCGLIFCONF down to IP and return the result in `lifcp'.
* lifcp->lifc_buf is dynamically allocated to be *bufsizep bytes.
*/
static int
{
int err;
if (err != 0)
return (err);
/*
* Pad the interface count to account for additional interfaces that
* may have been configured between the SIOCGLIFNUM and SIOCGLIFCONF.
*/
if (err != 0) {
return (err);
}
return (0);
}
/*
* Fill in `ibds' with IP addresses tied to IFT_IB IP interfaces. Returns
* B_TRUE if at least one address was filled in.
*/
static boolean_t
{
return (B_FALSE);
family_loc, nifs);
continue;
case AF_INET:
sizeof (struct sockaddr_in));
naddr++;
break;
case AF_INET6:
sizeof (struct sockaddr_in6));
naddr++;
break;
}
}
return (naddr > 0);
}
{
#ifdef DEBUG
int i;
#endif
if (ibdp->ibcm_arp_ibd_cnt == 0)
return (IBT_SRC_IP_NOT_FOUND);
/* Get the IP addresses of active ports. */
"ibd instance: IBT_SRC_IP_NOT_FOUND");
return (IBT_SRC_IP_NOT_FOUND);
}
#ifdef DEBUG
for (i = 0; i < ibdp->ibcm_arp_ibd_cnt; i++) {
char my_buf[INET6_ADDRSTRLEN];
"Instance %d PKey 0x%lX \n HCAGUID 0x%llX SGID %llX:%llX",
sizeof (my_buf)));
} else {
}
}
#endif
return (IBT_SUCCESS);
}
{
else
ibds.ibcm_arp_ibd_cnt = 0;
if (ret != IBT_SUCCESS) {
"ibcm_arp_get_ibds failed : 0x%x", ret);
goto srcip_plist_end;
}
if (ret != IBT_SUCCESS) {
"SGID for the specified SRCIP Not found %X", ret);
goto srcip_plist_end;
}
}
if (ret == IBT_SUCCESS) {
int i;
uint8_t no_srcip_cnt = 0;
plistp = port_list_p[0];
no_srcip_cnt++;
"ibcm_arp_get_srcip_plist: SrcIP NOT "
"Configured for GID %llX:%llX",
} else {
"ibcm_arp_get_srcip_plist: GID %llX:%llX",
sizeof (in_addr_t));
sizeof (in6_addr_t));
}
IBCM_PRINT_IP("ibcm_arp_get_srcip_plist: "
}
}
if (no_srcip_configured) {
/*
* Looks like some of the SRC GID we found have no
* IP ADDR configured, so remove these entries from
* our list.
*/
plistp = port_list_p[0];
"Only %d SGID (%d/%d) have SrcIP Configured",
if (new_cnt) {
/* Allocate Memory to hold Src Point info. */
sizeof (ibtl_cm_port_list_t), KM_SLEEP);
continue;
sizeof (ibtl_cm_port_list_t));
n_plistp++;
}
plistp = port_list_p[0];
} else {
/*
* All entries we have, do not have IP-Addr
* configured so return empty hand.
*/
"ibcm_arp_get_srcip_plist: None of SGID "
"found have SrcIP Configured");
*port_list_p = NULL;
}
}
}
if (ibds.ibcm_arp_ip)
sizeof (ibcm_arp_ip_t));
return (ret);
}