Whamcloud - gitweb
LU-1346 gnilnd: remove libcfs abstractions
[fs/lustre-release.git] / lnet / klnds / gnilnd / gnilnd_aries.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Copyright (C) 2009-2012 Cray, Inc.
5  *   Author: Nic Henke <nic@cray.com>, James Shimek <jshimek@cray.com>
6  *
7  *   This file is part of Lustre, http://www.lustre.org.
8  *
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.
12  *
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.
17  *
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.
21  *
22  */
23 #ifndef _GNILND_ARIES_H
24 #define _GNILND_ARIES_H
25
26 /* for libcfs_ipif_query */
27 #include <libcfs/libcfs.h>
28
29 #ifndef _GNILND_HSS_OPS_H
30 # error "must include gnilnd_hss_ops.h first"
31 #endif
32
33 /* Set HW related values */
34 #include <aries/aries_timeouts_gpl.h>
35
36 #define GNILND_BASE_TIMEOUT        TIMEOUT_SECS(TO_GNILND_timeout)
37 #define GNILND_CHECKSUM_DEFAULT    0            /* all off for Aries */
38
39 #if defined(CONFIG_CRAY_COMPUTE)
40 #define GNILND_REVERSE_RDMA        GNILND_REVERSE_PUT
41 #define GNILND_RDMA_DLVR_OPTION    GNI_DLVMODE_PERFORMANCE
42 #else
43 #define GNILND_REVERSE_RDMA        GNILND_REVERSE_GET
44 #define GNILND_RDMA_DLVR_OPTION    GNI_DLVMODE_PERFORMANCE
45 #endif
46
47 /* plug in our functions for use on the simulator */
48 #if !defined(GNILND_USE_RCA)
49
50 extern kgn_data_t kgnilnd_data;
51
52 #define kgnilnd_hw_hb()              do {} while(0)
53
54 /* Aries Sim doesn't have hardcoded tables, so we'll hijack the nic_pe
55  * and decode our address and nic addr from that - the rest are just offsets */
56
57 static inline int
58 kgnilnd_nid_to_nicaddrs(__u32 nid, int numnic, __u32 *nicaddr)
59 {
60         if (numnic > 1) {
61                 CERROR("manual nid2nic translation doesn't support"
62                        "multiple nic addrs (you asked for %d)\n",
63                         numnic);
64                 return -EINVAL;
65         }
66         if (nid < kgnilnd_data.kgn_nid_trans_private) {
67                 CERROR("Request for invalid nid translation %u, minimum %Lu\n",
68                        nid, kgnilnd_data.kgn_nid_trans_private);
69                 return -ESRCH;
70         }
71
72         *nicaddr = nid - kgnilnd_data.kgn_nid_trans_private;
73
74         CDEBUG(D_NETTRACE, "Sim nid %d -> nic 0x%x\n", nid, *nicaddr);
75
76         return 1;
77 }
78
79 static inline int
80 kgnilnd_nicaddr_to_nid(__u32 nicaddr, __u32 *nid)
81 {
82         *nid = kgnilnd_data.kgn_nid_trans_private + nicaddr;
83         return 1;
84 }
85
86 /* XXX Nic: This does not support multiple device!!!! */
87 static inline int
88 kgnilnd_setup_nic_translation(__u32 device_id)
89 {
90         char              *if_name = "ipogif0";
91         __u32              ipaddr, netmask, my_nid;
92         int                up, rc;
93
94         LCONSOLE_INFO("using Aries SIM IP info for RCA translation\n");
95
96         rc = libcfs_ipif_query(if_name, &up, &ipaddr, &netmask);
97         if (rc != 0) {
98                 CERROR ("can't get IP interface for %s: %d\n", if_name, rc);
99                 return rc;
100         }
101         if (!up) {
102                 CERROR ("IP interface %s is down\n", if_name);
103                 return -ENODEV;
104         }
105
106         my_nid = ((ipaddr >> 8) & 0xFF) + (ipaddr & 0xFF);
107
108         kgnilnd_data.kgn_nid_trans_private = my_nid - device_id;
109
110         return 0;
111 }
112
113 #endif /* GNILND_USE_RCA */
114
115 #endif /* _GNILND_ARIES_H */