Whamcloud - gitweb
file jbd-stats-2.6.9.patch was initially added on branch b1_4.
[fs/lustre-release.git] / lnet / klnds / socklnd / socklnd_lib-linux.h
1 #define DEBUG_PORTAL_ALLOC
2 #ifndef EXPORT_SYMTAB
3 # define EXPORT_SYMTAB
4 #endif
5
6 #ifndef __LINUX_SOCKNAL_LIB_H__
7 #define __LINUX_SOCKNAL_LIB_H__
8
9 #include <linux/config.h>
10 #include <linux/module.h>
11 #include <linux/kernel.h>
12 #include <linux/version.h>
13 #include <linux/mm.h>
14 #include <linux/string.h>
15 #include <linux/stat.h>
16 #include <linux/errno.h>
17 #include <linux/smp_lock.h>
18 #include <linux/unistd.h>
19 #include <net/sock.h>
20 #include <net/tcp.h>
21 #include <linux/uio.h>
22                                                                                                                                                                          
23 #include <asm/system.h>
24 #include <asm/uaccess.h>
25 #include <asm/irq.h>
26                                                                                                                                                                          
27 #include <linux/init.h>
28 #include <linux/fs.h>
29 #include <linux/file.h>
30 #include <linux/stat.h>
31 #include <linux/list.h>
32 #include <linux/kmod.h>
33 #include <linux/sysctl.h>
34 #include <asm/uaccess.h>
35 #include <asm/segment.h>
36 #include <asm/div64.h>
37
38 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
39 # include <linux/syscalls.h>
40 #endif
41                                                                                                                                                                        
42 #include <libcfs/kp30.h>
43 #include <libcfs/linux/portals_compat25.h>
44
45 #define SOCKNAL_TX_LOW_WATER(sk) (((sk)->sk_sndbuf*8)/10)
46
47 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,72))
48 # define sk_allocation  allocation
49 # define sk_data_ready  data_ready
50 # define sk_write_space write_space
51 # define sk_user_data   user_data
52 # define sk_prot        prot
53 # define sk_sndbuf      sndbuf
54 # define sk_socket      socket
55 #endif
56
57 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
58 # define sk_wmem_queued wmem_queued
59 # define sk_err         err
60 #endif
61
62 #define SOCKNAL_ARCH_EAGER_ACK  0
63 #define SOCK_WMEM_QUEUED(so)    ((so)->sk->sk_wmem_queued)
64 #define SOCK_ERROR(so)          ((so)->sk->sk_err)
65 #define SOCK_TEST_NOSPACE(so)   test_bit(SOCK_NOSPACE, &(so)->flags)
66
67 #define KSN_SOCK2FILE(so)       ((so)->file)
68 #define KSN_CONN2FILE(conn)     ((conn)->ksnc_sock->file)
69
70 #ifndef CONFIG_SMP
71 static inline
72 int ksocknal_nsched(void)
73 {
74         return 1;
75 }
76 #else
77 #include <linux/lustre_version.h>
78 # if !(defined(CONFIG_X86) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,21))) || defined(CONFIG_X86_64) || (LUSTRE_KERNEL_VERSION < 39) || ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) && !defined(CONFIG_X86_HT))
79 static inline int
80 ksocknal_nsched(void)
81 {
82         return num_online_cpus();
83 }
84
85 static inline int
86 ksocknal_sched2cpu(int i)
87 {
88         return i;
89 }
90
91 static inline int
92 ksocknal_irqsched2cpu(int i)
93 {
94         return i;
95 }
96 # else
97 static inline int
98 ksocknal_nsched(void)
99 {
100         if (smp_num_siblings == 1)
101                 return (num_online_cpus());
102
103         /* We need to know if this assumption is crap */
104         LASSERT (smp_num_siblings == 2);
105         return (num_online_cpus()/2);
106 }
107
108 static inline int
109 ksocknal_sched2cpu(int i)
110 {
111         if (smp_num_siblings == 1)
112                 return i;
113
114         return (i * 2);
115 }
116
117 static inline int
118 ksocknal_irqsched2cpu(int i)
119 {
120         return (ksocknal_sched2cpu(i) + 1);
121 }
122 # endif
123 #endif
124
125 #endif