1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
37 #define DEBUG_PORTAL_ALLOC
39 # define EXPORT_SYMTAB
42 #ifndef __LINUX_SOCKNAL_LIB_H__
43 #define __LINUX_SOCKNAL_LIB_H__
45 #ifndef AUTOCONF_INCLUDED
46 #include <linux/config.h>
48 #include <linux/module.h>
49 #include <linux/kernel.h>
50 #include <linux/version.h>
52 #include <linux/string.h>
53 #include <linux/stat.h>
54 #include <linux/errno.h>
55 #include <linux/smp_lock.h>
56 #include <linux/unistd.h>
59 #include <linux/uio.h>
61 #include <asm/system.h>
62 #include <asm/uaccess.h>
65 #include <linux/init.h>
67 #include <linux/file.h>
68 #include <linux/stat.h>
69 #include <linux/list.h>
70 #include <linux/kmod.h>
71 #include <linux/sysctl.h>
72 #include <asm/uaccess.h>
73 #include <asm/div64.h>
75 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
76 # include <linux/syscalls.h>
79 #include <libcfs/libcfs.h>
80 #include <libcfs/linux/portals_compat25.h>
82 #include <linux/crc32.h>
83 static inline __u32 ksocknal_csum(__u32 crc, unsigned char const *p, size_t len)
86 return crc32_le(crc, p, len);
89 crc = ((crc + 0x100) & ~0xff) | ((crc + *p++) & 0xff) ;
94 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,7))
95 # define SOCKNAL_WSPACE(sk) sk_stream_wspace(sk)
96 # define SOCKNAL_MIN_WSPACE(sk) sk_stream_min_wspace(sk)
98 # define SOCKNAL_WSPACE(sk) tcp_wspace(sk)
99 # define SOCKNAL_MIN_WSPACE(sk) (((sk)->sk_sndbuf*8)/10)
104 int ksocknal_nsched(void)
109 #include <linux/lustre_version.h>
110 # 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))
112 ksocknal_nsched(void)
114 return num_online_cpus();
118 ksocknal_sched2cpu(int i)
124 ksocknal_irqsched2cpu(int i)
130 ksocknal_nsched(void)
132 if (smp_num_siblings == 1)
133 return (num_online_cpus());
135 /* We need to know if this assumption is crap */
136 LASSERT (smp_num_siblings == 2);
137 return (num_online_cpus()/2);
141 ksocknal_sched2cpu(int i)
143 if (smp_num_siblings == 1)
150 ksocknal_irqsched2cpu(int i)
152 return (ksocknal_sched2cpu(i) + 1);