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