1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS_IB_MGT_IBCM_IBCM_ARP_H 27 #define _SYS_IB_MGT_IBCM_IBCM_ARP_H 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 36 #include <sys/ib/mgt/ibcm/ibcm_impl.h> 37 #include <sys/modhash.h> 38 #include <sys/ib/clients/ibd/ibd.h> 39 #include <sys/strsun.h> 40 #include <sys/strsubr.h> 41 #include <sys/socket.h> 42 #include <sys/stat.h> /* for S_IFCHR */ 43 #include <inet/common.h> 44 #include <inet/ip.h> 45 #include <inet/ip_if.h> 46 #include <inet/ip_ire.h> 47 #include <inet/ip_rts.h> 48 #include <sys/dlpi.h> 49 #include <net/route.h> 50 51 /* 52 * IPoIB addr lookup completion function 53 */ 54 typedef int (*ibcm_arp_pr_comp_func_t) (void *usr_arg, int status); 55 56 #define IBCM_ARP_MAX_IFNAME_LEN 24 57 #define IBCM_ARP_RTM_LEN 0x158 58 #define IBCM_ARP_XMIT_COUNT 6 59 #define IBCM_ARP_XMIT_INTERVAL 1000 /* timeout in milliseconds */ 60 #define IBCM_ARP_TIMEOUT \ 61 ((IBCM_ARP_XMIT_COUNT + 1) * IBCM_ARP_XMIT_INTERVAL) 62 #define IBCM_ARP_IP6_TIMEOUT 1000000 /* timeout in microseconds */ 63 64 enum { 65 IBCM_ARP_PR_RT_PENDING = 0x01, 66 IBCM_ARP_PR_ARP_PENDING = 0x02 67 }; 68 69 /* 70 * Path record wait queue node definition 71 */ 72 typedef struct ibcm_arp_prwqn { 73 ibcm_arp_pr_comp_func_t func; /* user callback function */ 74 void *arg; /* callback function arg */ 75 timeout_id_t timeout_id; 76 uint8_t flags; 77 ibt_ip_addr_t usrc_addr; /* user supplied src address */ 78 ibt_ip_addr_t dst_addr; /* user supplied dest address */ 79 ibt_ip_addr_t src_addr; /* rts's view of src address */ 80 char ifname[IBCM_ARP_MAX_IFNAME_LEN]; 81 int ibd_instance; 82 uint16_t ifproto; 83 ipoib_mac_t src_mac; 84 ipoib_mac_t dst_mac; 85 uint32_t localroute; /* user option */ 86 uint32_t bound_dev_if; /* user option */ 87 ib_gid_t sgid; 88 ib_gid_t dgid; 89 uint8_t hw_port; 90 uint16_t pkey; 91 int retries; /* no. of ND retries for ipv6 */ 92 } ibcm_arp_prwqn_t; 93 94 typedef struct ibcm_arp_streams_s { 95 kmutex_t lock; 96 kcondvar_t cv; 97 queue_t *arpqueue; 98 vnode_t *arp_vp; 99 int status; 100 boolean_t done; 101 ibcm_arp_prwqn_t *wqnp; 102 } ibcm_arp_streams_t; 103 104 /* GID to IP-Addr and Ip-Addr to GID look-up functions. */ 105 106 #define IBCM_ARP_IBD_NAME "ibd" 107 #define IBCM_ARP_IBD_INSTANCES 4 108 109 typedef struct ibcm_arp_ip_s { 110 uint8_t ip_inst; 111 ib_pkey_t ip_pkey; 112 ib_guid_t ip_hca_guid; 113 ib_gid_t ip_port_gid; 114 sa_family_t ip_inet_family; 115 union { 116 struct sockaddr_in ip_sockaddr; 117 struct sockaddr_in6 ip_sockaddr6; 118 } ip_sin; 119 #define ip_cm_sin ip_sin.ip_sockaddr 120 #define ip_cm_sin6 ip_sin.ip_sockaddr6 121 } ibcm_arp_ip_t; 122 123 typedef struct ibcm_arp_ibd_insts_s { 124 uint8_t ibcm_arp_ibd_alloc; 125 uint8_t ibcm_arp_ibd_cnt; 126 ibcm_arp_ip_t *ibcm_arp_ip; 127 } ibcm_arp_ibd_insts_t; 128 129 ibt_status_t ibcm_arp_get_ibaddr(ipaddr_t srcip, ipaddr_t destip, 130 ib_gid_t *sgid, ib_gid_t *dgid); 131 ibt_status_t ibcm_arp_get_srcip_plist(ibt_ip_path_attr_t *attr, 132 ibt_path_flags_t flags, ibtl_cm_port_list_t **list_p); 133 ibt_status_t ibcm_arp_get_ibds(ibcm_arp_ibd_insts_t *ibdp); 134 135 #ifdef __cplusplus 136 } 137 #endif 138 139 #endif /* _SYS_IB_MGT_IBCM_IBCM_ARP_H */ 140