xref: /titanic_51/usr/src/uts/common/sys/ib/mgt/ibcm/ibcm_arp.h (revision 17a2b317610f531d565bf4e940433aab2d9e6985)
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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #ifndef _SYS_IB_MGT_IBCM_IBCM_ARP_H
26 #define	_SYS_IB_MGT_IBCM_IBCM_ARP_H
27 
28 #ifdef	__cplusplus
29 extern "C" {
30 #endif
31 
32 #include <sys/ib/mgt/ibcm/ibcm_impl.h>
33 #include <sys/ib/clients/ibd/ibd.h>
34 #include <inet/ip2mac.h>
35 #include <inet/ip6.h>
36 
37 #define	IBCM_ARP_MAX_IFNAME_LEN		24
38 
39 #define	IBCM_H2N_GID(gid) \
40 { \
41 	uint32_t	*ptr; \
42 	ptr = (uint32_t *)&gid.gid_prefix; \
43 	gid.gid_prefix = (uint64_t)(((uint64_t)ntohl(ptr[0]) << 32) | \
44 			(ntohl(ptr[1]))); \
45 	ptr = (uint32_t *)&gid.gid_guid; \
46 	gid.gid_guid = (uint64_t)(((uint64_t)ntohl(ptr[0]) << 32) | \
47 			(ntohl(ptr[1]))); \
48 }
49 
50 #define	IBCM_ARP_PR_RT_PENDING		0x01
51 #define	IBCM_ARP_PR_RESOLVE_PENDING	0x02
52 
53 /*
54  * Path record wait queue node definition
55  */
56 typedef struct ibcm_arp_prwqn {
57 	struct ibcm_arp_streams_s *ib_str;
58 	uint8_t			flags;
59 	ibt_ip_addr_t		usrc_addr;	/* user supplied src address */
60 	ibt_ip_addr_t		dst_addr;	/* user supplied dest address */
61 	ibt_ip_addr_t		src_addr;	/* rts's view of src address */
62 	ibt_ip_addr_t		gateway;	/* rts returned gateway addr */
63 	ibt_ip_addr_t		netmask;	/* rts returned netmask */
64 	char			ifname[IBCM_ARP_MAX_IFNAME_LEN];
65 	uint16_t		ifproto;
66 	ipoib_mac_t		src_mac;
67 	ipoib_mac_t		dst_mac;
68 	ib_gid_t		sgid;
69 	ib_gid_t		dgid;
70 	ip2mac_id_t		ip2mac_id;
71 } ibcm_arp_prwqn_t;
72 
73 typedef struct ibcm_arp_streams_s {
74 	kmutex_t		lock;
75 	kcondvar_t		cv;
76 	int			status;
77 	boolean_t		done;
78 	ibcm_arp_prwqn_t	*wqnp;
79 } ibcm_arp_streams_t;
80 
81 typedef struct ibcm_arp_ip_s {
82 	datalink_id_t	ip_linkid;
83 	ib_pkey_t	ip_pkey;
84 	ib_guid_t	ip_hca_guid;
85 	ib_gid_t	ip_port_gid;
86 	sa_family_t	ip_inet_family;
87 	union {
88 		struct sockaddr_in	ip_sockaddr;
89 		struct sockaddr_in6	ip_sockaddr6;
90 	} ip_sin;
91 #define	ip_cm_sin		ip_sin.ip_sockaddr
92 #define	ip_cm_sin6		ip_sin.ip_sockaddr6
93 	zoneid_t	ip_zoneid;
94 } ibcm_arp_ip_t;
95 
96 typedef struct ibcm_arp_ibd_insts_s {
97 	uint8_t		ibcm_arp_ibd_alloc;
98 	uint8_t		ibcm_arp_ibd_cnt;
99 	ibcm_arp_ip_t	*ibcm_arp_ip;
100 } ibcm_arp_ibd_insts_t;
101 
102 ibt_status_t ibcm_arp_get_ibaddr(zoneid_t zoneid, ibt_ip_addr_t srcip,
103     ibt_ip_addr_t destip, ib_gid_t *sgid, ib_gid_t *dgid,
104     ibt_ip_addr_t *saddr_p);
105 ibt_status_t ibcm_arp_get_ibds(ibcm_arp_ibd_insts_t *ibdp, sa_family_t fam);
106 void ibcm_arp_free_ibds(ibcm_arp_ibd_insts_t *ibds);
107 
108 #ifdef	__cplusplus
109 }
110 #endif
111 
112 #endif /* _SYS_IB_MGT_IBCM_IBCM_ARP_H */
113