1 #define DEBUG_PORTAL_ALLOC
6 #ifndef __LINUX_SOCKNAL_LIB_H__
7 #define __LINUX_SOCKNAL_LIB_H__
9 #ifndef AUTOCONF_INCLUDED
10 #include <linux/config.h>
12 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/version.h>
16 #include <linux/string.h>
17 #include <linux/stat.h>
18 #include <linux/errno.h>
19 #include <linux/smp_lock.h>
20 #include <linux/unistd.h>
23 #include <linux/uio.h>
25 #include <asm/system.h>
26 #include <asm/uaccess.h>
29 #include <linux/init.h>
31 #include <linux/file.h>
32 #include <linux/stat.h>
33 #include <linux/list.h>
34 #include <linux/kmod.h>
35 #include <linux/sysctl.h>
36 #include <asm/uaccess.h>
37 #include <asm/segment.h>
38 #include <asm/div64.h>
40 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
41 # include <linux/syscalls.h>
44 #include <libcfs/kp30.h>
45 #include <libcfs/linux/portals_compat25.h>
47 #include <linux/crc32.h>
48 static inline __u32 ksocknal_csum(__u32 crc, unsigned char const *p, size_t len)
51 return crc32_le(crc, p, len);
54 crc = ((crc + 0x100) & ~0xff) | ((crc + *p++) & 0xff) ;
59 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,7))
60 # define SOCKNAL_WSPACE(sk) sk_stream_wspace(sk)
61 # define SOCKNAL_MIN_WSPACE(sk) sk_stream_min_wspace(sk)
63 # define SOCKNAL_WSPACE(sk) tcp_wspace(sk)
64 # define SOCKNAL_MIN_WSPACE(sk) (((sk)->sk_sndbuf*8)/10)
69 int ksocknal_nsched(void)
74 #include <linux/lustre_version.h>
75 # if !(defined(CONFIG_X86) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,21))) || defined(CONFIG_X86_64) || ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) && !defined(CONFIG_X86_HT))
79 return num_online_cpus();
83 ksocknal_sched2cpu(int i)
89 ksocknal_irqsched2cpu(int i)
97 if (smp_num_siblings == 1)
98 return (num_online_cpus());
100 /* We need to know if this assumption is crap */
101 LASSERT (smp_num_siblings == 2);
102 return (num_online_cpus()/2);
106 ksocknal_sched2cpu(int i)
108 if (smp_num_siblings == 1)
115 ksocknal_irqsched2cpu(int i)
117 return (ksocknal_sched2cpu(i) + 1);