1 #define DEBUG_PORTAL_ALLOC
6 #ifndef __LINUX_SOCKNAL_LIB_H__
7 #define __LINUX_SOCKNAL_LIB_H__
9 #include <linux/config.h>
10 #include <linux/module.h>
11 #include <linux/kernel.h>
12 #include <linux/version.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>
21 #include <linux/uio.h>
23 #include <asm/system.h>
24 #include <asm/uaccess.h>
27 #include <linux/init.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>
38 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
39 # include <linux/syscalls.h>
42 #include <libcfs/kp30.h>
43 #include <libcfs/linux/portals_compat25.h>
45 #define SOCKNAL_TX_LOW_WATER(sk) (((sk)->sk_sndbuf*8)/10)
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
53 # define sk_sndbuf sndbuf
54 # define sk_socket socket
57 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
58 # define sk_wmem_queued wmem_queued
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)
67 #define KSN_SOCK2FILE(so) ((so)->file)
68 #define KSN_CONN2FILE(conn) ((conn)->ksnc_sock->file)
72 int ksocknal_nsched(void)
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))
82 return num_online_cpus();
86 ksocknal_sched2cpu(int i)
92 ksocknal_irqsched2cpu(int i)
100 if (smp_num_siblings == 1)
101 return (num_online_cpus());
103 /* We need to know if this assumption is crap */
104 LASSERT (smp_num_siblings == 2);
105 return (num_online_cpus()/2);
109 ksocknal_sched2cpu(int i)
111 if (smp_num_siblings == 1)
118 ksocknal_irqsched2cpu(int i)
120 return (ksocknal_sched2cpu(i) + 1);