xref: /illumos-gate/usr/src/uts/common/sys/ib/mgt/ibcm/ibcm_arp.h (revision e11c3f44f531fdff80941ce57c065d2ae861cefc)
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 2009 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 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/ib/mgt/ibcm/ibcm_impl.h>
34 #include <sys/modhash.h>
35 #include <sys/ib/clients/ibd/ibd.h>
36 #include <sys/strsun.h>
37 #include <sys/socket.h>
38 #include <sys/stat.h>	/* for S_IFCHR */
39 
40 /*
41  * IPoIB addr lookup completion function
42  */
43 typedef int (*ibcm_arp_pr_comp_func_t) (void *usr_arg, int status);
44 
45 #define	IBCM_ARP_MAX_IFNAME_LEN		24
46 #define	IBCM_ARP_RTM_LEN		0x158
47 #define	IBCM_ARP_XMIT_COUNT		6
48 #define	IBCM_ARP_XMIT_INTERVAL		1000	/* timeout in milliseconds */
49 #define	IBCM_ARP_TIMEOUT \
50 		((IBCM_ARP_XMIT_COUNT + 1) * IBCM_ARP_XMIT_INTERVAL)
51 #define	IBCM_ARP_IP6_TIMEOUT		1000000	/* timeout in microseconds */
52 
53 enum {
54 	IBCM_ARP_PR_RT_PENDING = 0x01,
55 	IBCM_ARP_PR_ARP_PENDING = 0x02
56 };
57 
58 /*
59  * Path record wait queue node definition
60  */
61 typedef struct ibcm_arp_prwqn {
62 	ibcm_arp_pr_comp_func_t	func;	/* user callback function */
63 	void			*arg;	/* callback function arg */
64 	timeout_id_t		timeout_id;
65 	uint8_t			flags;
66 	ibt_ip_addr_t		usrc_addr;	/* user supplied src address */
67 	ibt_ip_addr_t		dst_addr;	/* user supplied dest address */
68 	ibt_ip_addr_t		src_addr;	/* rts's view of src address */
69 	char			ifname[IBCM_ARP_MAX_IFNAME_LEN];
70 	int			ibd_instance;
71 	uint16_t		ifproto;
72 	ipoib_mac_t		src_mac;
73 	ipoib_mac_t		dst_mac;
74 	uint32_t		localroute;		/* user option */
75 	uint32_t		bound_dev_if;		/* user option */
76 	ib_gid_t		sgid;
77 	ib_gid_t		dgid;
78 	uint8_t			hw_port;
79 	uint16_t		pkey;
80 	int			retries;	/* no. of ND retries for ipv6 */
81 } ibcm_arp_prwqn_t;
82 
83 typedef struct ibcm_arp_streams_s {
84 	kmutex_t		lock;
85 	kcondvar_t		cv;
86 	queue_t			*arpqueue;
87 	vnode_t			*arp_vp;
88 	int			status;
89 	boolean_t		done;
90 	ibcm_arp_prwqn_t	*wqnp;
91 } ibcm_arp_streams_t;
92 
93 /* GID to IP-Addr and Ip-Addr to GID look-up functions. */
94 
95 #define	IBCM_ARP_IBD_INSTANCES		4
96 
97 typedef struct ibcm_arp_ip_s {
98 	uint8_t		ip_inst;
99 	ib_pkey_t	ip_pkey;
100 	ib_guid_t	ip_hca_guid;
101 	ib_gid_t	ip_port_gid;
102 	sa_family_t	ip_inet_family;
103 	union {
104 		struct sockaddr_in	ip_sockaddr;
105 		struct sockaddr_in6	ip_sockaddr6;
106 	} ip_sin;
107 #define	ip_cm_sin		ip_sin.ip_sockaddr
108 #define	ip_cm_sin6		ip_sin.ip_sockaddr6
109 } ibcm_arp_ip_t;
110 
111 typedef struct ibcm_arp_ibd_insts_s {
112 	uint8_t		ibcm_arp_ibd_alloc;
113 	uint8_t		ibcm_arp_ibd_cnt;
114 	ibcm_arp_ip_t	*ibcm_arp_ip;
115 } ibcm_arp_ibd_insts_t;
116 
117 ibt_status_t ibcm_arp_get_ibaddr(ipaddr_t srcip, ipaddr_t destip,
118     ib_gid_t *sgid, ib_gid_t *dgid);
119 ibt_status_t ibcm_arp_get_srcip_plist(ibt_ip_path_attr_t *attr,
120     ibt_path_flags_t flags, ibtl_cm_port_list_t **list_p);
121 ibt_status_t ibcm_arp_get_ibds(ibcm_arp_ibd_insts_t *ibdp);
122 
123 #ifdef	__cplusplus
124 }
125 #endif
126 
127 #endif /* _SYS_IB_MGT_IBCM_IBCM_ARP_H */
128