1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2009-2012 Cray, Inc.
5 * Author: Nic Henke <nic@cray.com>, James Shimek <jshimek@cray.com>
7 * This file is part of Lustre, http://www.lustre.org.
9 * Lustre is free software; you can redistribute it and/or
10 * modify it under the terms of version 2 of the GNU General Public
11 * License as published by the Free Software Foundation.
13 * Lustre is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Lustre; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #ifndef _GNILND_ARIES_H
24 #define _GNILND_ARIES_H
26 /* for libcfs_ipif_query */
27 #include <libcfs/libcfs.h>
29 #ifndef _GNILND_HSS_OPS_H
30 # error "must include gnilnd_hss_ops.h first"
33 /* Set HW related values */
35 #include <aries/aries_timeouts_gpl.h>
37 /* from aries_timeouts_gpl.h when building for generic kernel */
38 #define TIMEOUT_SECS(x) ((uint64_t)(((x) / 1000.0) + 0.5))
39 #ifndef TO_GNILND_timeout
40 #define TO_GNILND_timeout (60000.000000)
41 #endif /* TO_GNILND_timeout */
42 #endif /* CONFIG_CRAY_XT */
44 #define GNILND_BASE_TIMEOUT TIMEOUT_SECS(TO_GNILND_timeout)
45 #define GNILND_CHECKSUM_DEFAULT 0 /* all off for Aries */
47 #if defined(CONFIG_CRAY_COMPUTE)
48 #define GNILND_REVERSE_RDMA GNILND_REVERSE_PUT
49 #define GNILND_RDMA_DLVR_OPTION GNI_DLVMODE_PERFORMANCE
51 #define GNILND_REVERSE_RDMA GNILND_REVERSE_GET
52 #define GNILND_RDMA_DLVR_OPTION GNI_DLVMODE_PERFORMANCE
55 /* plug in our functions for use on the simulator */
56 #if !defined(GNILND_USE_RCA)
58 extern kgn_data_t kgnilnd_data;
60 #define kgnilnd_hw_hb() do {} while(0)
64 /* Aries Sim doesn't have hardcoded tables, so we'll hijack the nic_pe
65 * and decode our address and nic addr from that - the rest are just offsets */
68 kgnilnd_nid_to_nicaddrs(__u32 nid, int numnic, __u32 *nicaddr)
71 CERROR("manual nid2nic translation doesn't support"
72 "multiple nic addrs (you asked for %d)\n",
76 if (nid < kgnilnd_data.kgn_nid_trans_private) {
77 CERROR("Request for invalid nid translation %u,"
79 nid, kgnilnd_data.kgn_nid_trans_private);
83 *nicaddr = nid - kgnilnd_data.kgn_nid_trans_private;
85 CDEBUG(D_NETTRACE, "Sim nid %d -> nic 0x%x\n", nid, *nicaddr);
91 kgnilnd_nicaddr_to_nid(__u32 nicaddr, __u32 *nid)
93 *nid = kgnilnd_data.kgn_nid_trans_private + nicaddr;
97 /* XXX Nic: This does not support multiple device!!!! */
99 kgnilnd_setup_nic_translation(__u32 device_id)
101 char *if_name = "ipogif0";
102 __u32 ipaddr, netmask, my_nid;
105 LCONSOLE_INFO("using Aries SIM IP info for RCA translation\n");
107 rc = libcfs_ipif_query(if_name, &up, &ipaddr, &netmask);
109 CERROR ("can't get IP interface for %s: %d\n", if_name, rc);
113 CERROR ("IP interface %s is down\n", if_name);
117 my_nid = ((ipaddr >> 8) & 0xFF) + (ipaddr & 0xFF);
118 kgnilnd_data.kgn_nid_trans_private = my_nid - device_id;
123 #else /* CONFIG_CRAY_XT */
124 #include <net/inet_common.h>
125 #include <linux/if_arp.h>
128 kgnilnd_nid_to_nicaddrs(__u32 nid, int numnic, __u32 *nicaddrs)
132 #define NID_MASK ((1ULL << 18) - 1)
134 struct arpreq req = {
135 .arp_dev = "ipogif0",
138 req.arp_pa.sa_family = AF_INET;
139 ((struct sockaddr_in *)&req.arp_pa)->sin_addr.s_addr = htonl(nid);
144 rc = inet_ioctl(kgnilnd_data.kgn_sock, SIOCGARP, (unsigned long)&req);
148 CDEBUG(D_NETERROR, "inet_ioctl returned %d\n", rc);
152 /* use the lower 18 bits of the mac address to use as a nid value */
153 *nicaddrs = *(__u32 *)&req.arp_ha.sa_data[2];
154 *nicaddrs = ntohl(*nicaddrs) & NID_MASK;
156 CDEBUG(D_NETTRACE, "nid %s -> nic 0x%x\n", libcfs_nid2str(nid),
163 kgnilnd_nicaddr_to_nid(__u32 nicaddr, __u32 *nid)
168 .ifr_name = "ipogif0",
171 struct sockaddr_in* ipaddr = (struct sockaddr_in*)&ifr.ifr_addr;
175 rc = inet_ioctl(kgnilnd_data.kgn_sock, SIOCGIFADDR, (unsigned long)&ifr);
179 CDEBUG(D_NETERROR, "inet_ioctl returned %d\n", rc);
183 CDEBUG(D_NETTRACE, "ipaddr %08x\n", htonl(ipaddr->sin_addr.s_addr));
185 *nid = htonl(ipaddr->sin_addr.s_addr);
186 CDEBUG(D_NETTRACE, "nic 0x%x -> nid %s\n", nicaddr,
187 libcfs_nid2str(*nid));
192 kgnilnd_setup_nic_translation(__u32 device_id)
197 #endif /* CONFIG_CRAY_XT */
199 #endif /* GNILND_USE_RCA */
201 #endif /* _GNILND_ARIES_H */