summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/ib/mgt/ibcm/ibcm_arp.h
blob: 8c3cc3021a84a5d0d2d76491a22ad3fdfcfd17a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
 * 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
 * or http://www.opensolaris.org/os/licensing.
 * 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) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
 */

#ifndef _SYS_IB_MGT_IBCM_IBCM_ARP_H
#define	_SYS_IB_MGT_IBCM_IBCM_ARP_H

#ifdef	__cplusplus
extern "C" {
#endif

#include <sys/ib/mgt/ibcm/ibcm_impl.h>
#include <sys/ib/clients/ibd/ibd.h>
#include <inet/ip2mac.h>
#include <inet/ip6.h>

#define	IBCM_ARP_MAX_IFNAME_LEN		24

#define	IBCM_H2N_GID(gid) \
{ \
	uint32_t	*ptr; \
	ptr = (uint32_t *)&gid.gid_prefix; \
	gid.gid_prefix = (uint64_t)(((uint64_t)ntohl(ptr[0]) << 32) | \
			(ntohl(ptr[1]))); \
	ptr = (uint32_t *)&gid.gid_guid; \
	gid.gid_guid = (uint64_t)(((uint64_t)ntohl(ptr[0]) << 32) | \
			(ntohl(ptr[1]))); \
}

#define	IBCM_ARP_PR_RT_PENDING		0x01
#define	IBCM_ARP_PR_RESOLVE_PENDING	0x02

/*
 * Path record wait queue node definition
 */
typedef struct ibcm_arp_prwqn {
	struct ibcm_arp_streams_s *ib_str;
	uint8_t			flags;
	ibt_ip_addr_t		usrc_addr;	/* user supplied src address */
	ibt_ip_addr_t		dst_addr;	/* user supplied dest address */
	ibt_ip_addr_t		src_addr;	/* rts's view of src address */
	ibt_ip_addr_t		gateway;	/* rts returned gateway addr */
	ibt_ip_addr_t		netmask;	/* rts returned netmask */
	char			ifname[IBCM_ARP_MAX_IFNAME_LEN];
	uint16_t		ifproto;
	ipoib_mac_t		src_mac;
	ipoib_mac_t		dst_mac;
	ib_gid_t		sgid;
	ib_gid_t		dgid;
	ip2mac_id_t		ip2mac_id;
} ibcm_arp_prwqn_t;

typedef struct ibcm_arp_streams_s {
	kmutex_t		lock;
	kcondvar_t		cv;
	int			status;
	boolean_t		done;
	ibcm_arp_prwqn_t	*wqnp;
} ibcm_arp_streams_t;

typedef struct ibcm_arp_ip_s {
	datalink_id_t	ip_linkid;
	ib_pkey_t	ip_pkey;
	ib_guid_t	ip_hca_guid;
	ib_gid_t	ip_port_gid;
	sa_family_t	ip_inet_family;
	union {
		struct sockaddr_in	ip_sockaddr;
		struct sockaddr_in6	ip_sockaddr6;
	} ip_sin;
#define	ip_cm_sin		ip_sin.ip_sockaddr
#define	ip_cm_sin6		ip_sin.ip_sockaddr6
	zoneid_t	ip_zoneid;
} ibcm_arp_ip_t;

typedef struct ibcm_arp_ibd_insts_s {
	uint8_t		ibcm_arp_ibd_alloc;
	uint8_t		ibcm_arp_ibd_cnt;
	ibcm_arp_ip_t	*ibcm_arp_ip;
} ibcm_arp_ibd_insts_t;

ibt_status_t ibcm_arp_get_ibaddr(zoneid_t zoneid, ibt_ip_addr_t srcip,
    ibt_ip_addr_t destip, ib_gid_t *sgid, ib_gid_t *dgid,
    ibt_ip_addr_t *saddr_p);
ibt_status_t ibcm_arp_get_ibds(ibcm_arp_ibd_insts_t *ibdp, sa_family_t fam);
void ibcm_arp_free_ibds(ibcm_arp_ibd_insts_t *ibds);

#ifdef	__cplusplus
}
#endif

#endif /* _SYS_IB_MGT_IBCM_IBCM_ARP_H */