Whamcloud - gitweb
Landing b_hd_newconfig on HEAD
[fs/lustre-release.git] / lnet / include / lnet / linux / lib-lnet.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  */
4 #ifndef __LNET_LINUX_LIB_LNET_H__
5 #define __LNET_LINUX_LIB_LNET_H__
6
7 #ifndef __LNET_LIB_LNET_H__
8 #error Do not #include this file directly. #include <lnet/lib-lnet.h> instead
9 #endif
10
11 #ifdef __KERNEL__
12 # include <asm/page.h>
13 # include <linux/string.h>
14 # include <asm/io.h>
15 # include <libcfs/kp30.h>
16
17 static inline __u64
18 lnet_page2phys (struct page *p)
19 {
20         /* compiler optimizer will elide unused branches */
21
22         switch (sizeof(typeof(page_to_phys(p)))) {
23         case 4:
24                 /* page_to_phys returns a 32 bit physical address.  This must
25                  * be a 32 bit machine with <= 4G memory and we must ensure we
26                  * don't sign extend when converting to 64 bits. */
27                 return (unsigned long)page_to_phys(p);
28
29         case 8:
30                 /* page_to_phys returns a 64 bit physical address :) */
31                 return page_to_phys(p);
32                 
33         default:
34                 LBUG();
35                 return 0;
36         }
37 }
38
39 #else  /* __KERNEL__ */
40 # include <libcfs/list.h>
41 # include <string.h>
42 # ifdef HAVE_LIBPTHREAD
43 #  include <pthread.h>
44 # endif
45 #endif
46
47 #define LNET_ROUTER
48
49 #endif /* __LNET_LINUX_LIB_LNET_H__ */