Whamcloud - gitweb
Landing b_hd_newconfig on HEAD
authornathan <nathan>
Sat, 10 Feb 2007 00:05:05 +0000 (00:05 +0000)
committernathan <nathan>
Sat, 10 Feb 2007 00:05:05 +0000 (00:05 +0000)
349 files changed:
lnet/ChangeLog
lnet/Kernelenv.in
lnet/Kernelenv.mk
lnet/Makefile.in
lnet/autoMakefile.am
lnet/autoconf/Makefile.am
lnet/autoconf/lustre-lnet.m4
lnet/include/Makefile.am
lnet/include/libcfs/Makefile.am
lnet/include/libcfs/curproc.h
lnet/include/libcfs/darwin/Makefile.am
lnet/include/libcfs/darwin/darwin-fs.h
lnet/include/libcfs/darwin/darwin-lock.h
lnet/include/libcfs/darwin/darwin-mem.h
lnet/include/libcfs/darwin/darwin-prim.h
lnet/include/libcfs/darwin/darwin-sync.h
lnet/include/libcfs/darwin/darwin-tcpip.h [new file with mode: 0644]
lnet/include/libcfs/darwin/darwin-time.h
lnet/include/libcfs/darwin/darwin-types.h
lnet/include/libcfs/darwin/darwin-utils.h
lnet/include/libcfs/darwin/kp30.h
lnet/include/libcfs/darwin/libcfs.h
lnet/include/libcfs/darwin/lltrace.h
lnet/include/libcfs/kp30.h
lnet/include/libcfs/libcfs.h
lnet/include/libcfs/linux/Makefile.am
lnet/include/libcfs/linux/kp30.h
lnet/include/libcfs/linux/libcfs.h
lnet/include/libcfs/linux/linux-fs.h
lnet/include/libcfs/linux/linux-lock.h
lnet/include/libcfs/linux/linux-mem.h
lnet/include/libcfs/linux/linux-prim.h
lnet/include/libcfs/linux/linux-tcpip.h [new file with mode: 0644]
lnet/include/libcfs/linux/linux-time.h
lnet/include/libcfs/linux/lltrace.h
lnet/include/libcfs/linux/portals_compat25.h
lnet/include/libcfs/linux/portals_utils.h
lnet/include/libcfs/list.h
lnet/include/libcfs/lltrace.h
lnet/include/libcfs/portals_lib.h [deleted file]
lnet/include/libcfs/portals_utils.h
lnet/include/libcfs/types.h [new file with mode: 0755]
lnet/include/libcfs/user-lock.h
lnet/include/libcfs/user-prim.h
lnet/include/libcfs/user-time.h
lnet/include/libcfs/winnt/kp30.h [new file with mode: 0644]
lnet/include/libcfs/winnt/libcfs.h [new file with mode: 0644]
lnet/include/libcfs/winnt/lltrace.h [moved from lnet/include/libcfs/darwin/portals_lib.h with 69% similarity]
lnet/include/libcfs/winnt/portals_compat25.h [moved from lnet/include/libcfs/linux/portals_lib.h with 65% similarity]
lnet/include/libcfs/winnt/portals_utils.h [new file with mode: 0644]
lnet/include/libcfs/winnt/winnt-fs.h [new file with mode: 0644]
lnet/include/libcfs/winnt/winnt-lock.h [new file with mode: 0644]
lnet/include/libcfs/winnt/winnt-mem.h [new file with mode: 0644]
lnet/include/libcfs/winnt/winnt-prim.h [new file with mode: 0644]
lnet/include/libcfs/winnt/winnt-tcpip.h [new file with mode: 0644]
lnet/include/libcfs/winnt/winnt-time.h [new file with mode: 0644]
lnet/include/libcfs/winnt/winnt-types.h [new file with mode: 0644]
lnet/include/lnet/Makefile.am
lnet/include/lnet/api-support.h
lnet/include/lnet/api.h
lnet/include/lnet/build_check.h [deleted file]
lnet/include/lnet/darwin/Makefile.am
lnet/include/lnet/darwin/api-support.h [new file with mode: 0644]
lnet/include/lnet/darwin/lib-lnet.h
lnet/include/lnet/darwin/lib-p30.h [deleted file]
lnet/include/lnet/darwin/lib-types.h
lnet/include/lnet/darwin/lnet.h
lnet/include/lnet/darwin/p30.h [deleted file]
lnet/include/lnet/errno.h [deleted file]
lnet/include/lnet/internal.h [deleted file]
lnet/include/lnet/kpr.h [deleted file]
lnet/include/lnet/lib-lnet.h
lnet/include/lnet/lib-p30.h [deleted file]
lnet/include/lnet/lib-types.h
lnet/include/lnet/linux/Makefile.am
lnet/include/lnet/linux/api-support.h [new file with mode: 0644]
lnet/include/lnet/linux/lib-lnet.h
lnet/include/lnet/linux/lib-p30.h [deleted file]
lnet/include/lnet/linux/lib-types.h
lnet/include/lnet/linux/lnet.h
lnet/include/lnet/linux/p30.h [deleted file]
lnet/include/lnet/lnet.h
lnet/include/lnet/lnetctl.h
lnet/include/lnet/myrnal.h [deleted file]
lnet/include/lnet/nal.h [deleted file]
lnet/include/lnet/nalids.h [deleted file]
lnet/include/lnet/p30.h [deleted file]
lnet/include/lnet/ptlctl.h [deleted file]
lnet/include/lnet/ptllnd.h [new file with mode: 0755]
lnet/include/lnet/ptllnd_wire.h [new file with mode: 0644]
lnet/include/lnet/socklnd.h
lnet/include/lnet/stringtab.h [deleted file]
lnet/include/lnet/types.h
lnet/include/lnet/winnt/api-support.h [new file with mode: 0644]
lnet/include/lnet/winnt/lib-lnet.h [new file with mode: 0644]
lnet/include/lnet/winnt/lib-types.h [new file with mode: 0644]
lnet/include/lnet/winnt/lnet.h [new file with mode: 0644]
lnet/klnds/Makefile.in
lnet/klnds/autoMakefile.am
lnet/klnds/ciblnd/.cvsignore [moved from lnet/klnds/lolnd/.cvsignore with 100% similarity]
lnet/klnds/ciblnd/Makefile.in [new file with mode: 0644]
lnet/klnds/ciblnd/autoMakefile.am [moved from lnet/klnds/lolnd/autoMakefile.am with 54% similarity]
lnet/klnds/ciblnd/ciblnd.c [new file with mode: 0644]
lnet/klnds/ciblnd/ciblnd_cb.c [new file with mode: 0644]
lnet/klnds/ciblnd/ciblnd_modparams.c [new file with mode: 0644]
lnet/klnds/gmlnd/Makefile.in
lnet/klnds/gmlnd/README [new file with mode: 0644]
lnet/klnds/gmlnd/autoMakefile.am
lnet/klnds/gmlnd/gm-reg-phys.patch [new file with mode: 0644]
lnet/klnds/gmlnd/gmlnd.h
lnet/klnds/gmlnd/gmlnd_api.c
lnet/klnds/gmlnd/gmlnd_cb.c
lnet/klnds/gmlnd/gmlnd_comm.c
lnet/klnds/gmlnd/gmlnd_module.c
lnet/klnds/gmlnd/gmlnd_utils.c
lnet/klnds/iiblnd/Makefile.in
lnet/klnds/iiblnd/autoMakefile.am
lnet/klnds/iiblnd/iiblnd.c
lnet/klnds/iiblnd/iiblnd.h
lnet/klnds/iiblnd/iiblnd_cb.c
lnet/klnds/iiblnd/iiblnd_modparams.c [new file with mode: 0644]
lnet/klnds/lolnd/Makefile.in [deleted file]
lnet/klnds/lolnd/lolnd.c [deleted file]
lnet/klnds/lolnd/lolnd.h [deleted file]
lnet/klnds/lolnd/lolnd_cb.c [deleted file]
lnet/klnds/mxlnd/.cvsignore [new file with mode: 0644]
lnet/klnds/mxlnd/Makefile.in [new file with mode: 0644]
lnet/klnds/mxlnd/README [new file with mode: 0644]
lnet/klnds/mxlnd/autoMakefile.am [moved from lnet/router/autoMakefile.am with 52% similarity]
lnet/klnds/mxlnd/mxlnd.c [new file with mode: 0644]
lnet/klnds/mxlnd/mxlnd.h [new file with mode: 0644]
lnet/klnds/mxlnd/mxlnd_cb.c [new file with mode: 0644]
lnet/klnds/mxlnd/mxlnd_modparams.c [new file with mode: 0644]
lnet/klnds/mxlnd/mxlnd_wire.h [new file with mode: 0644]
lnet/klnds/o2iblnd/.cvsignore [new file with mode: 0644]
lnet/klnds/o2iblnd/Makefile.in [new file with mode: 0644]
lnet/klnds/o2iblnd/autoMakefile.am [new file with mode: 0644]
lnet/klnds/o2iblnd/o2iblnd.c [new file with mode: 0644]
lnet/klnds/o2iblnd/o2iblnd.h [new file with mode: 0644]
lnet/klnds/o2iblnd/o2iblnd_cb.c [new file with mode: 0644]
lnet/klnds/o2iblnd/o2iblnd_modparams.c [new file with mode: 0644]
lnet/klnds/openiblnd/Makefile.in
lnet/klnds/openiblnd/autoMakefile.am
lnet/klnds/openiblnd/openiblnd.c
lnet/klnds/openiblnd/openiblnd.h
lnet/klnds/openiblnd/openiblnd_cb.c
lnet/klnds/openiblnd/openiblnd_modparams.c [new file with mode: 0644]
lnet/klnds/ptllnd/.cvsignore [new file with mode: 0644]
lnet/klnds/ptllnd/Makefile.in [new file with mode: 0755]
lnet/klnds/ptllnd/README [new file with mode: 0644]
lnet/klnds/ptllnd/autoMakefile.am [new file with mode: 0755]
lnet/klnds/ptllnd/ptllnd.c [new file with mode: 0755]
lnet/klnds/ptllnd/ptllnd.h [new file with mode: 0755]
lnet/klnds/ptllnd/ptllnd_cb.c [new file with mode: 0644]
lnet/klnds/ptllnd/ptllnd_modparams.c [new file with mode: 0644]
lnet/klnds/ptllnd/ptllnd_peer.c [new file with mode: 0644]
lnet/klnds/ptllnd/ptllnd_ptltrace.c [new file with mode: 0644]
lnet/klnds/ptllnd/ptllnd_rx_buf.c [new file with mode: 0644]
lnet/klnds/ptllnd/ptllnd_tx.c [new file with mode: 0644]
lnet/klnds/ptllnd/wirecheck.c [new file with mode: 0644]
lnet/klnds/qswlnd/Makefile.in
lnet/klnds/qswlnd/autoMakefile.am
lnet/klnds/qswlnd/qswlnd.c
lnet/klnds/qswlnd/qswlnd.h
lnet/klnds/qswlnd/qswlnd_cb.c
lnet/klnds/qswlnd/qswlnd_modparams.c [new file with mode: 0644]
lnet/klnds/ralnd/Makefile.in
lnet/klnds/ralnd/autoMakefile.am
lnet/klnds/ralnd/ralnd.c
lnet/klnds/ralnd/ralnd.h
lnet/klnds/ralnd/ralnd_cb.c
lnet/klnds/ralnd/ralnd_modparams.c [new file with mode: 0644]
lnet/klnds/socklnd/Info.plist
lnet/klnds/socklnd/Makefile.in
lnet/klnds/socklnd/autoMakefile.am
lnet/klnds/socklnd/socklnd.c
lnet/klnds/socklnd/socklnd.h
lnet/klnds/socklnd/socklnd_cb.c
lnet/klnds/socklnd/socklnd_lib-darwin.c
lnet/klnds/socklnd/socklnd_lib-darwin.h
lnet/klnds/socklnd/socklnd_lib-linux.c
lnet/klnds/socklnd/socklnd_lib-linux.h
lnet/klnds/socklnd/socklnd_lib-winnt.c [new file with mode: 0755]
lnet/klnds/socklnd/socklnd_lib-winnt.h [new file with mode: 0755]
lnet/klnds/socklnd/socklnd_modparams.c [new file with mode: 0644]
lnet/klnds/viblnd/Makefile.in
lnet/klnds/viblnd/autoMakefile.am
lnet/klnds/viblnd/viblnd.c
lnet/klnds/viblnd/viblnd.h
lnet/klnds/viblnd/viblnd_cb.c
lnet/klnds/viblnd/viblnd_modparams.c [new file with mode: 0644]
lnet/klnds/viblnd/viblnd_wire.h
lnet/klnds/viblnd/wirecheck.c
lnet/libcfs/Info.plist
lnet/libcfs/Makefile.in
lnet/libcfs/autoMakefile.am
lnet/libcfs/darwin/Makefile.am
lnet/libcfs/darwin/darwin-curproc.c
lnet/libcfs/darwin/darwin-debug.c
lnet/libcfs/darwin/darwin-fs.c
lnet/libcfs/darwin/darwin-internal.h [new file with mode: 0644]
lnet/libcfs/darwin/darwin-mem.c
lnet/libcfs/darwin/darwin-module.c
lnet/libcfs/darwin/darwin-prim.c
lnet/libcfs/darwin/darwin-proc.c
lnet/libcfs/darwin/darwin-sync.c
lnet/libcfs/darwin/darwin-tcpip.c [new file with mode: 0644]
lnet/libcfs/darwin/darwin-tracefile.c
lnet/libcfs/darwin/darwin-utils.c
lnet/libcfs/debug.c
lnet/libcfs/linux/Makefile.am
lnet/libcfs/linux/linux-curproc.c
lnet/libcfs/linux/linux-debug.c
lnet/libcfs/linux/linux-fs.c
lnet/libcfs/linux/linux-lock.c
lnet/libcfs/linux/linux-lwt.c
lnet/libcfs/linux/linux-mem.c
lnet/libcfs/linux/linux-module.c
lnet/libcfs/linux/linux-prim.c
lnet/libcfs/linux/linux-proc.c
lnet/libcfs/linux/linux-sync.c
lnet/libcfs/linux/linux-tcpip.c [new file with mode: 0644]
lnet/libcfs/linux/linux-tracefile.c
lnet/libcfs/linux/linux-utils.c
lnet/libcfs/lwt.c
lnet/libcfs/misc.c [new file with mode: 0644]
lnet/libcfs/module.c
lnet/libcfs/nidstrings.c [new file with mode: 0644]
lnet/libcfs/tracefile.c
lnet/libcfs/tracefile.h
lnet/libcfs/user-lock.c
lnet/libcfs/user-prim.c
lnet/libcfs/watchdog.c
lnet/libcfs/winnt/winnt-curproc.c [new file with mode: 0644]
lnet/libcfs/winnt/winnt-debug.c [new file with mode: 0644]
lnet/libcfs/winnt/winnt-fs.c [new file with mode: 0644]
lnet/libcfs/winnt/winnt-lock.c [new file with mode: 0644]
lnet/libcfs/winnt/winnt-lwt.c [new file with mode: 0644]
lnet/libcfs/winnt/winnt-mem.c [new file with mode: 0644]
lnet/libcfs/winnt/winnt-module.c [new file with mode: 0644]
lnet/libcfs/winnt/winnt-prim.c [new file with mode: 0644]
lnet/libcfs/winnt/winnt-proc.c [new file with mode: 0644]
lnet/libcfs/winnt/winnt-sync.c [new file with mode: 0644]
lnet/libcfs/winnt/winnt-tcpip.c [new file with mode: 0644]
lnet/libcfs/winnt/winnt-tracefile.c [new file with mode: 0644]
lnet/libcfs/winnt/winnt-usr.c [new file with mode: 0644]
lnet/libcfs/winnt/winnt-utils.c [new file with mode: 0644]
lnet/lnet/Info.plist
lnet/lnet/Makefile.in
lnet/lnet/acceptor.c [new file with mode: 0644]
lnet/lnet/api-errno.c
lnet/lnet/api-ni.c
lnet/lnet/api-wrap.c [deleted file]
lnet/lnet/autoMakefile.am
lnet/lnet/config.c [new file with mode: 0644]
lnet/lnet/lib-eq.c
lnet/lnet/lib-init.c [deleted file]
lnet/lnet/lib-md.c
lnet/lnet/lib-me.c
lnet/lnet/lib-move.c
lnet/lnet/lib-msg.c
lnet/lnet/lib-ni.c [deleted file]
lnet/lnet/lib-pid.c [deleted file]
lnet/lnet/lo.c [new file with mode: 0644]
lnet/lnet/module.c
lnet/lnet/peer.c [new file with mode: 0644]
lnet/lnet/router.c [new file with mode: 0644]
lnet/lnet/router_proc.c [new file with mode: 0644]
lnet/router/Makefile.in [deleted file]
lnet/router/proc.c [deleted file]
lnet/router/router.c [deleted file]
lnet/router/router.h [deleted file]
lnet/tests/Makefile.in
lnet/tests/autoMakefile.am
lnet/tests/ping.h
lnet/tests/ping_cli.c
lnet/tests/ping_cli/Info.plist
lnet/tests/ping_cli/winnt-pingcli.c [new file with mode: 0644]
lnet/tests/ping_srv.c
lnet/tests/ping_srv/Info.plist
lnet/tests/ping_srv/winnt-pingsrv.c [new file with mode: 0644]
lnet/tests/sping_cli.c [deleted file]
lnet/tests/sping_srv.c [deleted file]
lnet/tests/startclient.sh
lnet/tests/startserver.sh
lnet/tests/stopclient.sh
lnet/tests/stopserver.sh
lnet/tests/ut.README [new file with mode: 0644]
lnet/tests/ut.h [new file with mode: 0644]
lnet/tests/ut_cli.c [new file with mode: 0644]
lnet/tests/ut_srv.c [new file with mode: 0644]
lnet/ulnds/.cvsignore
lnet/ulnds/Makefile.am [deleted file]
lnet/ulnds/Makefile.in [new file with mode: 0644]
lnet/ulnds/README [deleted file]
lnet/ulnds/address.c [deleted file]
lnet/ulnds/autoMakefile.am [new file with mode: 0644]
lnet/ulnds/bridge.h [deleted file]
lnet/ulnds/connection.c [deleted file]
lnet/ulnds/connection.h [deleted file]
lnet/ulnds/debug.c [deleted file]
lnet/ulnds/dispatch.h [deleted file]
lnet/ulnds/ipmap.h [deleted file]
lnet/ulnds/pqtimer.c [deleted file]
lnet/ulnds/pqtimer.h [deleted file]
lnet/ulnds/procapi.c [deleted file]
lnet/ulnds/procbridge.h [deleted file]
lnet/ulnds/proclib.c [deleted file]
lnet/ulnds/ptllnd/.cvsignore [new file with mode: 0644]
lnet/ulnds/ptllnd/Makefile.am [new file with mode: 0644]
lnet/ulnds/ptllnd/ptllnd.c [new file with mode: 0644]
lnet/ulnds/ptllnd/ptllnd.h [new file with mode: 0644]
lnet/ulnds/ptllnd/ptllnd_cb.c [new file with mode: 0644]
lnet/ulnds/select.c [deleted file]
lnet/ulnds/socklnd/.cvsignore [new file with mode: 0644]
lnet/ulnds/socklnd/Makefile.am
lnet/ulnds/socklnd/address.c [deleted file]
lnet/ulnds/socklnd/bridge.h
lnet/ulnds/socklnd/connection.c
lnet/ulnds/socklnd/connection.h
lnet/ulnds/socklnd/debug.c [deleted file]
lnet/ulnds/socklnd/dispatch.h
lnet/ulnds/socklnd/ipmap.h [deleted file]
lnet/ulnds/socklnd/procapi.c
lnet/ulnds/socklnd/procbridge.h
lnet/ulnds/socklnd/proclib.c
lnet/ulnds/socklnd/select.c
lnet/ulnds/socklnd/table.c
lnet/ulnds/socklnd/table.h
lnet/ulnds/socklnd/tcplnd.c
lnet/ulnds/socklnd/utypes.h [deleted file]
lnet/ulnds/table.c [deleted file]
lnet/ulnds/table.h [deleted file]
lnet/ulnds/tcplnd.c [deleted file]
lnet/ulnds/timer.h [deleted file]
lnet/ulnds/utypes.h [deleted file]
lnet/utils/.cvsignore
lnet/utils/Makefile.am
lnet/utils/acceptor.c [deleted file]
lnet/utils/debug.c
lnet/utils/debugctl.c
lnet/utils/gmlndnid.c
lnet/utils/l_ioctl.c
lnet/utils/lbstats [new file with mode: 0755]
lnet/utils/parser.c
lnet/utils/portals.c
lnet/utils/ptlctl.c
lnet/utils/routerstat.c
lnet/utils/wirecheck.c

index fed4790..79ca961 100644 (file)
@@ -1,4 +1,204 @@
-tba  Cluster File Systems, Inc. <info@clusterfs.com>
+TBD         Cluster File Systems, Inc. <info@clusterfs.com>
+       * version 1.4.10
+       * Support for networks:
+       socklnd   - kernels up to 2.6.15 (I believe this is accurate, SLES10)
+       qswlnd    - Qsnet kernel modules 5.20 and later
+       openiblnd - IbGold 1.8.2
+       o2iblnd   - OFED 1.1
+       viblnd    - Voltaire ibhost 3.4.5 and later
+       ciblnd    - Topspin 3.2.0
+       iiblnd    - Infiniserv 3.3 + PathBits patch
+       gmlnd     - GM 2.1.22 and later
+       mxlnd     - MX 1.2.1 or later
+       ptllnd    - Portals 3.3 / UNICOS/lc 1.5.x, 2.0.x
+       * bug fixes
+
+Severity   : major
+Frequency  : rare      
+Bugzilla   : 11616
+Description: o2iblnd handle early RDMA_CM_EVENT_DISCONNECTED.
+Details    : If the fabric is lossy, an RDMA_CM_EVENT_DISCONNECTED
+            callback can occur before a connection has actually been
+            established.  This caused an assertion failure previously.
+
+Severity   : enhancement
+Bugzilla   : 11094
+Description: Multiple instances for o2iblnd
+Details    : Allow multiple instances of o2iblnd to enable networking over
+            multiple HCAs and routing between them.
+
+Severity   : major
+Bugzilla   : 11201
+Description: lnet deadlock in router_checker
+Details    : turned ksnd_connd_lock, ksnd_reaper_lock, and ksock_net_t:ksnd_lock
+            into BH locks to eliminate potential deadlock caused by
+            ksocknal_data_ready() preempting code holding these locks.
+
+Severity   : major
+Bugzilla   : 11126
+Description: Millions of failed socklnd connection attempts cause a very slow FS
+Details    : added a new route flag ksnr_scheduled to distinguish from
+            ksnr_connecting, so that a peer connection request is only turned
+            down for race concerns when an active connection to the same peer
+            is under progress (instead of just being scheduled).
+
+------------------------------------------------------------------------------
+
+2007-02-09  Cluster File Systems, Inc. <info@clusterfs.com>
+       * version 1.4.9
+       * Support for networks:
+       socklnd   - kernels up to 2.6.15 (I believe this is accurate, SLES10)
+       qswlnd    - Qsnet kernel modules 5.20 and later
+       openiblnd - IbGold 1.8.2
+       o2iblnd   - OFED 1.1
+       viblnd    - Voltaire ibhost 3.4.5 and later
+       ciblnd    - Topspin 3.2.0
+       iiblnd    - Infiniserv 3.3 + PathBits patch
+       gmlnd     - GM 2.1.22 and later
+       mxlnd     - MX 1.2.1 or later
+       ptllnd    - Portals 3.3 / UNICOS/lc 1.5.x, 2.0.x
+       * bug fixes
+
+Severity   : major on XT3
+Bugzilla   : none
+Description: libcfs overwrites /proc/sys/portals
+Details    : libcfs created a symlink from /proc/sys/portals to
+            /proc/sys/lnet for backwards compatibility.  This is no
+            longer required and makes the Cray portals /proc variables
+            inaccessible.
+            
+Severity   : minor
+Bugzilla   : 11312
+Description: OFED FMR API change
+Details    : This changes parameter usage to reflect a change in
+            ib_fmr_pool_map_phys() between OFED 1.0 and OFED 1.1.  Note
+            that FMR support is only used in experimental versions of the
+            o2iblnd - this change does not affect standard usage at all.
+            
+Severity   : enhancement
+Bugzilla   : 11245
+Description: new ko2iblnd module parameter: ib_mtu
+Details    : the default IB MTU of 2048 performs badly on 23108 Tavor
+            HCAs.  You can avoid this problem by setting the MTU to 1024
+            using this module parameter.
+            
+Severity   : enhancement
+Bugzilla   : 11118/11620
+Description: ptllnd small request message buffer alignment fix
+Details    : Set the PTL_MD_LOCAL_ALIGN8 option on small message receives.
+            Round up small message size on sends in case this option
+            is not supported.  11620 was a defect in the initial
+            implementation which effectively asserted all peers had to be
+            running the correct protocol version which was fixed by always
+            NAK-ing such requests and handling any misalignments they
+            introduce.
+            
+Severity   : minor
+Frequency  : rarely
+Description: When kib(nal|lnd)_del_peer() is called upon a peer whose
+            ibp_tx_queue is not empty, kib(nal|lnd)_destroy_peer()'s
+            'LASSERT(list_empty(&peer->ibp_tx_queue))' will fail.
+
+Severity   : enhancement
+Bugzilla   : 11250
+Description: Patchless ZC(zero copy) socklnd
+Details    : New protocol for socklnd, socklnd can support zero copy without
+            kernel patch, it's compatible with old socklnd. Checksum is 
+            moved from tunables to modparams.
+
+Severity   : minor
+Frequency  : rarely
+Description: When ksocknal_del_peer() is called upon a peer whose
+            ksnp_tx_queue is not empty, ksocknal_destroy_peer()'s
+            'LASSERT(list_empty(&peer->ksnp_tx_queue))' will fail.
+
+Severity   : normal
+Frequency  : when ptlrpc is under heavy use and runs out of request buffer
+Bugzilla   : 11318
+Description: In lnet_match_blocked_msg(), md can be used without holding a
+            ref on it.
+
+Severity   : minor
+Frequency  : very rarely
+Bugzilla   : 10727
+Description: If ksocknal_lib_setup_sock() fails, a ref on peer is lost.
+            If connd connects a route which has been closed by
+            ksocknal_shutdown(), ksocknal_create_routes() may create new
+            routes which hold references on the peer, causing shutdown
+            process to wait for peer to disappear forever.
+
+Severity   : enhancement
+Bugzilla   : 11234
+Description: Dump XT3 portals traces on kptllnd timeout
+Details    : Set the kptllnd module parameter "ptltrace_on_timeout=1" to
+            dump Cray portals debug traces to a file.  The kptllnd module
+            parameter "ptltrace_basename", default "/tmp/lnet-ptltrace",
+            is the basename of the dump file.
+       
+Severity   : major
+Frequency  : infrequent
+Bugzilla   : 11308
+Description: kernel ptllnd fix bug in connection re-establishment
+Details    : Kernel ptllnd could produce protocol errors e.g. illegal
+            matchbits and/or violate the credit flow protocol when trying
+            to re-establish a connection with a peer after an error or
+            timeout. 
+       
+Severity   : enhancement
+Bugzilla   : 10316
+Description: Allow /proc/sys/lnet/debug to be set symbolically
+Details    : Allow debug and subsystem debug values to be read/set by name
+            in addition to numerically, for ease of use.
+
+Severity   : normal
+Frequency  : only in configurations with LNET routers
+Bugzilla   : 10316
+Description: routes automatically marked down and recovered
+Details    : In configurations with LNET routers if a router fails routers
+            now actively try to recover routes that are down, unless they
+            are marked down by an administrator.
+
+------------------------------------------------------------------------------
+
+2006-07-31  Cluster File Systems, Inc. <info@clusterfs.com>
+       * version 1.4.7
+       - rework CDEBUG messages rate-limiting mechanism b=10375
+       - add per-socket tunables for socklnd if the kernel is patched b=10327
+
+------------------------------------------------------------------------------
+
+2006-02-15  Cluster File Systems, Inc. <info@clusterfs.com>
+       * version 1.4.6
+       - fix use of portals/lnet pid to avoid dropping RPCs b=10074
+       - iiblnd wasn't mapping all memory, resulting in comms errors b=9776
+       - quiet LNET startup LNI message for liblustre b=10128
+       - Better console error messages if 'ip2nets' can't match an IP address
+       - Fixed overflow/use-before-set bugs in linux-time.h
+       - Fixed ptllnd bug that wasn't initialising rx descriptors completely
+       - LNET teardown failed an assertion about the route table being empty
+       - Fixed a crash in LNetEQPoll(<invalid handle>)
+       - Future protocol compatibility work (b_rls146_lnetprotovrsn)
+       - improve debug message for liblustre/Catamount nodes (b=10116)
+
+2005-10-10  Cluster File Systems, Inc. <info@clusterfs.com>
+       * Configuration change for the XT3
+            The PTLLND is now used to run Lustre over Portals on the XT3.
+            The configure option(s) --with-cray-portals are no longer
+            used.  Rather --with-portals=<path-to-portals-includes> is
+            used to enable building on the XT3.  In addition to enable
+            XT3 specific features the option --enable-cray-xt3 must be
+            used.
+
+2005-10-10  Cluster File Systems, Inc. <info@clusterfs.com>
+       * Portals has been removed, replaced by LNET.
+          LNET is new networking infrastructure for Lustre, it includes a
+          reorganized network configuration mode (see the user
+          documentation for full details) as well as support for routing
+          between different network fabrics.  Lustre Networking Devices
+          (LNDS) for the supported network fabrics have also been created
+          for this new infrastructure.
+       
+2005-08-08  Cluster File Systems, Inc. <info@clusterfs.com>
        * version 1.4.4
        * bug fixes
 
@@ -6,9 +206,9 @@ Severity   : major
 Frequency  : rare (large Voltaire clusters only)
 Bugzilla   : 6993
 Description: the default number of reserved transmit descriptors was too low
-             for some large clusters
+            for some large clusters
 Details    : As a workaround, the number was increased.  A proper fix includes
-             a run-time tunable.
+            a run-time tunable.
 
 2005-06-02  Cluster File Systems, Inc. <info@clusterfs.com>
        * version 1.4.3
@@ -18,14 +218,14 @@ Severity   : major
 Frequency  : occasional (large-scale events, cluster reboot, network failure)
 Bugzilla   : 6411
 Description: too many error messages on console obscure actual problem and
-             can slow down/panic server, or cause recovery to fail repeatedly
+            can slow down/panic server, or cause recovery to fail repeatedly
 Details    : enable rate-limiting of console error messages, and some messages
-             that were console errors now only go to the kernel log
+            that were console errors now only go to the kernel log
 
 Severity   : enhancement
 Bugzilla   : 1693
 Description: add /proc/sys/portals/catastrophe entry which will report if
-             that node has previously LBUGged
+            that node has previously LBUGged
 
 2005-04-06  Cluster File Systems, Inc. <info@clusterfs.com>
        * bugs
index 7a48c58..59eda30 100644 (file)
@@ -1,5 +1,5 @@
-EXTRA_CFLAGS := -Ifs/lustre/include -Ifs/lustre/portals/include
-# portals/utils/debug.c wants <linux/version.h> from userspace.  sigh.
+EXTRA_CFLAGS := -Ifs/lustre/include -Ifs/lustre/lnet/include
+# lnet/utils/debug.c wants <linux/version.h> from userspace.  sigh.
 HOSTCFLAGS := -I@LINUX@/include $(EXTRA_CFLAGS)
 LIBREADLINE := @LIBREADLINE@
 # 2.5's makefiles aren't nice to cross dir libraries in host programs
index 7c66dfa..d973e5d 100644 (file)
@@ -1,4 +1,4 @@
-EXTRA_CFLAGS := -Ifs/lustre/include -Ifs/lustre/portals/include
+EXTRA_CFLAGS := -Ifs/lustre/include -Ifs/lustre/lnet/include
 HOSTCFLAGS := $(EXTRA_CFLAGS)
 # the kernel doesn't want us to build archives for host binaries :/
 PTLCTLOBJS := debug.o l_ioctl.o parser.o portals.o
index 71d0dc8..553578c 100644 (file)
@@ -1,9 +1,8 @@
 subdir-m += libcfs
 
-cray-subdirs += portals
-cray-subdirs += knals
-cray-subdirs += router
-cray-subdirs += tests
-@CRAY_PORTALS_FALSE@subdir-m += $(cray-subdirs)
+lnet-subdirs += lnet
+lnet-subdirs += klnds
+lnet-subdirs += tests
+subdir-m += $(lnet-subdirs)
 
 @INCLUDE_RULES@
index b49b8d4..27a60a8 100644 (file)
@@ -3,7 +3,7 @@
 # This code is issued under the GNU General Public License.
 # See the file COPYING in this distribution
 
-SUBDIRS = libcfs portals knals unals router tests doc utils include    \
+SUBDIRS = libcfs lnet klnds ulnds tests doc utils include      \
        autoconf
 
 sources:
index f65d2c0..171634a 100644 (file)
@@ -1 +1 @@
-EXTRA_DIST := lustre-portals.m4
+EXTRA_DIST := lustre-lnet.m4
index 9897290..479a1f5 100644 (file)
@@ -1,9 +1,31 @@
 #
-# LP_CHECK_GCC_VERSION
+# LN_CONFIG_MAX_PAYLOAD
+#
+# configure maximum payload
+#
+AC_DEFUN([LN_CONFIG_MAX_PAYLOAD],
+[AC_MSG_CHECKING([for non-default maximum LNET payload])
+AC_ARG_WITH([max-payload-mb],
+       AC_HELP_STRING([--with-max-payload-mb=MBytes],
+                       [set maximum lnet payload in MBytes]),
+        [
+               AC_MSG_RESULT([$with_max_payload_mb])
+               LNET_MAX_PAYLOAD_MB=$with_max_payload_mb
+               LNET_MAX_PAYLOAD="(($with_max_payload_mb)<<20)"
+       ], [
+               AC_MSG_RESULT([no])
+               LNET_MAX_PAYLOAD="LNET_MTU"
+       ])
+        AC_DEFINE_UNQUOTED(LNET_MAX_PAYLOAD, $LNET_MAX_PAYLOAD,
+                          [Max LNET payload])
+])
+
+#
+# LN_CHECK_GCC_VERSION
 #
 # Check compiler version
 #
-AC_DEFUN([LP_CHECK_GCC_VERSION],
+AC_DEFUN([LN_CHECK_GCC_VERSION],
 [AC_MSG_CHECKING([compiler version])
 PTL_CC_VERSION=`$CC --version | awk '/^gcc/{print $ 3}'`
 PTL_MIN_CC_VERSION="3.2.2"
@@ -20,35 +42,58 @@ fi
 ])
 
 #
-# LP_CONFIG_ZEROCOPY
+# LN_CONFIG_ZEROCOPY
 #
 # check if zerocopy is available/wanted
 #
-AC_DEFUN([LP_CONFIG_ZEROCOPY],
-[AC_MSG_CHECKING([for zero-copy TCP support])
-AC_ARG_ENABLE([zerocopy],
+AC_DEFUN([LN_CONFIG_ZEROCOPY],
+[AC_ARG_ENABLE([zerocopy],
        AC_HELP_STRING([--disable-zerocopy],
-                      [disable socknal zerocopy]),
+                      [disable socklnd zerocopy]),
        [],[enable_zerocopy='yes'])
+AC_MSG_CHECKING([for zero-copy TCP support])
 if test x$enable_zerocopy = xno ; then
        AC_MSG_RESULT([no (by request)])
 else
        ZCCD="`grep -c zccd $LINUX/include/linux/skbuff.h`"
-       if test "$ZCCD" != 0 ; then
-               AC_DEFINE(SOCKNAL_ZC, 1, [use zero-copy TCP])
-               AC_MSG_RESULT(yes)
-       else
+       if test "$ZCCD" = 0 ; then
                AC_MSG_RESULT([no (no kernel support)])
+       else
+               AC_MSG_RESULT([yes])
+               AC_MSG_CHECKING([for up-to-date tcp zero-copy patch])
+               LB_LINUX_TRY_COMPILE([
+                       #include <linux/config.h>
+                       #include <linux/kernel.h>
+                       #include <linux/sched.h>
+                       #include <linux/types.h>
+                       #include <linux/in.h>
+                       #include <linux/string.h>
+                       #include <linux/init.h>
+                       #include <linux/errno.h>
+                       #include <linux/interrupt.h>
+                       #include <linux/netdevice.h>
+                       #include <linux/skbuff.h>
+               ],[
+                       struct zccd zc = {0};
+
+                       return atomic_read(&zc.zccd_refcount);
+               ],[
+                       AC_MSG_RESULT([yes])
+                       AC_DEFINE(SOCKNAL_ZC, 1, [enable zero-copy support])
+               ],[
+                       AC_MSG_RESULT([no])
+                       AC_MSG_ERROR([old TCP zero-copy in kernel (bug 10889) - use --disable-zerocopy to continue ])
+               ])
        fi
 fi
 ])
 
 #
-# LP_CONFIG_AFFINITY
+# LN_CONFIG_AFFINITY
 #
 # check if cpu affinity is available/wanted
 #
-AC_DEFUN([LP_CONFIG_AFFINITY],
+AC_DEFUN([LN_CONFIG_AFFINITY],
 [AC_ARG_ENABLE([affinity],
        AC_HELP_STRING([--disable-affinity],
                       [disable process/irq affinity]),
@@ -62,11 +107,11 @@ else
                #include <linux/sched.h>
        ],[
                struct task_struct t;
-               #ifdef CPU_ARRAY_SIZE
-               cpumask_t m;
-               #else
-               unsigned long m;
-               #endif
+               #if HAVE_CPUMASK_T
+               cpumask_t     m;
+               #else
+               unsigned long m;
+               #endif
                set_cpus_allowed(&t, m);
        ],[
                AC_DEFINE(CPU_AFFINITY, 1, [kernel has cpu affinity support])
@@ -78,11 +123,162 @@ fi
 ])
 
 #
-# LP_CONFIG_QUADRICS
+# LN_CONFIG_PORTALS
+#
+# configure support for Portals
+#
+AC_DEFUN([LN_CONFIG_PORTALS],
+[AC_MSG_CHECKING([for portals])
+AC_ARG_WITH([portals],
+       AC_HELP_STRING([--with-portals=path],
+                       [set path to portals]),
+        [
+               case $with_portals in
+                       no)     ENABLEPORTALS=0
+                               ;;
+                       *)      PORTALS="${with_portals}"
+                               ENABLEPORTALS=1
+                               ;;
+               esac
+               
+       ], [
+               ENABLEPORTALS=0
+       ])
+PTLLNDCPPFLAGS=""
+if test $ENABLEPORTALS -eq 0; then
+       AC_MSG_RESULT([no])
+elif test ! \( -f ${PORTALS}/include/portals/p30.h \); then
+        AC_MSG_RESULT([no])
+       AC_MSG_ERROR([bad --with-portals path])
+else
+        AC_MSG_RESULT([$PORTALS])
+        PTLLNDCPPFLAGS="-I${PORTALS}/include"
+fi
+AC_SUBST(PTLLNDCPPFLAGS)
+])
+
+#
+# LN_CONFIG_BACKOFF
+#
+# check if tunable tcp backoff is available/wanted
+#
+AC_DEFUN([LN_CONFIG_BACKOFF],
+[AC_MSG_CHECKING([for tunable backoff TCP support])
+AC_ARG_ENABLE([backoff],
+       AC_HELP_STRING([--disable-backoff],
+                      [disable socknal tunable backoff]),
+       [],[enable_backoff='yes'])
+if test x$enable_backoff = xno ; then
+       AC_MSG_RESULT([no (by request)])
+else
+       BOCD="`grep -c TCP_BACKOFF $LINUX/include/linux/tcp.h`"
+       if test "$BOCD" != 0 ; then
+               AC_DEFINE(SOCKNAL_BACKOFF, 1, [use tunable backoff TCP])
+               AC_MSG_RESULT(yes)
+       else
+               AC_MSG_RESULT([no (no kernel support)])
+       fi
+fi
+])
+
+#
+# LN_CONFIG_PANIC_DUMPLOG
+#
+# check if tunable panic_dumplog is wanted
+#
+AC_DEFUN([LN_CONFIG_PANIC_DUMPLOG],
+[AC_MSG_CHECKING([for tunable panic_dumplog support])
+AC_ARG_ENABLE([panic_dumplog],
+       AC_HELP_STRING([--enable-panic_dumplog],
+                      [enable panic_dumplog]),
+       [],[enable_panic_dumplog='no'])
+if test x$enable_panic_dumplog = xyes ; then
+       AC_DEFINE(LNET_DUMP_ON_PANIC, 1, [use dumplog on panic])
+       AC_MSG_RESULT([yes (by request)])
+else
+       AC_MSG_RESULT([no])
+fi
+])
+
+#
+# LN_CONFIG_PTLLND
+#
+# configure support for Portals LND
+#
+AC_DEFUN([LN_CONFIG_PTLLND],
+[
+if test -z "$ENABLEPORTALS"; then
+       LN_CONFIG_PORTALS
+fi
+
+AC_MSG_CHECKING([whether to build the kernel portals LND])
+
+PTLLND=""
+if test $ENABLEPORTALS -ne 0; then
+       AC_MSG_RESULT([yes])
+       PTLLND="ptllnd"
+else
+       AC_MSG_RESULT([no])
+fi
+AC_SUBST(PTLLND)
+])
+
+#
+# LN_CONFIG_UPTLLND
+#
+# configure support for Portals LND
+#
+AC_DEFUN([LN_CONFIG_UPTLLND],
+[
+if test -z "$ENABLEPORTALS"; then
+       LN_CONFIG_PORTALS
+fi
+
+AC_MSG_CHECKING([whether to build the userspace portals LND])
+
+UPTLLND=""
+if test $ENABLEPORTALS -ne 0; then
+       AC_MSG_RESULT([yes])
+       UPTLLND="ptllnd"
+else
+       AC_MSG_RESULT([no])
+fi
+AC_SUBST(UPTLLND)
+])
+
+#
+# LN_CONFIG_USOCKLND
+#
+# configure support for userspace TCP/IP LND
+#
+AC_DEFUN([LN_CONFIG_USOCKLND],
+[AC_MSG_CHECKING([whether to build usocklnd])
+AC_ARG_ENABLE([usocklnd],
+               AC_HELP_STRING([--disable-usocklnd],
+                       [disable usocklnd]),
+               [],[enable_usocklnd='yes'])
+
+if test x$enable_usocklnd = xyes ; then
+       if test "$ENABLE_LIBPTHREAD" = "yes" ; then
+               AC_MSG_RESULT([yes])
+               USOCKLND="usocklnd"
+       else
+               AC_MSG_RESULT([no (libpthread not present or disabled)])
+               USOCKLND=""
+       fi
+else
+       AC_MSG_RESULT([no (disabled explicitly)])
+       USOCKLND=""
+fi
+AC_SUBST(USOCKLND)
+])
+
+#
+# LN_CONFIG_QUADRICS
 #
 # check if quadrics support is in this kernel
 #
-AC_DEFUN([LP_CONFIG_QUADRICS],
+AC_DEFUN([LN_CONFIG_QUADRICS],
 [AC_MSG_CHECKING([for QsNet sources])
 AC_ARG_WITH([qsnet],
        AC_HELP_STRING([--with-qsnet=path],
@@ -94,78 +290,304 @@ AC_MSG_RESULT([$QSNET])
 AC_MSG_CHECKING([if quadrics kernel headers are present])
 if test -d $QSNET/drivers/net/qsnet ; then
        AC_MSG_RESULT([yes])
-       QSWNAL="qswnal"
+       QSWLND="qswlnd"
        AC_MSG_CHECKING([for multirail EKC])
        if test -f $QSNET/include/elan/epcomms.h; then
                AC_MSG_RESULT([supported])
                QSWCPPFLAGS="-I$QSNET/include -DMULTIRAIL_EKC=1"
        else
                AC_MSG_RESULT([not supported])
-               if test -d $QSNET/drivers/net/qsnet/include; then
-                       QSWCPPFLAGS="-I$QSNET/drivers/net/qsnet/include"
-               else
-                       QSWCPPFLAGS="-I$QSNET/include/linux"
-               fi
+               AC_MSG_ERROR([Need multirail EKC])
        fi
 
        if test x$QSNET = x$LINUX ; then
                LB_LINUX_CONFIG([QSNET],[],[
                        LB_LINUX_CONFIG([QSNET_MODULE],[],[
-                               AC_MSG_WARN([QSNET is not enabled in this kernel; not building qswnal.])
-                               QSWNAL=""
+                               AC_MSG_WARN([QSNET is not enabled in this kernel; not building qswlnd.])
+                               QSWLND=""
                                QSWCPPFLAGS=""
                        ])
                ])
        fi
 else
        AC_MSG_RESULT([no])
-       QSWNAL=""
+       QSWLND=""
        QSWCPPFLAGS=""
 fi
 AC_SUBST(QSWCPPFLAGS)
-AC_SUBST(QSWNAL)
+AC_SUBST(QSWLND)
 ])
 
 #
-# LP_CONFIG_GM
+# LN_CONFIG_GM
 #
 # check if GM support is available
 #
-AC_DEFUN([LP_CONFIG_GM],
-[LB_ARG_LIBS_INCLUDES([Myrinet],[gm])
-if test x$gm_includes != x ; then
-       GMCPPFLAGS="-I$gm_includes"
-       if test -d "$gm/drivers" ; then
-               GMCPPFLAGS="$GMCPPFLAGS -I$gm/drivers -I$gm/drivers/linux/gm"
-       fi
+AC_DEFUN([LN_CONFIG_GM],[
+AC_MSG_CHECKING([whether to enable GM support])
+AC_ARG_WITH([gm],
+        AC_HELP_STRING([--with-gm=path-to-gm-source-tree],
+                      [build gmlnd against path]),
+       [
+               case $with_gm in
+                no)    ENABLE_GM=0
+                      ;;
+                *)     ENABLE_GM=1
+                       GM_SRC="$with_gm"
+                      ;;
+                esac
+        ],[
+                ENABLE_GM=0
+        ])
+AC_ARG_WITH([gm-install],
+        AC_HELP_STRING([--with-gm-install=path-to-gm-install-tree],
+                      [say where GM has been installed]),
+       [
+               GM_INSTALL=$with_gm_install
+        ],[
+                GM_INSTALL="/opt/gm"
+        ])
+if test $ENABLE_GM -eq 0; then
+        AC_MSG_RESULT([no])
+else
+        AC_MSG_RESULT([yes])
+
+       GMLND="gmlnd"
+        GMCPPFLAGS="-I$GM_SRC/include -I$GM_SRC/drivers -I$GM_SRC/drivers/linux/gm"
+
+       if test -f $GM_INSTALL/lib/libgm.a -o \
+                -f $GM_INSTALL/lib64/libgm.a; then
+               GMLIBS="-L$GM_INSTALL/lib -L$GM_INSTALL/lib64"
+        else
+               AC_MSG_ERROR([Cant find GM libraries under $GM_INSTALL])
+        fi
+
+       EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
+       EXTRA_KCFLAGS="$GMCPPFLAGS -DGM_KERNEL $EXTRA_KCFLAGS"
+
+        AC_MSG_CHECKING([that code using GM compiles with given path])
+       LB_LINUX_TRY_COMPILE([
+               #define GM_STRONG_TYPES 1
+               #ifdef VERSION
+               #undef VERSION
+               #endif
+               #include "gm.h"
+               #include "gm_internal.h"
+        ],[
+               struct gm_port *port = NULL;
+               gm_recv_event_t *rxevent = gm_blocking_receive_no_spin(port);
+                return 0;
+        ],[
+               AC_MSG_RESULT([yes])
+        ],[
+               AC_MSG_RESULT([no])
+               AC_MSG_ERROR([Bad --with-gm path])
+        ])
+
+       AC_MSG_CHECKING([that GM has gm_register_memory_ex_phys()])
+       LB_LINUX_TRY_COMPILE([
+               #define GM_STRONG_TYPES 1
+               #ifdef VERSION
+               #undef VERSION
+               #endif
+               #include "gm.h"
+               #include "gm_internal.h"
+       ],[
+               gm_status_t     gmrc;
+               struct gm_port *port = NULL;
+               gm_u64_t        phys = 0;
+               gm_up_t         pvma = 0;
+
+               gmrc = gm_register_memory_ex_phys(port, phys, 100, pvma);
+               return 0;
+       ],[
+               AC_MSG_RESULT([yes])
+       ],[
+               AC_MSG_RESULT([no.
+Please patch the GM sources as follows...
+    cd $GM_SRC
+    patch -p0 < $PWD/lnet/klnds/gmlnd/gm-reg-phys.patch
+...then rebuild and re-install them])
+                AC_MSG_ERROR([Can't build GM without gm_register_memory_ex_phys()])
+        ])
+
+       EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
 fi
 AC_SUBST(GMCPPFLAGS)
+AC_SUBST(GMLIBS)
+AC_SUBST(GMLND)
+])
+
 
-if test x$gm_libs != x ; then
-       GMLIBS="-L$gm_libs"
+#
+# LN_CONFIG_MX
+#
+AC_DEFUN([LN_CONFIG_MX],
+[AC_MSG_CHECKING([whether to enable Myrinet MX support])
+# set default
+MXPATH="/opt/mx"
+AC_ARG_WITH([mx],
+       AC_HELP_STRING([--with-mx=path],
+                      [build mxlnd against path]),
+       [
+               case $with_mx in
+               yes)    ENABLEMX=2
+                       ;;
+               no)     ENABLEMX=0
+                       ;;
+               *)      MXPATH=$with_mx
+                       ENABLEMX=3
+                       ;;
+               esac
+       ],[
+               ENABLEMX=1
+       ])
+if test $ENABLEMX -eq 0; then
+       AC_MSG_RESULT([disabled])
+elif test ! \( -f ${MXPATH}/include/myriexpress.h -a \
+              -f ${MXPATH}/include/mx_kernel_api.h -a \
+              -f ${MXPATH}/include/mx_pin.h \); then
+       AC_MSG_RESULT([no])
+       case $ENABLEMX in
+       1) ;;
+       2) AC_MSG_ERROR([Myrinet MX kernel headers not present]);;
+       3) AC_MSG_ERROR([bad --with-mx path]);;
+       *) AC_MSG_ERROR([internal error]);;
+       esac
+else
+       MXCPPFLAGS="-I$MXPATH/include"
+       EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
+       EXTRA_KCFLAGS="$EXTRA_KCFLAGS $MXCPPFLAGS"
+       MXLIBS="-L$MXPATH/lib"
+       LB_LINUX_TRY_COMPILE([
+               #define MX_KERNEL 1
+               #include <mx_extensions.h>
+               #include <myriexpress.h>
+       ],[
+               mx_endpoint_t   end;
+               mx_status_t     status;
+               mx_request_t    request;
+               int             result;
+
+               mx_init();
+               mx_open_endpoint(MX_ANY_NIC, MX_ANY_ENDPOINT, 0, NULL, 0, &end);
+              mx_register_unexp_handler(end, (mx_unexp_handler_t) NULL, NULL);
+               mx_wait_any(end, MX_INFINITE, 0LL, 0LL, &status, &result);
+               mx_iconnect(end, 0LL, 0, 0, 0, NULL, &request);
+               return 0;
+       ],[
+               AC_MSG_RESULT([yes])
+               MXLND="mxlnd"
+       ],[
+               AC_MSG_RESULT([no])
+               case $ENABLEMX in
+               1) ;;
+               2) AC_MSG_ERROR([can't compile with Myrinet MX kernel headers]);;
+               3) AC_MSG_ERROR([can't compile with Myrinet MX headers under $MXPATH]);;
+               *) AC_MSG_ERROR([internal error]);;
+               esac
+               MXLND=""
+               MXCPPFLAGS=""
+       ])
+       EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
 fi
-AC_SUBST(GMLIBS)
+AC_SUBST(MXCPPFLAGS)
+AC_SUBST(MXLIBS)
+AC_SUBST(MXLND)
+])
+
+
+
+#
+# LN_CONFIG_O2IB
+#
+AC_DEFUN([LN_CONFIG_O2IB],[
+AC_MSG_CHECKING([whether to enable OpenIB gen2 support])
+# set default
+O2IBPATH="$LINUX/drivers/infiniband"
+AC_ARG_WITH([o2ib],
+       AC_HELP_STRING([--with-o2ib=path],
+                      [build o2iblnd against path]),
+       [
+               case $with_o2ib in
+               yes)    ENABLEO2IB=2
+                       ;;
+               no)     ENABLEO2IB=0
+                       ;;
+               *)      O2IBPATH=$with_o2ib
+                       ENABLEO2IB=3
+                       ;;
+               esac
+       ],[
+               ENABLEO2IB=1
+       ])
+if test $ENABLEO2IB -eq 0; then
+       AC_MSG_RESULT([disabled])
+elif test ! \( -f ${O2IBPATH}/include/rdma/rdma_cm.h -a \
+               -f ${O2IBPATH}/include/rdma/ib_cm.h -a\
+               -f ${O2IBPATH}/include/rdma/ib_verbs.h -a\
+              -f ${O2IBPATH}/include/rdma/ib_fmr_pool.h \); then
+       AC_MSG_RESULT([no])
+       case $ENABLEO2IB in
+       1) ;;
+       2) AC_MSG_ERROR([kernel OpenIB gen2 headers not present]);;
+       3) AC_MSG_ERROR([bad --with-o2ib path]);;
+       *) AC_MSG_ERROR([internal error]);;
+       esac
+else
+       O2IBCPPFLAGS="-I$O2IBPATH/include"
+       EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
+       EXTRA_KCFLAGS="$EXTRA_KCFLAGS $O2IBCPPFLAGS"
+       LB_LINUX_TRY_COMPILE([
+               #include <linux/version.h>
+               #if !HAVE_GFP_T
+               typedef int gfp_t;
+               #endif
+               #include <rdma/rdma_cm.h>
+               #include <rdma/ib_cm.h>
+               #include <rdma/ib_verbs.h>
+               #include <rdma/ib_fmr_pool.h>
+       ],[
+                       struct rdma_cm_id          *cm_id;
+               struct rdma_conn_param      conn_param;
+               struct ib_device_attr       device_attr;
+               struct ib_qp_attr           qp_attr;
+               struct ib_pool_fmr          pool_fmr;           
+               enum   ib_cm_rej_reason     rej_reason;
 
-ENABLE_GM=0
-if test x$gm != x ; then
-       GMNAL="gmnal"
-       ENABLE_GM=1
+               cm_id = rdma_create_id(NULL, NULL, RDMA_PS_TCP);
+               return PTR_ERR(cm_id);
+       ],[
+               AC_MSG_RESULT([yes])
+               O2IBLND="o2iblnd"
+       ],[
+               AC_MSG_RESULT([no])
+               case $ENABLEO2IB in
+               1) ;;
+               2) AC_MSG_ERROR([can't compile with kernel OpenIB gen2 headers]);;
+               3) AC_MSG_ERROR([can't compile with OpenIB gen2 headers under $O2IBPATH]);;
+               *) AC_MSG_ERROR([internal error]);;
+               esac
+               O2IBLND=""
+               O2IBCPPFLAGS=""
+       ])
+       EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
 fi
-AC_SUBST(GMNAL)
-AC_SUBST(ENABLE_GM)
+AC_SUBST(O2IBCPPFLAGS)
+AC_SUBST(O2IBLND)
 ])
 
 #
-# LP_CONFIG_OPENIB
+# LN_CONFIG_OPENIB
 #
 # check for OpenIB in the kernel
-AC_DEFUN([LP_CONFIG_OPENIB],[
+AC_DEFUN([LN_CONFIG_OPENIB],[
 AC_MSG_CHECKING([whether to enable OpenIB support])
 # set default
 OPENIBPATH="$LINUX/drivers/infiniband"
 AC_ARG_WITH([openib],
        AC_HELP_STRING([--with-openib=path],
-                      [build openibnal against path]),
+                      [build openiblnd against path]),
        [
                case $with_openib in
                yes)    ENABLEOPENIB=2
@@ -198,6 +620,7 @@ else
        *)   AC_MSG_RESULT([no])
             AC_MSG_ERROR([internal error]);;
        esac
+       OPENIBCPPFLAGS="$OPENIBCPPFLAGS -DIB_NTXRXPARAMS=4"
        EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
        EXTRA_KCFLAGS="$EXTRA_KCFLAGS $OPENIBCPPFLAGS"
        LB_LINUX_TRY_COMPILE([
@@ -215,7 +638,7 @@ else
                return 0;
        ],[
                AC_MSG_RESULT([yes])
-               OPENIBNAL="openibnal"
+               OPENIBLND="openiblnd"
        ],[
                AC_MSG_RESULT([no])
                case $ENABLEOPENIB in
@@ -224,32 +647,82 @@ else
                3) AC_MSG_ERROR([can't compile with OpenIB headers under $OPENIBPATH]);;
                *) AC_MSG_ERROR([internal error]);;
                esac
-               OPENIBNAL=""
+               OPENIBLND=""
                OPENIBCPPFLAGS=""
        ])
        EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
 fi
 AC_SUBST(OPENIBCPPFLAGS)
-AC_SUBST(OPENIBNAL)
+AC_SUBST(OPENIBLND)
 ])
 
 #
-# LP_CONFIG_IIB
-#
-# check for infinicon infiniband support
+# LN_CONFIG_CIBLND
 #
+AC_DEFUN([LN_CONFIG_CIB],[
+AC_MSG_CHECKING([whether to enable Cisco/TopSpin IB support])
+# set default
+CIBPATH=""
+CIBLND=""
+AC_ARG_WITH([cib],
+       AC_HELP_STRING([--with-cib=path],
+                      [build ciblnd against path]),
+       [
+               case $with_cib in
+               no)     AC_MSG_RESULT([no]);;
+               *)      CIBPATH="$with_cib"
+                       if test -d "$CIBPATH"; then
+                               AC_MSG_RESULT([yes])
+                        else
+                               AC_MSG_RESULT([no])
+                               AC_MSG_ERROR([No directory $CIBPATH])
+                       fi;;
+               esac
+       ],[
+               AC_MSG_RESULT([no])
+       ])
+if test -n "$CIBPATH"; then
+       CIBCPPFLAGS="-I${CIBPATH}/ib/ts_api_ng/include -I${CIBPATH}/all/kernel_services/include -DUSING_TSAPI"
+       CIBCPPFLAGS="$CIBCPPFLAGS -DIB_NTXRXPARAMS=3"
+       EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
+       EXTRA_KCFLAGS="$EXTRA_KCFLAGS $CIBCPPFLAGS"
+       LB_LINUX_TRY_COMPILE([
+               #include <ts_ib_core.h>
+               #include <ts_ib_cm.h>
+               #include <ts_ib_sa_client.h>
+       ],[
+                       struct ib_device_properties dev_props;
+               struct ib_cm_active_param   cm_active_params;
+               tTS_IB_CLIENT_QUERY_TID     tid;
+               int                         enum1 = TS_IB_QP_ATTRIBUTE_STATE;
+               int                         enum2 = TS_IB_ACCESS_LOCAL_WRITE;
+               int                         enum3 = TS_IB_CQ_CALLBACK_INTERRUPT;
+               int                         enum4 = TS_IB_CQ_PROVIDER_REARM;
+               return 0;
+       ],[
+               CIBLND="ciblnd"
+       ],[
+               AC_MSG_ERROR([can't compile ciblnd with given path])
+               CIBCPPFLAGS=""
+       ])
+       EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
+fi
+AC_SUBST(CIBCPPFLAGS)
+AC_SUBST(CIBLND)
+])
+
 #
-# LP_CONFIG_IIB
+# LN_CONFIG_IIB
 #
 # check for infinicon infiniband support
 #
-AC_DEFUN([LP_CONFIG_IIB],[
+AC_DEFUN([LN_CONFIG_IIB],[
 AC_MSG_CHECKING([whether to enable Infinicon support])
 # set default
 IIBPATH="/usr/include"
 AC_ARG_WITH([iib],
        AC_HELP_STRING([--with-iib=path],
-                      [build iibnal against path]),
+                      [build iiblnd against path]),
        [
                case $with_iib in
                yes)    ENABLEIIB=2
@@ -293,7 +766,7 @@ else
                return rc == FSUCCESS ? 0 : 1;
        ],[
                AC_MSG_RESULT([yes])
-               IIBNAL="iibnal"
+               IIBLND="iiblnd"
        ],[
                AC_MSG_RESULT([no])
                case $ENABLEIIB in
@@ -302,26 +775,26 @@ else
                3) AC_MSG_ERROR([can't compile with Infinicon headers under $IIBPATH]);;
                *) AC_MSG_ERROR([internal error]);;
                esac
-               IIBNAL=""
+               IIBLND=""
                IIBCPPFLAGS=""
        ])
        EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
 fi
 AC_SUBST(IIBCPPFLAGS)
-AC_SUBST(IIBNAL)
+AC_SUBST(IIBLND)
 ])
 
 #
-# LP_CONFIG_VIB
+# LN_CONFIG_VIB
 #
 # check for Voltaire infiniband support
 #
-AC_DEFUN([LP_CONFIG_VIB],
+AC_DEFUN([LN_CONFIG_VIB],
 [AC_MSG_CHECKING([whether to enable Voltaire IB support])
 VIBPATH=""
 AC_ARG_WITH([vib],
        AC_HELP_STRING([--with-vib=path],
-                      [build vibnal against path]),
+                      [build viblnd against path]),
        [
                case $with_vib in
                no)     AC_MSG_RESULT([no]);;
@@ -337,7 +810,7 @@ AC_ARG_WITH([vib],
                AC_MSG_RESULT([no])
        ])
 if test -z "$VIBPATH"; then
-       VIBNAL=""
+       VIBLND=""
 else
        VIBCPPFLAGS="-I${VIBPATH}/include -I${VIBPATH}/cm"
        EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
@@ -371,13 +844,13 @@ else
                                           NULL, 0);
                return 0;
        ],[
-               VIBNAL="vibnal"
+               VIBLND="viblnd"
        ],[
-               AC_MSG_ERROR([can't compile vibnal with given path])
+               AC_MSG_ERROR([can't compile viblnd with given path])
        ])
        EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
 fi
-if test -n "$VIBNAL"; then
+if test -n "$VIBLND"; then
        EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
        EXTRA_KCFLAGS="$EXTRA_KCFLAGS $VIBCPPFLAGS"
        AC_MSG_CHECKING([if Voltaire still uses void * sg addresses])
@@ -405,39 +878,18 @@ if test -n "$VIBNAL"; then
        ],[
                AC_MSG_RESULT([no])
        ])
-       AC_MSG_CHECKING([if page_to_phys() must avoid sign extension])
-       LB_LINUX_TRY_COMPILE([
-               #include <linux/kernel.h>
-               #include <linux/mm.h>
-               #include <linux/unistd.h>
-               #include <asm/system.h>
-               #include <asm/io.h>
-       ],[
-               struct page p;
-
-               switch (42) {
-               case 0:
-               case (sizeof(typeof(page_to_phys(&p))) < 8):
-                       break;
-               }
-       ],[
-               AC_MSG_RESULT([yes])
-               VIBCPPFLAGS="$VIBCPPFLAGS -DIBNAL_32BIT_PAGE2PHYS=1"
-       ],[
-               AC_MSG_RESULT([no])
-       ])
        EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
 fi
 AC_SUBST(VIBCPPFLAGS)
-AC_SUBST(VIBNAL)
+AC_SUBST(VIBLND)
 ])
 
 #
-# LP_CONFIG_RANAL
+# LN_CONFIG_RALND
 #
-# check whether to use the RapidArray nal
+# check whether to use the RapidArray lnd
 #
-AC_DEFUN([LP_CONFIG_RANAL],
+AC_DEFUN([LN_CONFIG_RALND],
 [#### Rapid Array
 AC_MSG_CHECKING([if RapidArray kernel headers are present])
 # placeholder
@@ -456,23 +908,23 @@ LB_LINUX_TRY_COMPILE([
        return rc == RAP_SUCCESS ? 0 : 1;
 ],[
        AC_MSG_RESULT([yes])
-       RANAL="ranal"
+       RALND="ralnd"
 ],[
        AC_MSG_RESULT([no])
-       RANAL=""
+       RALND=""
        RACPPFLAGS=""
 ])
 EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
 AC_SUBST(RACPPFLAGS)
-AC_SUBST(RANAL)
+AC_SUBST(RALND)
 ])
 
 #
-# LP_STRUCT_PAGE_LIST
+# LN_STRUCT_PAGE_LIST
 #
 # 2.6.4 no longer has page->list
 #
-AC_DEFUN([LP_STRUCT_PAGE_LIST],
+AC_DEFUN([LN_STRUCT_PAGE_LIST],
 [AC_MSG_CHECKING([if struct page has a list field])
 LB_LINUX_TRY_COMPILE([
        #include <linux/mm.h>
@@ -488,11 +940,11 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
-# LP_STRUCT_SIGHAND
+# LN_STRUCT_SIGHAND
 #
 # red hat 2.4 adds sighand to struct task_struct
 #
-AC_DEFUN([LP_STRUCT_SIGHAND],
+AC_DEFUN([LN_STRUCT_SIGHAND],
 [AC_MSG_CHECKING([if task_struct has a sighand field])
 LB_LINUX_TRY_COMPILE([
        #include <linux/sched.h>
@@ -508,11 +960,11 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
-# LP_FUNC_CPU_ONLINE
+# LN_FUNC_CPU_ONLINE
 #
 # cpu_online is different in rh 2.4, vanilla 2.4, and 2.6
 #
-AC_DEFUN([LP_FUNC_CPU_ONLINE],
+AC_DEFUN([LN_FUNC_CPU_ONLINE],
 [AC_MSG_CHECKING([if kernel defines cpu_online()])
 LB_LINUX_TRY_COMPILE([
        #include <linux/sched.h>
@@ -527,11 +979,30 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
-# LP_TYPE_CPUMASK_T
+# LN_TYPE_GFP_T
+#
+# check if gfp_t is typedef-ed
+#
+AC_DEFUN([LN_TYPE_GFP_T],
+[AC_MSG_CHECKING([if kernel defines gfp_t])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/gfp.h>
+],[
+       return sizeof(gfp_t);
+],[
+       AC_MSG_RESULT([yes])
+       AC_DEFINE(HAVE_GFP_T, 1, [gfp_t found])
+],[
+       AC_MSG_RESULT([no])
+])
+])
+
+#
+# LN_TYPE_CPUMASK_T
 #
 # same goes for cpumask_t
 #
-AC_DEFUN([LP_TYPE_CPUMASK_T],
+AC_DEFUN([LN_TYPE_CPUMASK_T],
 [AC_MSG_CHECKING([if kernel defines cpumask_t])
 LB_LINUX_TRY_COMPILE([
        #include <linux/sched.h>
@@ -546,11 +1017,11 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
-# LP_FUNC_SHOW_TASK
+# LN_FUNC_SHOW_TASK
 #
 # we export show_task(), but not all kernels have it (yet)
 #
-AC_DEFUN([LP_FUNC_SHOW_TASK],
+AC_DEFUN([LN_FUNC_SHOW_TASK],
 [AC_MSG_CHECKING([if kernel exports show_task])
 have_show_task=0
 for file in ksyms sched ; do
@@ -568,57 +1039,120 @@ else
 fi
 ])
 
+# LN_TASKLIST_LOCK
+# 2.6.18 remove tasklist_lock export
+AC_DEFUN([LN_TASKLIST_LOCK],
+[AC_MSG_CHECKING([kernel export tasklist_lock])
+        if grep -q "EXPORT_SYMBOL(tasklist_lock)" \
+                 "$LINUX/kernel/fork.c" 2>/dev/null ; then
+                AC_DEFINE(HAVE_TASKLIST_LOCK, 1,
+                          [tasklist_lock exported])
+                AC_MSG_RESULT([yes])
+        else
+                AC_MSG_RESULT([no])
+        fi
+])
+
+# 2.6.19 API changes
+# kmem_cache_destroy(cachep) return void instead of 
+# int
+AC_DEFUN([LN_KMEM_CACHE_DESTROY_INT],
+[AC_MSG_CHECKING([kmem_cache_destroy(cachep) return int])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/slab.h>
+],[
+       int i = kmem_cache_destroy(NULL);
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_KMEM_CACHE_DESTROY_INT, 1,
+                [kmem_cache_destroy(cachep) return int])
+],[
+        AC_MSG_RESULT(NO)
+])
+])
+
+#2.6.19 API change
+#panic_notifier_list use atomic_notifier operations
+#
+AC_DEFUN([LN_ATOMIC_PANIC_NOTIFIER],
+[AC_MSG_CHECKING([panic_notifier_list is atomic])
+LB_LINUX_TRY_COMPILE([
+       #include <linux/notifier.h>
+       #include <linux/kernel.h>       
+],[
+       struct atomic_notifier_head panic_notifier_list;
+],[
+        AC_MSG_RESULT(yes)
+       AC_DEFINE(HAVE_ATOMIC_PANIC_NOTIFIER, 1,
+               [panic_notifier_list is atomic_notifier_head])
+],[
+        AC_MSG_RESULT(NO)
+])
+])
+
 #
-# LP_PROG_LINUX
+# LN_PROG_LINUX
 #
-# Portals linux kernel checks
+# LNet linux kernel checks
 #
-AC_DEFUN([LP_PROG_LINUX],
-[LP_CONFIG_ZEROCOPY
-LP_CONFIG_AFFINITY
-LP_CONFIG_QUADRICS
-LP_CONFIG_GM
-LP_CONFIG_OPENIB
-LP_CONFIG_VIB
-LP_CONFIG_IIB
-LP_CONFIG_RANAL
+AC_DEFUN([LN_PROG_LINUX],
+[LN_CONFIG_ZEROCOPY
+LN_FUNC_CPU_ONLINE
+LN_TYPE_GFP_T
+LN_TYPE_CPUMASK_T
+LN_CONFIG_AFFINITY
+LN_CONFIG_BACKOFF
+LN_CONFIG_PANIC_DUMPLOG
+LN_CONFIG_QUADRICS
+LN_CONFIG_GM
+LN_CONFIG_OPENIB
+LN_CONFIG_CIB
+LN_CONFIG_VIB
+LN_CONFIG_IIB
+LN_CONFIG_O2IB
+LN_CONFIG_RALND
+LN_CONFIG_PTLLND
+LN_CONFIG_MX
 
-LP_STRUCT_PAGE_LIST
-LP_STRUCT_SIGHAND
-LP_FUNC_CPU_ONLINE
-LP_TYPE_CPUMASK_T
-LP_FUNC_SHOW_TASK
+LN_STRUCT_PAGE_LIST
+LN_STRUCT_SIGHAND
+LN_FUNC_SHOW_TASK
+# 2.6.18
+LN_TASKLIST_LOCK
+# 2.6.19
+LN_KMEM_CACHE_DESTROY_INT
+LN_ATOMIC_PANIC_NOTIFIER
 ])
 
 #
-# LP_PROG_DARWIN
+# LN_PROG_DARWIN
 #
 # Darwin checks
 #
-AC_DEFUN([LP_PROG_DARWIN],
+AC_DEFUN([LN_PROG_DARWIN],
 [LB_DARWIN_CHECK_FUNCS([get_preemption_level])
 ])
 
 #
-# LP_PATH_DEFAULTS
+# LN_PATH_DEFAULTS
 #
 # default paths for installed files
 #
-AC_DEFUN([LP_PATH_DEFAULTS],
+AC_DEFUN([LN_PATH_DEFAULTS],
 [
 ])
 
 #
-# LP_CONFIGURE
+# LN_CONFIGURE
 #
 # other configure checks
 #
-AC_DEFUN([LP_CONFIGURE],
-[# portals/utils/portals.c
+AC_DEFUN([LN_CONFIGURE],
+[# lnet/utils/portals.c
 AC_CHECK_HEADERS([netdb.h netinet/tcp.h asm/types.h endian.h sys/ioctl.h])
 AC_CHECK_FUNCS([gethostbyname socket connect])
 
-# portals/utils/debug.c
+# lnet/utils/debug.c
 AC_CHECK_HEADERS([linux/version.h])
 
 AC_CHECK_TYPE([spinlock_t],
@@ -626,20 +1160,37 @@ AC_CHECK_TYPE([spinlock_t],
        [],
        [#include <linux/spinlock.h>])
 
-# portals/utils/wirecheck.c
+# lnet/utils/wirecheck.c
 AC_CHECK_FUNCS([strnlen])
 
 # --------  Check for required packages  --------------
 
-LIBS_save="$LIBS"
-LIBS="-lncurses $LIBS"
-AC_CHECK_LIB([readline],[readline],[
+#
+# LC_CONFIG_READLINE
+#
+# Build with readline
+#
+AC_MSG_CHECKING([whether to enable readline support])
+AC_ARG_ENABLE(readline,
+        AC_HELP_STRING([--disable-readline],
+                        [disable readline support]),
+        [],[enable_readline='yes'])
+AC_MSG_RESULT([$enable_readline])
+
+# -------- check for readline if enabled ----
+if test x$enable_readline = xyes ; then
+       LIBS_save="$LIBS"
+       LIBS="-lncurses $LIBS"
+       AC_CHECK_LIB([readline],[readline],[
        LIBREADLINE="-lreadline -lncurses"
        AC_DEFINE(HAVE_LIBREADLINE, 1, [readline library is available])
-],[
+       ],[
        LIBREADLINE=""
-])
-LIBS="$LIBS_save"
+       ])
+       LIBS="$LIBS_save"
+else
+       LIBREADLINE=""
+fi
 AC_SUBST(LIBREADLINE)
 
 AC_MSG_CHECKING([if efence debugging support is requested])
@@ -651,7 +1202,7 @@ AC_MSG_RESULT([$enable_efence])
 if test "$enable_efence" = "yes" ; then
        LIBEFENCE="-lefence"
        AC_DEFINE(HAVE_LIBEFENCE, 1, [libefence support is requested])
-else 
+else
        LIBEFENCE=""
 fi
 AC_SUBST(LIBEFENCE)
@@ -674,6 +1225,31 @@ else
 fi
 AC_SUBST(LIBWRAP)
 
+# -------- check for -lpthread support ----
+AC_MSG_CHECKING([whether to use libpthread for lnet library])
+AC_ARG_ENABLE([libpthread],
+               AC_HELP_STRING([--disable-libpthread],
+                       [disable libpthread]),
+               [],[enable_libpthread=yes])
+if test "$enable_libpthread" = "yes" ; then
+       AC_CHECK_LIB([pthread], [pthread_create],
+               [ENABLE_LIBPTHREAD="yes"],
+               [ENABLE_LIBPTHREAD="no"])
+       if test "$ENABLE_LIBPTHREAD" = "yes" ; then
+               AC_MSG_RESULT([$ENABLE_LIBPTHREAD])
+               PTHREAD_LIBS="-lpthread"
+               AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
+       else
+               PTHREAD_LIBS=""
+               AC_MSG_RESULT([no libpthread is found])
+       fi
+       AC_SUBST(PTHREAD_LIBS)
+else
+       AC_MSG_RESULT([no (disabled explicitly)])
+       ENABLE_LIBPTHREAD="no"
+fi
+AC_SUBST(ENABLE_LIBPTHREAD)
+
 # ----------------------------------------
 # some tests for catamount-like systems
 # ----------------------------------------
@@ -697,92 +1273,105 @@ if test x$enable_urandom != xno ; then
        AC_DEFINE([LIBLUSTRE_USE_URANDOM], 1, [use /dev/urandom for random data])
 fi
 
-# -------- check for -lcap and -lpthread ----
+# -------- check for -lcap support ----
 if test x$enable_liblustre = xyes ; then
        AC_CHECK_LIB([cap], [cap_get_proc],
                [
                        CAP_LIBS="-lcap"
                        AC_DEFINE([HAVE_LIBCAP], 1, [use libcap])
                ],
-               [CAP_LIBS=""])
-       AC_SUBST(CAP_LIBS)
-       AC_CHECK_LIB([pthread], [pthread_create],
                [
-                       PTHREAD_LIBS="-lpthread"
-                       AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread])
-               ],
-               [PTHREAD_LIBS=""])
-       AC_SUBST(PTHREAD_LIBS)
+                       CAP_LIBS=""
+               ])
+       AC_SUBST(CAP_LIBS)
+
 fi
+
+LN_CONFIG_MAX_PAYLOAD
+LN_CONFIG_UPTLLND
+LN_CONFIG_USOCKLND
 ])
 
 #
-# LP_CONDITIONALS
+# LN_CONDITIONALS
 #
-# AM_CONDITOINAL defines for portals
+# AM_CONDITOINAL defines for lnet
 #
-AC_DEFUN([LP_CONDITIONALS],
-[AM_CONDITIONAL(BUILD_QSWNAL, test x$QSWNAL = "xqswnal")
-AM_CONDITIONAL(BUILD_GMNAL, test x$GMNAL = "xgmnal")
-AM_CONDITIONAL(BUILD_OPENIBNAL, test x$OPENIBNAL = "xopenibnal")
-AM_CONDITIONAL(BUILD_IIBNAL, test x$IIBNAL = "xiibnal")
-AM_CONDITIONAL(BUILD_VIBNAL, test x$VIBNAL = "xvibnal")
-AM_CONDITIONAL(BUILD_RANAL, test x$RANAL = "xranal")
+AC_DEFUN([LN_CONDITIONALS],
+[AM_CONDITIONAL(BUILD_QSWLND, test x$QSWLND = "xqswlnd")
+AM_CONDITIONAL(BUILD_GMLND, test x$GMLND = "xgmlnd")
+AM_CONDITIONAL(BUILD_MXLND, test x$MXLND = "xmxlnd")
+AM_CONDITIONAL(BUILD_O2IBLND, test x$O2IBLND = "xo2iblnd")
+AM_CONDITIONAL(BUILD_OPENIBLND, test x$OPENIBLND = "xopeniblnd")
+AM_CONDITIONAL(BUILD_CIBLND, test x$CIBLND = "xciblnd")
+AM_CONDITIONAL(BUILD_IIBLND, test x$IIBLND = "xiiblnd")
+AM_CONDITIONAL(BUILD_VIBLND, test x$VIBLND = "xviblnd")
+AM_CONDITIONAL(BUILD_RALND, test x$RALND = "xralnd")
+AM_CONDITIONAL(BUILD_PTLLND, test x$PTLLND = "xptllnd")
+AM_CONDITIONAL(BUILD_UPTLLND, test x$UPTLLND = "xptllnd")
+AM_CONDITIONAL(BUILD_USOCKLND, test x$USOCKLND = "xusocklnd")
 ])
 
 #
-# LP_CONFIG_FILES
+# LN_CONFIG_FILES
 #
 # files that should be generated with AC_OUTPUT
 #
-AC_DEFUN([LP_CONFIG_FILES],
+AC_DEFUN([LN_CONFIG_FILES],
 [AC_CONFIG_FILES([
-portals/Kernelenv
-portals/Makefile
-portals/autoMakefile
-portals/autoconf/Makefile
-portals/doc/Makefile
-portals/include/Makefile
-portals/include/libcfs/Makefile
-portals/include/libcfs/linux/Makefile
-portals/include/portals/Makefile
-portals/include/portals/linux/Makefile
-portals/knals/Makefile
-portals/knals/autoMakefile
-portals/knals/gmnal/Makefile
-portals/knals/gmnal/autoMakefile
-portals/knals/openibnal/Makefile
-portals/knals/openibnal/autoMakefile
-portals/knals/iibnal/Makefile
-portals/knals/iibnal/autoMakefile
-portals/knals/vibnal/Makefile
-portals/knals/vibnal/autoMakefile
-portals/knals/lonal/Makefile
-portals/knals/lonal/autoMakefile
-portals/knals/qswnal/Makefile
-portals/knals/qswnal/autoMakefile
-portals/knals/ranal/Makefile
-portals/knals/ranal/autoMakefile
-portals/knals/socknal/Makefile
-portals/knals/socknal/autoMakefile
-portals/libcfs/Makefile
-portals/libcfs/autoMakefile
-portals/libcfs/linux/Makefile
-portals/portals/Makefile
-portals/portals/autoMakefile
-portals/router/Makefile
-portals/router/autoMakefile
-portals/tests/Makefile
-portals/tests/autoMakefile
-portals/unals/Makefile
-portals/utils/Makefile
+lnet/Kernelenv
+lnet/Makefile
+lnet/autoMakefile
+lnet/autoconf/Makefile
+lnet/doc/Makefile
+lnet/include/Makefile
+lnet/include/libcfs/Makefile
+lnet/include/libcfs/linux/Makefile
+lnet/include/lnet/Makefile
+lnet/include/lnet/linux/Makefile
+lnet/klnds/Makefile
+lnet/klnds/autoMakefile
+lnet/klnds/gmlnd/Makefile
+lnet/klnds/mxlnd/autoMakefile
+lnet/klnds/mxlnd/Makefile
+lnet/klnds/gmlnd/autoMakefile
+lnet/klnds/openiblnd/Makefile
+lnet/klnds/openiblnd/autoMakefile
+lnet/klnds/o2iblnd/Makefile
+lnet/klnds/o2iblnd/autoMakefile
+lnet/klnds/ciblnd/Makefile
+lnet/klnds/ciblnd/autoMakefile
+lnet/klnds/iiblnd/Makefile
+lnet/klnds/iiblnd/autoMakefile
+lnet/klnds/viblnd/Makefile
+lnet/klnds/viblnd/autoMakefile
+lnet/klnds/qswlnd/Makefile
+lnet/klnds/qswlnd/autoMakefile
+lnet/klnds/ralnd/Makefile
+lnet/klnds/ralnd/autoMakefile
+lnet/klnds/socklnd/Makefile
+lnet/klnds/socklnd/autoMakefile
+lnet/klnds/ptllnd/Makefile
+lnet/klnds/ptllnd/autoMakefile
+lnet/libcfs/Makefile
+lnet/libcfs/autoMakefile
+lnet/libcfs/linux/Makefile
+lnet/lnet/Makefile
+lnet/lnet/autoMakefile
+lnet/tests/Makefile
+lnet/tests/autoMakefile
+lnet/ulnds/Makefile
+lnet/ulnds/autoMakefile
+lnet/ulnds/socklnd/Makefile
+lnet/ulnds/ptllnd/Makefile
+lnet/utils/Makefile
 ])
 case $lb_target_os in
        darwin)
                AC_CONFIG_FILES([
-portals/include/libcfs/darwin/Makefile
-portals/include/portals/darwin/Makefile
-portals/libcfs/darwin/Makefile
+lnet/include/libcfs/darwin/Makefile
+lnet/include/lnet/darwin/Makefile
+lnet/libcfs/darwin/Makefile
 ])
                ;;
 esac
index dd6db1d..006180b 100644 (file)
@@ -1,3 +1,3 @@
-SUBDIRS = libcfs portals
+SUBDIRS = libcfs lnet
 
 EXTRA_DIST = cygwin-ioctl.h
index 50e377a..2874a52 100644 (file)
@@ -4,5 +4,5 @@ SUBDIRS += darwin
 endif
 DIST_SUBDIRS := $(SUBDIRS)
 
-EXTRA_DIST := curproc.h kp30.h libcfs.h list.h lltrace.h portals_lib.h \
-       portals_utils.h user-lock.h user-prim.h user-time.h
+EXTRA_DIST := curproc.h kp30.h libcfs.h list.h lltrace.h \
+       portals_utils.h types.h user-lock.h user-prim.h user-time.h
index 630912d..6495c66 100644 (file)
@@ -20,6 +20,7 @@
 #ifndef __LIBCFS_CURPROC_H__
 #define __LIBCFS_CURPROC_H__
 
+#ifdef __KERNEL__
 /*
  * Portable API to access common characteristics of "current" UNIX process.
  *
@@ -48,6 +49,7 @@ char  *cfs_curproc_comm(void);
  */
 cfs_kernel_cap_t cfs_curproc_cap_get(void);
 void cfs_curproc_cap_set(cfs_kernel_cap_t cap);
+#endif
 
 /* __LIBCFS_CURPROC_H__ */
 #endif
index 4ff2072..f2f217a 100644 (file)
@@ -1,3 +1,3 @@
 EXTRA_DIST := darwin-mem.h darwin-types.h libcfs.h portals_utils.h     \
        darwin-fs.h darwin-prim.h darwin-utils.h lltrace.h              \
-       darwin-lock.h darwin-sync.h kp30.h portals_lib.h
+       darwin-lock.h darwin-sync.h darwin-tcpip.h kp30.h
index 32244e7..5eed9ef 100644 (file)
@@ -1,5 +1,24 @@
-#ifndef __LIBCFS_DARWIN_CFS_FS_H__
-#define __LIBCFS_DARWIN_CFS_FS_H__
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Implementation of standard file system interfaces for XNU kernel.
+ *
+ *  Copyright (c) 2004 Cluster File Systems, Inc.
+ *
+ *   This file is part of Lustre, http://www.lustre.org.
+ *
+ *   Lustre is free software; you can redistribute it and/or modify it under
+ *   the terms of version 2 of the GNU General Public License as published by
+ *   the Free Software Foundation. Lustre is distributed in the hope that it
+ *   will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ *   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details. You should have received a
+ *   copy of the GNU General Public License along with Lustre; if not, write
+ *   to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
+ *   USA.
+ */
+#ifndef __LIBCFS_DARWIN_FS_H__
+#define __LIBCFS_DARWIN_FS_H__
 
 #ifndef __LIBCFS_LIBCFS_H__
 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
 
 #include <sys/types.h>
 #include <sys/systm.h>
-/*
- * __APPLE_API_PRIVATE is defined before include user.h
- * Doing this way to get the define of uthread, it's not good
- * but I do need to know what's inside uthread.
- */
-#ifndef __APPLE_API_PRIVATE
-#define __APPLE_API_PRIVATE
-#include <sys/vnode.h>
-#undef __APPLE_API_PRIVATE
-#else
-#include <sys/vnode.h>
-#endif
 
 #include <sys/kernel.h>
 #include <sys/file.h>
 #include <sys/time.h>
 #include <sys/filedesc.h>
-#include <sys/stat.h>
 #include <sys/mount.h>
+#include <sys/stat.h>
 #include <sys/sysctl.h>
 #include <sys/ubc.h>
 #include <sys/mbuf.h>
@@ -37,7 +44,6 @@
 #include <stdarg.h>
 
 #include <mach/mach_types.h>
-#include <mach/mach_traps.h>
 #include <mach/time_value.h>
 #include <kern/clock.h>
 #include <sys/param.h>
 /*
  * File operating APIs in kernel
  */
+#ifdef __DARWIN8__
+/*
+ * Kernel file descriptor
+ */
+typedef struct cfs_kern_file {
+        int             f_flags;
+        vnode_t         f_vp;
+        vfs_context_t   f_ctxt;
+} cfs_file_t;
+
+#else
+
 typedef struct file cfs_file_t;
 
-int    filp_node_size(cfs_file_t *fp, off_t    *size);
+#endif
+
+int    kern_file_size(cfs_file_t *fp, off_t    *size);
 #define cfs_filp_size(fp)                      \
        ({                                      \
                off_t           __size;         \
-               filp_node_size((fp), &__size);  \
+               kern_file_size((fp), &__size);  \
                __size;                         \
         })
 #define cfs_filp_poff(fp)               (NULL)
 
-cfs_file_t *filp_open(const char *name, int flags, int mode, int *err);
-int filp_close(cfs_file_t *fp);
-int filp_read(cfs_file_t *fp, void *buf, size_t nbytes, off_t *pos);
-int filp_write(cfs_file_t *fp, void *buf, size_t nbytes, off_t *pos);
-int filp_fsync(cfs_file_t *fp);
+cfs_file_t *kern_file_open(const char *name, int flags, int mode, int *err);
+int kern_file_close(cfs_file_t *fp);
+int kern_file_read(cfs_file_t *fp, void *buf, size_t nbytes, off_t *pos);
+int kern_file_write(cfs_file_t *fp, void *buf, size_t nbytes, off_t *pos);
+int kern_file_sync(cfs_file_t *fp);
 
-#define cfs_filp_open(n, f, m, e)      filp_open(n, f, m, e)
-#define cfs_filp_close(f)              filp_close(f)
-#define cfs_filp_read(f, b, n, p)      filp_read(f, b, n, p)
-#define cfs_filp_write(f, b, n, p)     filp_write(f, b, n, p)
-#define cfs_filp_fsync(f)              filp_fsync(f)
+#define cfs_filp_open(n, f, m, e)      kern_file_open(n, f, m, e)
+#define cfs_filp_close(f)              kern_file_close(f)
+#define cfs_filp_read(f, b, n, p)      kern_file_read(f, b, n, p)
+#define cfs_filp_write(f, b, n, p)     kern_file_write(f, b, n, p)
+#define cfs_filp_fsync(f)              kern_file_sync(f)
 
 int ref_file(cfs_file_t *fp);
 int rele_file(cfs_file_t *fp);
@@ -85,25 +105,25 @@ int file_count(cfs_file_t *fp);
 #define CFS_OFFSET_MAX                 CFS_INT_LIMIT(loff_t)
 
 typedef struct flock                   cfs_flock_t;
-#define CFS_FLOCK_TYPE(fl)             ((fl)->l_type)
-#define CFS_FLOCK_SET_TYPE(fl, type)   do { (fl)->l_type = (type); } while(0)
-#define CFS_FLOCK_PID(fl)              ((fl)->l_pid)
-#define CFS_FLOCK_SET_PID(fl, pid)     do { (fl)->l_pid = (pid); } while(0)
-#define CFS_FLOCK_START(fl)            ((fl)->l_start)
-#define CFS_FLOCK_SET_START(fl, start) do { (fl)->l_start = (start); } while(0)
-#define CFS_FLOCK_END(fl)              ((fl)->l_len == 0? CFS_OFFSET_MAX: ((fl)->l_start + (fl)->l_en))
-#define CFS_FLOCK_SET_END(fl, end)             \
-       do {                                    \
-               if (end == CFS_OFFSET_MAX)      \
-                       (fl)->l_len = 0;        \
-               else                            \
-                       (fl)->l_len = (end) - (fl)->l_start;\
-       } while(0)
-
-typedef struct {
-       void    *d;
-} cfs_dentry_t;
-typedef unsigned short umode_t;
+#define cfs_flock_type(fl)             ((fl)->l_type)
+#define cfs_flock_set_type(fl, type)   do { (fl)->l_type = (type); } while(0)
+#define cfs_flock_pid(fl)              ((fl)->l_pid)
+#define cfs_flock_set_pid(fl, pid)     do { (fl)->l_pid = (pid); } while(0)
+#define cfs_flock_start(fl)            ((fl)->l_start)
+#define cfs_flock_set_start(fl, start) do { (fl)->l_start = (start); } while(0)
+
+static inline loff_t cfs_flock_end(cfs_flock_t *fl)
+{
+        return (fl->l_len == 0 ? CFS_OFFSET_MAX: (fl->l_start + fl->l_len));
+}
+
+static inline void cfs_flock_set_end(cfs_flock_t *fl, loff_t end)
+{
+        if (end == CFS_OFFSET_MAX)
+                fl->l_len = 0;
+        else
+                fl->l_len = end - fl->l_start;
+}
 
 #define ATTR_MODE       0x0001
 #define ATTR_UID        0x0002
@@ -119,13 +139,59 @@ typedef unsigned short umode_t;
 #define ATTR_RAW        0x0800  /* file system, not vfs will massage attrs */
 #define ATTR_FROM_OPEN  0x1000  /* called from open path, ie O_TRUNC */
 #define ATTR_CTIME_SET  0x2000
+#define ATTR_BLOCKS     0x4000
 
 #define in_group_p(x)  (0)
 
-#endif
+struct posix_acl_entry {
+        short                   e_tag;
+        unsigned short          e_perm;
+        unsigned int            e_id;
+};
+
+struct posix_acl {
+        atomic_t                a_refcount;
+        unsigned int            a_count;
+        struct posix_acl_entry  a_entries[0];
+};
+
+struct posix_acl *posix_acl_alloc(int count, int flags);
+static inline struct posix_acl *posix_acl_from_xattr(const void *value, 
+                                                     size_t size)
+{ 
+        return posix_acl_alloc(0, 0);
+}
+static inline void posix_acl_release(struct posix_acl *acl) {};
+static inline int posix_acl_valid(const struct posix_acl *acl) { return 0; }
+static inline struct posix_acl * posix_acl_dup(struct posix_acl *acl) 
+{ 
+        return acl;
+}
+
+/*
+ * portable UNIX device file identification.
+ */
+
+typedef dev_t cfs_rdev_t;
+
+#else  /* !__KERNEL__ */
+
+typedef struct file cfs_file_t;
 
+#endif /* END __KERNEL__ */
+
+typedef struct {
+       void    *d;
+} cfs_dentry_t;
+
+#ifndef O_SYNC
 #define O_SYNC                                 0
+#endif
+#ifndef O_DIRECTORY
 #define O_DIRECTORY                            0
+#endif
+#ifndef O_LARGEFILE
 #define O_LARGEFILE                            0
+#endif
 
 #endif
index da16418..f826fef 100644 (file)
@@ -9,10 +9,6 @@
 #include <mach/sync_policy.h>
 #include <mach/task.h>
 #include <mach/semaphore.h>
-#include <mach/mach_traps.h>
-
-/* spin lock types and operations */
-#include <kern/simple_lock.h>
 #include <kern/assert.h>
 #include <kern/thread.h>
 
@@ -56,12 +52,18 @@ static inline int spin_trylock(spinlock_t *lock)
        return kspin_trylock(&lock->spin);
 }
 
+static inline void spin_lock_done(spinlock_t *lock)
+{
+       kspin_done(&lock->spin);
+}
+
+#error "does this lock out timer callbacks?"
 #define spin_lock_bh(x)                spin_lock(x)
 #define spin_unlock_bh(x)      spin_unlock(x)
 #define spin_lock_bh_init(x)   spin_lock_init(x)
 
 extern boolean_t ml_set_interrupts_enabled(boolean_t enable);
-#define __disable_irq()         (spl_t) ml_set_interrupts_enabled(FALSE)
+#define __disable_irq()         ml_set_interrupts_enabled(FALSE)
 #define __enable_irq(x)         (void) ml_set_interrupts_enabled(x)
 
 #define spin_lock_irqsave(s, f)                do{                     \
@@ -165,6 +167,11 @@ static inline void init_rwsem(struct rw_semaphore *s)
        krw_sem_init(&s->s);
 }
 
+static inline void fini_rwsem(struct rw_semaphore *s)
+{
+       krw_sem_done(&s->s);
+}
+
 static inline void down_read(struct rw_semaphore *s)
 {
        krw_sem_down_r(&s->s);
@@ -173,7 +180,7 @@ static inline void down_read(struct rw_semaphore *s)
 static inline int down_read_trylock(struct rw_semaphore *s)
 {
        int ret = krw_sem_down_r_try(&s->s);
-       return ret == 0? 1: 0;
+       return ret == 0;
 }
 
 static inline void down_write(struct rw_semaphore *s)
@@ -184,7 +191,7 @@ static inline void down_write(struct rw_semaphore *s)
 static inline int down_write_trylock(struct rw_semaphore *s)
 {
        int ret = krw_sem_down_w_try(&s->s);
-       return ret == 0? 1: 0;
+       return ret == 0;
 }
 
 static inline void up_read(struct rw_semaphore *s)
@@ -199,7 +206,6 @@ static inline void up_write(struct rw_semaphore *s)
 
 /* 
  * read-write lock : Need to be investigated more!!
- * XXX nikita: for now, let rwlock_t to be identical to rw_semaphore
  *
  * - DECLARE_RWLOCK(l)
  * - rwlock_init(x)
@@ -208,14 +214,14 @@ static inline void up_write(struct rw_semaphore *s)
  * - write_lock(x)
  * - write_unlock(x)
  */
-typedef struct rw_semaphore rwlock_t;
+typedef struct krw_spin rwlock_t;
 
-#define rwlock_init(pl)                init_rwsem(pl)
+#define rwlock_init(pl)                        krw_spin_init(pl)
 
-#define read_lock(l)           down_read(l)
-#define read_unlock(l)         up_read(l)
-#define write_lock(l)          down_write(l)
-#define write_unlock(l)                up_write(l)
+#define read_lock(l)                   krw_spin_down_r(l)
+#define read_unlock(l)                 krw_spin_up_r(l)
+#define write_lock(l)                  krw_spin_down_w(l)
+#define write_unlock(l)                        krw_spin_up_w(l)
 
 #define write_lock_irqsave(l, f)       do{                     \
                                        f = __disable_irq();    \
@@ -232,12 +238,23 @@ typedef struct rw_semaphore rwlock_t;
 #define read_unlock_irqrestore(l, f)   do{                     \
                                        read_unlock(l);         \
                                        __enable_irq(f);}while(0)
-
 /*
  * Funnel: 
  *
  * Safe funnel in/out
  */
+#ifdef __DARWIN8__
+
+#define CFS_DECL_FUNNEL_DATA
+#define CFS_DECL_CONE_DATA              DECLARE_FUNNEL_DATA
+#define CFS_DECL_NET_DATA               DECLARE_FUNNEL_DATA
+#define CFS_CONE_IN                     do {} while(0)
+#define CFS_CONE_EX                     do {} while(0)
+
+#define CFS_NET_IN                      do {} while(0)
+#define CFS_NET_EX                      do {} while(0)
+
+#else
 
 #define CFS_DECL_FUNNEL_DATA                   \
         boolean_t    __funnel_state = FALSE;   \
@@ -257,8 +274,11 @@ void lustre_net_ex(boolean_t state, funnel_t *cone);
 #define CFS_NET_IN  lustre_net_in(&__funnel_state, &__funnel)
 #define CFS_NET_EX  lustre_net_ex(__funnel_state, __funnel)
 
-/* __KERNEL__ */
 #endif
 
+#else
+#include <libcfs/user-lock.h>
+#endif /* __KERNEL__ */
+
 /* __XNU_CFS_LOCK_H */
 #endif
index 922a1b8..5ffcd4e 100644 (file)
 #include <libcfs/list.h>
 
 /*
- * Page of OSX
- *
- * There is no page in OSX, however, we need page in lustre.
- */
-#define PAGE_MASK                              (~(PAGE_SIZE-1))
-#define _ALIGN_UP(addr,size)                   (((addr)+((size)-1))&(~((size)-1)))
-#define _ALIGN(addr,size)                      _ALIGN_UP(addr,size)
-#define PAGE_ALIGN(addr)                       _ALIGN(addr, PAGE_SIZE)
-
-/*
  * Basic xnu_page struct, should be binary compatibility with
  * all page types in xnu (we have only xnu_raw_page, xll_page now)
  */
 
 /* Variable sized pages are not supported */
 
+#ifdef PAGE_SHIFT
+#define CFS_PAGE_SHIFT PAGE_SHIFT
+#else
 #define CFS_PAGE_SHIFT 12
-#define CFS_PAGE_SIZE  (1 << CFS_PAGE_SHIFT)
-#define PAGE_CACHE_SIZE CFS_PAGE_SIZE
-#define CFS_PAGE_MASK  (~(CFS_PAGE_SIZE - 1))
+#endif
+
+#define CFS_PAGE_SIZE  (1UL << CFS_PAGE_SHIFT)
+
+#define CFS_PAGE_MASK  (~((__u64)CFS_PAGE_SIZE - 1))
 
 enum {
        XNU_PAGE_RAW,
@@ -98,20 +93,16 @@ void xnu_page_ops_unregister(int type);
  * raw page, no cache object, just like buffer
  */
 struct xnu_raw_page {
-       struct xnu_page header;
-       vm_address_t    virtual;
-       upl_t           upl;
-       int             order;
-       atomic_t        count;
-       void           *private;
+       struct xnu_page  header;
+       void            *virtual;
+       atomic_t         count;
+       struct list_head link;
 };
 
 /*
  * Public interface to lustre
  *
- * - cfs_alloc_pages(f, o)
  * - cfs_alloc_page(f)
- * - cfs_free_pages(p, o)
  * - cfs_free_page(p)
  * - cfs_kmap(p)
  * - cfs_kunmap(p)
@@ -124,14 +115,12 @@ struct xnu_raw_page {
  * pages only.
  */
 
-cfs_page_t *cfs_alloc_pages(u_int32_t flags, u_int32_t order);
 cfs_page_t *cfs_alloc_page(u_int32_t flags);
-void cfs_free_pages(cfs_page_t *pages, int order);
 void cfs_free_page(cfs_page_t *page);
 void cfs_get_page(cfs_page_t *page);
 int cfs_put_page_testzero(cfs_page_t *page);
 int cfs_page_count(cfs_page_t *page);
-void cfs_set_page_count(cfs_page_t *page, int v);
+#define cfs_page_index(pg)     (0)
 
 void *cfs_page_address(cfs_page_t *pg);
 void *cfs_kmap(cfs_page_t *pg);
@@ -141,48 +130,84 @@ void cfs_kunmap(cfs_page_t *pg);
  * Memory allocator
  */
 
-extern void *cfs_alloc(size_t nr_bytes, u_int32_t flags);
-extern void  cfs_free(void *addr);
+void *cfs_alloc(size_t nr_bytes, u_int32_t flags);
+void  cfs_free(void *addr);
+
+void *cfs_alloc_large(size_t nr_bytes);
+void  cfs_free_large(void *addr);
 
-extern void *cfs_alloc_large(size_t nr_bytes);
-extern void  cfs_free_large(void *addr);
+extern int get_preemption_level(void);
+
+#define CFS_ALLOC_ATOMIC_TRY                                    \
+       (get_preemption_level() != 0 ? CFS_ALLOC_ATOMIC : 0)
 
 /*
  * Slab:
  *
- * No slab in OSX, use zone allocator to fake slab
+ * No slab in OSX, use zone allocator to simulate slab
  */
 #define SLAB_HWCACHE_ALIGN             0
 
+#ifdef __DARWIN8__
+/* 
+ * In Darwin8, we cannot use zalloc_noblock(not exported by kernel),
+ * also, direct using of zone allocator is not recommended.
+ */
+#define CFS_INDIVIDUAL_ZONE     (0)
+
+#if !CFS_INDIVIDUAL_ZONE
+#include <libkern/OSMalloc.h>
+typedef        OSMallocTag     mem_cache_t;
+#else
+typedef                void*           zone_t;
+typedef                zone_t          mem_cache_t;
+#endif
+
+#else /* !__DARWIN8__ */
+
+#define CFS_INDIVIDUAL_ZONE     (1)
+
+typedef        zone_t          mem_cache_t;
+
+#endif /* !__DARWIN8__ */
+
+#define MC_NAME_MAX_LEN                64
+
 typedef struct cfs_mem_cache {
-       struct list_head        link;
-       zone_t                  zone;
-       int                     size;
-       char                    name [ZONE_NAME_MAX_LEN];
+       int                     mc_size;
+       mem_cache_t             mc_cache;
+       struct list_head        mc_link;
+       char                    mc_name [MC_NAME_MAX_LEN];
 } cfs_mem_cache_t;
 
 #define KMEM_CACHE_MAX_COUNT   64
 #define KMEM_MAX_ZONE          8192
 
-extern cfs_mem_cache_t * cfs_mem_cache_create (const char *, size_t, size_t, unsigned long,
-                                              void (*)(void *, cfs_mem_cache_t *, unsigned long),
-                                              void (*)(void *, cfs_mem_cache_t *, unsigned long));
-extern int cfs_mem_cache_destroy ( cfs_mem_cache_t * );
-extern void *cfs_mem_cache_alloc ( cfs_mem_cache_t *, int);
-extern void cfs_mem_cache_free ( cfs_mem_cache_t *, void *);
+cfs_mem_cache_t * cfs_mem_cache_create (const char *, size_t, size_t, unsigned long);
+int cfs_mem_cache_destroy ( cfs_mem_cache_t * );
+void *cfs_mem_cache_alloc ( cfs_mem_cache_t *, int);
+void cfs_mem_cache_free ( cfs_mem_cache_t *, void *);
 
 /*
  * Misc
  */
-/* XXX fix me */
+/* XXX Liang: num_physpages... fix me */
 #define num_physpages                  (64 * 1024)
 
 #define CFS_DECL_MMSPACE               
 #define CFS_MMSPACE_OPEN               do {} while(0)
 #define CFS_MMSPACE_CLOSE              do {} while(0)
 
-#define copy_from_user(kaddr, uaddr, size)     copyin((caddr_t)uaddr, (caddr_t)kaddr, size)
-#define copy_to_user(uaddr, kaddr, size)       copyout((caddr_t)kaddr, (caddr_t)uaddr, size)
+#define copy_from_user(kaddr, uaddr, size)     copyin(CAST_USER_ADDR_T(uaddr), (caddr_t)kaddr, size)
+#define copy_to_user(uaddr, kaddr, size)       copyout((caddr_t)kaddr, CAST_USER_ADDR_T(uaddr), size)
+
+#if 0
+static inline int strncpy_from_user(char *kaddr, char *uaddr, int size)
+{
+       size_t count;
+       return copyinstr((const user_addr_t)uaddr, (void *)kaddr, size, &count);
+}
+#endif
 
 #if defined (__ppc__)
 #define mb()  __asm__ __volatile__ ("sync" : : : "memory")
@@ -198,9 +223,10 @@ extern void cfs_mem_cache_free ( cfs_mem_cache_t *, void *);
 
 #else  /* !__KERNEL__ */
 
-typedef struct cfs_page{
-       void    *foo;
-} cfs_page_t;
+#define CFS_CACHE_SHIFT 12
+#define PAGE_CACHE_SIZE (1 << CFS_CACHE_SHIFT)
+#include <libcfs/user-prim.h>
+
 #endif /* __KERNEL__ */
 
 #endif /* __XNU_CFS_MEM_H__ */
index ec9be59..00fbeed 100644 (file)
@@ -9,25 +9,29 @@
 #include <sys/types.h>
 #include <sys/systm.h>
 
-#ifndef __APPLE_API_PRIVATE
-#define __APPLE_API_PRIVATE
-#include <sys/user.h>
-#undef __APPLE_API_PRIVATE
-#else
-#include <sys/user.h>
-#endif
+#ifndef __DARWIN8__
+# ifndef __APPLE_API_PRIVATE
+#  define __APPLE_API_PRIVATE
+#  include <sys/user.h>
+#  undef __APPLE_API_PRIVATE
+# else
+#  include <sys/user.h>
+# endif
+# include <mach/mach_traps.h>
+# include <mach/thread_switch.h>
+# include <machine/cpu_number.h>
+#endif /* !__DARWIN8__ */
 
 #include <sys/kernel.h>
 
 #include <mach/thread_act.h>
 #include <mach/mach_types.h>
-#include <mach/mach_traps.h>
-#include <mach/thread_switch.h>
 #include <mach/time_value.h>
 #include <kern/sched_prim.h>
 #include <vm/pmap.h>
 #include <vm/vm_kern.h>
 #include <mach/machine/vm_param.h>
+#include <machine/machine_routines.h>
 #include <kern/clock.h>
 #include <kern/thread_call.h>
 #include <sys/param.h>
@@ -63,17 +67,19 @@ extern kern_return_t            cfs_symbol_put(const char *);
  * User can register/unregister a list of sysctl_oids
  * sysctl_oid is data struct of osx's sysctl-entry
  */
+#define        CONFIG_SYSCTL   1
+
 typedef struct sysctl_oid *     cfs_sysctl_table_t;
 typedef cfs_sysctl_table_t      cfs_sysctl_table_header_t;
-cfs_sysctl_table_header_t      *register_cfs_sysctl_table (cfs_sysctl_table_t *table, int arg);
-void unregister_cfs_sysctl_table (cfs_sysctl_table_header_t *table);
+cfs_sysctl_table_header_t      *cfs_register_sysctl_table (cfs_sysctl_table_t *table, int arg);
+void cfs_unregister_sysctl_table (cfs_sysctl_table_header_t *table);
 
 /*
  * Proc file system APIs, no /proc fs support in OSX
  */
-typedef struct cfs_proc_dir_entry{
+typedef struct cfs_proc_dir_entry {
        void            *data;
-}cfs_proc_dir_entry_t;
+} cfs_proc_dir_entry_t;
 
 cfs_proc_dir_entry_t * cfs_create_proc_entry(char *name, int mod,
                                          cfs_proc_dir_entry_t *parent);
@@ -111,12 +117,23 @@ extern kern_return_t            cfs_psdev_deregister(cfs_psdev_t *);
 extern boolean_t        assert_wait_possible(void);
 extern void             *get_bsdtask_info(task_t);
 
+#ifdef __DARWIN8__
+
+typedef struct {}              cfs_task_t;
+#define cfs_current()          ((cfs_task_t *)current_thread())
+#else  /* !__DARWIN8__ */
+
 typedef struct uthread         cfs_task_t;
+
 #define current_uthread()       ((struct uthread *)get_bsdthread_info(current_act()))
 #define cfs_current()          current_uthread()
 
+#endif /* !__DARWIN8__ */
+
+#define cfs_task_lock(t)       do {;} while (0)
+#define cfs_task_unlock(t)     do {;} while (0)
+
 #define set_current_state(s)   do {;} while (0)
-#define reparent_to_init()     do {;} while (0)
 
 #define CFS_DECL_JOURNAL_DATA  
 #define CFS_PUSH_JOURNAL       do {;} while(0)
@@ -128,109 +145,12 @@ typedef struct uthread           cfs_task_t;
  *
  * OSX kernel thread can not be created with args,
  * so we have to implement new APIs to create thread with args
- *
- * All requests to create kernel thread will create a new
- * thread instance of cfs_thread_agent, one by one.
- * cfs_thread_agent will call the caller's thread function
- * with argument supplied by caller.
  */
 
 typedef int (*cfs_thread_t)(void *);
 
 extern task_t  kernel_task;
 
-struct kernel_thread_arg
-{
-       spinlock_t      lock;
-       atomic_t        inuse;
-       cfs_thread_t    func;
-       void            *arg;
-};
-
-extern struct kernel_thread_arg cfs_thread_arg;
-extern void cfs_thread_agent(void);
-
-#define THREAD_ARG_FREE                        0
-#define THREAD_ARG_HOLD                        1
-#define THREAD_ARG_RECV                        2
-
-#define set_targ_stat(a, v)            atomic_set(&(a)->inuse, v)
-#define get_targ_stat(a)               atomic_read(&(a)->inuse)
-
-/*
- * Hold the thread argument and set the status of thread_status
- * to THREAD_ARG_HOLD, if the thread argument is held by other
- * threads (It's THREAD_ARG_HOLD already), current-thread has to wait.
- */
-#define thread_arg_hold(pta, _func, _arg)                      \
-       do {                                                    \
-               spin_lock(&(pta)->lock);                        \
-               if (get_targ_stat(pta) == THREAD_ARG_FREE) {    \
-                       set_targ_stat((pta), THREAD_ARG_HOLD);  \
-                       (pta)->arg = (void *)_arg;              \
-                       (pta)->func = _func;                    \
-                       spin_unlock(&(pta)->lock);              \
-                       break;                                  \
-               }                                               \
-               spin_unlock(&(pta)->lock);                      \
-               schedule();                                     \
-       } while(1);                                             \
-
-/*
- * Release the thread argument if the thread argument has been
- * received by the child-thread (Status of thread_args is
- * THREAD_ARG_RECV), otherwise current-thread has to wait.
- * After release, the thread_args' status will be set to
- * THREAD_ARG_FREE, and others can re-use the thread_args to
- * create new kernel_thread.
- */
-#define thread_arg_release(pta)                                        \
-       do {                                                    \
-               spin_lock(&(pta)->lock);                        \
-               if (get_targ_stat(pta) == THREAD_ARG_RECV) {    \
-                       (pta)->arg = NULL;                      \
-                       (pta)->func = NULL;                     \
-                       set_targ_stat(pta, THREAD_ARG_FREE);    \
-                       spin_unlock(&(pta)->lock);              \
-                       break;                                  \
-               }                                               \
-               spin_unlock(&(pta)->lock);                      \
-               schedule();                                     \
-       } while(1)
-
-/*
- * Receive thread argument (Used in child thread), set the status
- * of thread_args to THREAD_ARG_RECV.
- */
-#define __thread_arg_recv_fin(pta, _func, _arg, fin)           \
-       do {                                                    \
-               spin_lock(&(pta)->lock);                        \
-               if (get_targ_stat(pta) == THREAD_ARG_HOLD) {    \
-                       if (fin)                                \
-                           set_targ_stat(pta, THREAD_ARG_RECV);\
-                       _arg = (pta)->arg;                      \
-                       _func = (pta)->func;                    \
-                       spin_unlock(&(pta)->lock);              \
-                       break;                                  \
-               }                                               \
-               spin_unlock(&(pta)->lock);                      \
-               schedule();                                     \
-       } while (1);                                            \
-
-/*
- * Just set the thread_args' status to THREAD_ARG_RECV
- */
-#define thread_arg_fin(pta)                                    \
-       do {                                                    \
-               spin_lock(&(pta)->lock);                        \
-               assert( get_targ_stat(pta) == THREAD_ARG_HOLD); \
-               set_targ_stat(pta, THREAD_ARG_RECV);            \
-               spin_unlock(&(pta)->lock);                      \
-       } while(0)
-
-#define thread_arg_recv(pta, f, a)     __thread_arg_recv_fin(pta, f, a, 1)
-#define thread_arg_keep(pta, f, a)     __thread_arg_recv_fin(pta, f, a, 0)
-
 /*
  * cloning flags, no use in OSX, just copy them from Linux
  */
@@ -265,11 +185,16 @@ typedef struct cfs_waitlink {
        struct ksleep_link  wl_ksleep_link;
 } cfs_waitlink_t;
 
+typedef int cfs_task_state_t;
+
+#define CFS_TASK_INTERRUPTIBLE THREAD_ABORTSAFE
+#define CFS_TASK_UNINT         THREAD_UNINT
+
 void cfs_waitq_init(struct cfs_waitq *waitq);
 void cfs_waitlink_init(struct cfs_waitlink *link);
 
 void cfs_waitq_add(struct cfs_waitq *waitq, struct cfs_waitlink *link);
-void cfs_waitq_add_exclusive(struct cfs_waitq *waitq, 
+void cfs_waitq_add_exclusive(struct cfs_waitq *waitq,
                             struct cfs_waitlink *link);
 void cfs_waitq_forward(struct cfs_waitlink *link, struct cfs_waitq *waitq);
 void cfs_waitq_del(struct cfs_waitq *waitq, struct cfs_waitlink *link);
@@ -279,29 +204,37 @@ void cfs_waitq_signal(struct cfs_waitq *waitq);
 void cfs_waitq_signal_nr(struct cfs_waitq *waitq, int nr);
 void cfs_waitq_broadcast(struct cfs_waitq *waitq);
 
-void cfs_waitq_wait(struct cfs_waitlink *link);
-cfs_duration_t cfs_waitq_timedwait(struct cfs_waitlink *link, 
+void cfs_waitq_wait(struct cfs_waitlink *link, cfs_task_state_t state);
+cfs_duration_t cfs_waitq_timedwait(struct cfs_waitlink *link,
+                                  cfs_task_state_t state, 
                                   cfs_duration_t timeout);
 
 /*
  * Thread schedule APIs.
  */
 #define MAX_SCHEDULE_TIMEOUT    ((long)(~0UL>>12))
+extern void thread_set_timer_deadline(uint64_t deadline);
+extern void thread_cancel_timer(void);
 
-static inline int schedule_timeout(int64_t timeout)
+static inline int cfs_schedule_timeout(int state, int64_t timeout)
 {
        int          result;
        
-       AbsoluteTime clock_current;
-       AbsoluteTime clock_delay;
-       result = assert_wait((event_t)current_uthread(), THREAD_UNINT);
-       clock_get_uptime(&clock_current);
-       nanoseconds_to_absolutetime(timeout, &clock_delay);
-       ADD_ABSOLUTETIME(&clock_current, &clock_delay);
-       thread_set_timer_deadline(clock_current);
+#ifdef __DARWIN8__
+       result = assert_wait((event_t)current_thread(), state);
+#else
+       result = assert_wait((event_t)current_uthread(), state);
+#endif
+       if (timeout > 0) {
+               uint64_t expire;
+               nanoseconds_to_absolutetime(timeout, &expire);
+               clock_absolutetime_interval_to_deadline(expire, &expire);
+               thread_set_timer_deadline(expire);
+       }
        if (result == THREAD_WAITING)
                result = thread_block(THREAD_CONTINUE_NULL);
-       thread_cancel_timer();
+       if (timeout > 0)
+               thread_cancel_timer();
        if (result == THREAD_TIMED_OUT)
                result = 0;
        else
@@ -309,47 +242,80 @@ static inline int schedule_timeout(int64_t timeout)
        return result;
 }
 
-#define schedule()                              \
-       do {                                    \
-               if (assert_wait_possible())     \
-                       schedule_timeout(1);    \
-               else                            \
-                       schedule_timeout(0);    \
-       } while (0)
+#define cfs_schedule() cfs_schedule_timeout(CFS_TASK_UNINT, CFS_TICK)
+#define cfs_pause(tick)        cfs_schedule_timeout(CFS_TASK_UNINT, tick)
+
+#define __wait_event(wq, condition)                            \
+do {                                                           \
+       struct cfs_waitlink __wait;                             \
+                                                               \
+       cfs_waitlink_init(&__wait);                             \
+       for (;;) {                                              \
+               cfs_waitq_add(&wq, &__wait);                    \
+               if (condition)                                  \
+                       break;                                  \
+               cfs_waitq_wait(&__wait, CFS_TASK_UNINT);        \
+               cfs_waitq_del(&wq, &__wait);                    \
+       }                                                       \
+       cfs_waitq_del(&wq, &__wait);                            \
+} while (0)
 
-#define __wait_event(wq, condition)            \
-do {                                           \
-       struct cfs_waitlink __wait;             \
-                                               \
-       cfs_waitlink_init(&__wait);             \
-       for (;;) {                              \
-               cfs_waitq_add(&wq, &__wait);    \
-               if (condition)                  \
-                       break;                  \
-               cfs_waitq_wait(&__wait);        \
-               cfs_waitq_del(&wq, &__wait);    \
-       }                                       \
-       cfs_waitq_del(&wq, &__wait);            \
+#define wait_event(wq, condition)                              \
+do {                                                           \
+       if (condition)                                          \
+               break;                                          \
+       __wait_event(wq, condition);                            \
 } while (0)
 
-#define wait_event(wq, condition)                                      \
-do {                                                                   \
-       if (condition)                                                  \
-               break;                                                  \
-       __wait_event(wq, condition);                                    \
+#define __wait_event_interruptible(wq, condition, ex, ret)     \
+do {                                                           \
+       struct cfs_waitlink __wait;                             \
+                                                               \
+       cfs_waitlink_init(&__wait);                             \
+       for (;;) {                                              \
+               if (ex == 0)                                    \
+                       cfs_waitq_add(&wq, &__wait);            \
+               else                                            \
+                       cfs_waitq_add_exclusive(&wq, &__wait);  \
+               if (condition)                                  \
+                       break;                                  \
+               if (!cfs_signal_pending()) {                    \
+                       cfs_waitq_wait(&__wait,                 \
+                                      CFS_TASK_INTERRUPTIBLE); \
+                       cfs_waitq_del(&wq, &__wait);            \
+                       continue;                               \
+               }                                               \
+               ret = -ERESTARTSYS;                             \
+               break;                                          \
+       }                                                       \
+       cfs_waitq_del(&wq, &__wait);                            \
 } while (0)
 
-#define wait_event_interruptible(wq, condition)        \
-({                                             \
-       wait_event(wq, condition);              \
-       0;                                      \
+#define wait_event_interruptible(wq, condition)                        \
+({                                                             \
+       int __ret = 0;                                          \
+       if (!condition)                                         \
+               __wait_event_interruptible(wq, condition,       \
+                                          0, __ret);           \
+       __ret;                                                  \
 })
 
+#define wait_event_interruptible_exclusive(wq, condition)      \
+({                                                             \
+       int __ret = 0;                                          \
+       if (!condition)                                         \
+               __wait_event_interruptible(wq, condition,       \
+                                          1, __ret);           \
+       __ret;                                                  \
+})
+
+#ifndef __DARWIN8__
 extern void    wakeup_one __P((void * chan));
+#endif
 /* only used in tests */
-#define wake_up_process(p)                     \
-       do {                                    \
-               wakeup_one(p);                  \
+#define wake_up_process(p)                                     \
+       do {                                                    \
+               wakeup_one((caddr_t)p);                         \
        } while (0)
        
 /* used in couple of places */
@@ -359,48 +325,19 @@ static inline void sleep_on(cfs_waitq_t *waitq)
        
        cfs_waitlink_init(&link);
        cfs_waitq_add(waitq, &link);
-       cfs_waitq_wait(&link);
+       cfs_waitq_wait(&link, CFS_TASK_UNINT);
        cfs_waitq_del(waitq, &link);
 }
 
 /*
- * XXX
  * Signal
  */
-#define cfs_sigmask_lock(t, f)         do { f = 0; } while(0)
-#define cfs_sigmask_unlock(t, f)       do { f = 0; } while(0)
-#define cfs_signal_pending(t)          (0)
-
-#define cfs_siginitset(pmask, sigs)                            \
-       do {                                                    \
-               sigset_t __sigs = sigs & (~sigcantmask);        \
-               *(pmask) = __sigs;                              \
-       } while(0)
-
-#define cfs_siginitsetinv(pmask, sigs)                          \
-       do {                                                    \
-               sigset_t __sigs = ~(sigs | sigcantmask);        \
-               *(pmask) = __sigs;                              \
-       } while(0)
-
-#define cfs_recalc_sigpending(ut)                              \
-        do {                                                   \
-               (ut)->uu_siglist = (ut)->uu_siglist & ~(ut)->uu_sigmask;\
-       } while (0)
-#define cfs_sigfillset(s)                                      \
-       do {                                                    \
-               memset((s), -1, sizeof(sigset_t));              \
-       } while(0)
-
-#define cfs_set_sig_blocked(ut, b)             do {(ut)->uu_sigmask = b;} while(0)
-#define cfs_get_sig_blocked(ut)                        (&(ut)->uu_sigmask)
+typedef sigset_t       cfs_sigset_t;
 
 #define SIGNAL_MASK_ASSERT()
-
 /*
  * Timer
  */
-
 typedef struct cfs_timer {
        struct ktimer t;
 } cfs_timer_t;
@@ -434,20 +371,27 @@ cfs_time_t cfs_timer_deadline(struct cfs_timer *t);
 /*
  * CPU
  */
-#include <machine/cpu_number.h>
 /* Run in PowerG5 who is PPC64 */
 #define SMP_CACHE_BYTES                         128
 #define __cacheline_aligned                     __attribute__((__aligned__(SMP_CACHE_BYTES)))
-/* XXX How to get the value of NCPUS from xnu ? */
 #define NR_CPUS                                        2
-#define smp_processor_id()                     cpu_number()
-#define smp_num_cpus                           NR_CPUS
+
+/* 
+ * XXX Liang: patch xnu and export current_processor()?
+ *
+ * #define smp_processor_id()                  current_processor()
+ */
+#define smp_processor_id()                     0
 /* XXX smp_call_function is not supported in xnu */
 #define smp_call_function(f, a, n, w)          do {} while(0)
+int cfs_online_cpus(void);
+#define smp_num_cpus                           cfs_online_cpus()
 
 /*
  * Misc
  */
+extern int is_suser(void);
+
 #ifndef likely
 #define likely(exp) (exp)
 #endif
@@ -458,11 +402,9 @@ cfs_time_t cfs_timer_deadline(struct cfs_timer *t);
 #define lock_kernel()                          do {} while(0)
 #define unlock_kernel()                                do {} while(0)
 
-#define exit_mm(t)                             do {} while(0)
-#define exit_files(t)                          do {} while(0)
-
-#define CAP_SYS_ADMIN                           0
-#define capable(a)             suser(current_proc()->p_ucred, &(current_proc()->p_acflag))
+#define CAP_SYS_BOOT                           0
+#define CAP_SYS_ADMIN                           1
+#define capable(a)                             ((a) == CAP_SYS_BOOT ? is_suser(): is_suser1())
 
 #define USERMODEHELPER(path, argv, envp)       (0)
 
@@ -499,6 +441,11 @@ struct __dummy_ ## name ## _struct {}
 #define inter_module_get(n)                    cfs_symbol_get(n)
 #define inter_module_put(n)                    cfs_symbol_put(n)
 
+static inline int request_module(char *name)
+{
+       return (-EINVAL);
+}
+
 #ifndef __exit
 #define __exit
 #endif
@@ -517,7 +464,7 @@ struct __dummy_ ## name ## _struct {}
 #define LINUX_VERSION_CODE KERNEL_VERSION(2,5,0)
 
 #define NR_IRQS                                512
-#define in_interrupt()                 (0)
+#define in_interrupt()                 ml_at_interrupt_context()
 
 #define KERN_EMERG      "<0>"   /* system is unusable                   */
 #define KERN_ALERT      "<1>"   /* action must be taken immediately     */
@@ -534,21 +481,47 @@ static inline long PTR_ERR(const void *ptr)
 }
 
 #define ERR_PTR(err)   ((void *)err)
+#define IS_ERR(p)      ((unsigned long)(p) + 1000 < 1000)
+
+#else  /* !__KERNEL__ */
 
-/* XXX */
-#define IS_ERR(p)      (0)
+typedef struct cfs_proc_dir_entry {
+       void            *data;
+} cfs_proc_dir_entry_t;
+
+#include <libcfs/user-prim.h>
+#define __WORDSIZE     32
 
+#endif /* END __KERNEL__ */
 /*
  * Error number
  */
+#ifndef EPROTO
+#define EPROTO          EPROTOTYPE
+#endif
+#ifndef EBADR
 #define EBADR          EBADRPC
-#define ERESTARTSYS    ERESTART
+#endif
+#ifndef ERESTARTSYS
+#define ERESTARTSYS    512
+#endif
+#ifndef EDEADLOCK
 #define EDEADLOCK      EDEADLK
+#endif
+#ifndef ECOMM
 #define ECOMM          EINVAL
+#endif
+#ifndef ENODATA
 #define ENODATA                EINVAL
+#endif
+#ifndef ENOTSUPP
+#define ENOTSUPP       EINVAL
+#endif
 
+#if BYTE_ORDER == BIG_ENDIAN
+# define __BIG_ENDIAN
 #else
-#define __WORDSIZE     32
-#endif /* __KERNEL__ */
+# define __LITTLE_ENDIAN
+#endif
 
-#endif /* __LINUX__ */
+#endif /* __LIBCFS_DARWIN_CFS_PRIM_H__ */
index 3374f43..5a3fabd 100644 (file)
@@ -1,7 +1,8 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- * Lustre Light Super operations
+ * Implementation of standard libcfs synchronization primitives for XNU
+ * kernel.
  *
  *  Copyright (c) 2004 Cluster File Systems, Inc.
  *
@@ -33,7 +34,7 @@
 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
 #endif
 
-#define XNU_SYNC_DEBUG (0)
+#define XNU_SYNC_DEBUG (1)
 
 #if XNU_SYNC_DEBUG
 #define ON_SYNC_DEBUG(e) e
@@ -48,6 +49,7 @@ enum {
        KCOND_MAGIC = 0xb01dface,
        KRW_MAGIC   = 0xdabb1edd,
        KSPIN_MAGIC = 0xca11ab1e,
+        KRW_SPIN_MAGIC    = 0xbabeface,
        KSLEEP_CHAN_MAGIC = 0x0debac1e,
        KSLEEP_LINK_MAGIC = 0xacc01ade,
        KTIMER_MAGIC      = 0xbefadd1e
@@ -60,25 +62,63 @@ enum {
  */
 #define SMP (1)
 
+#include <libcfs/list.h>
+
+#ifdef __DARWIN8__
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <kern/locks.h>
+
+/*
+ * hw_lock is not available in Darwin8 (hw_lock_* are not exported at all), 
+ * so use lck_spin_t. we can hack out lck_spin_t easily, it's the only 
+ * hacking in Darwin8.x. We did so because it'll take a lot of time to 
+ * add lock_done for all locks, maybe it should be done in the future.
+ * If lock_done for all locks were added, we can:
+ *
+ * typedef lck_spin_t      *xnu_spin_t;
+ */
+#if defined (__ppc__)
+typedef struct {
+        unsigned int    opaque[3];
+} xnu_spin_t;
+#elif defined (__i386__)
+typedef struct {
+        unsigned int    opaque[10];
+} xnu_spin_t;
+#endif
+
+/* 
+ * wait_queue is not available in Darwin8 (wait_queue_* are not exported), 
+ * use assert_wait/wakeup/wake_one (wait_queue in kernel hash).
+ */
+typedef void * xnu_wait_queue_t;
+
+/* DARWIN8 */
+#else
+
+#include <mach/mach_types.h>
+#include <sys/types.h>
 #include <kern/simple_lock.h>
 
-#include <libcfs/list.h>
+typedef hw_lock_data_t          xnu_spin_t;
+typedef struct wait_queue       xnu_wait_queue_t;
+
+/* DARWIN8 */
+#endif
 
 struct kspin {
 #if SMP
-       hw_lock_data_t lock;
+       xnu_spin_t      lock;
 #endif
 #if XNU_SYNC_DEBUG
-       unsigned magic;
-       thread_t owner;
+       unsigned        magic;
+       thread_t        owner;
 #endif
 };
 
-/*
- * XXX nikita: we cannot use simple_* functions, because bsd/sys/lock.h
- * redefines them to nothing. Use low-level hw_lock_* instead.
- */
-
 void kspin_init(struct kspin *spin);
 void kspin_done(struct kspin *spin);
 void kspin_lock(struct kspin *spin);
@@ -98,11 +138,27 @@ int kspin_isnotlocked(struct kspin *spin);
 #define kspin_isnotlocked(s) (1)
 #endif
 
+/* ------------------------- rw spinlock ----------------------- */
+struct krw_spin {
+        struct kspin      guard;
+        int               count;
+#if XNU_SYNC_DEBUG
+        unsigned          magic;
+#endif
+};
+
+void krw_spin_init(struct krw_spin *sem);
+void krw_spin_done(struct krw_spin *sem);
+void krw_spin_down_r(struct krw_spin *sem);
+void krw_spin_down_w(struct krw_spin *sem);
+void krw_spin_up_r(struct krw_spin *sem);
+void krw_spin_up_w(struct krw_spin *sem);
+
 /* ------------------------- semaphore ------------------------- */
 
 struct ksem {
         struct kspin      guard;
-        struct wait_queue q;
+        xnu_wait_queue_t  q;
         int               value;
 #if XNU_SYNC_DEBUG
         unsigned          magic;
@@ -225,20 +281,20 @@ void ksleep_link_done(struct ksleep_link *link);
 void ksleep_add(struct ksleep_chan *chan, struct ksleep_link *link);
 void ksleep_del(struct ksleep_chan *chan, struct ksleep_link *link);
 
-void ksleep_wait(struct ksleep_chan *chan);
-int64_t  ksleep_timedwait(struct ksleep_chan *chan, uint64_t timeout);
+void ksleep_wait(struct ksleep_chan *chan, int state);
+int64_t  ksleep_timedwait(struct ksleep_chan *chan, int state, uint64_t timeout);
 
 void ksleep_wake(struct ksleep_chan *chan);
 void ksleep_wake_all(struct ksleep_chan *chan);
 void ksleep_wake_nr(struct ksleep_chan *chan, int nr);
 
-#define KSLEEP_LINK_DECLARE(name)                      \
-{                                                      \
-       .flags   = 0,                                   \
-       .event   = 0,                                   \
-       .hits    = 0,                                   \
-       .linkage = PTL_LIST_HEAD_INIT(name.linkage),    \
-       .magic   = KSLEEP_LINK_MAGIC                    \
+#define KSLEEP_LINK_DECLARE(name)               \
+{                                               \
+       .flags   = 0,                           \
+       .event   = 0,                           \
+       .hits    = 0,                           \
+       .linkage = CFS_LIST_HEAD(name.linkage), \
+       .magic   = KSLEEP_LINK_MAGIC            \
 }
 
 /* ------------------------- timer ------------------------- */
diff --git a/lnet/include/libcfs/darwin/darwin-tcpip.h b/lnet/include/libcfs/darwin/darwin-tcpip.h
new file mode 100644 (file)
index 0000000..1a73891
--- /dev/null
@@ -0,0 +1,90 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ *  Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
+ *
+ *   This file is part of Lustre, http://www.lustre.org.
+ *
+ *   Lustre is free software; you can redistribute it and/or
+ *   modify it under the terms of version 2 of the GNU General Public
+ *   License as published by the Free Software Foundation.
+ *
+ *   Lustre is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with Lustre; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Basic library routines. 
+ *
+ */
+
+#ifndef __LIBCFS_DARWIN_TCPIP_H__
+#define __LIBCFS_DARWIN_TCPIP_H__
+
+#ifdef __KERNEL__
+#include <sys/socket.h>
+
+#ifdef __DARWIN8__
+
+struct socket;
+
+typedef void    (*so_upcall)(socket_t sock, void* arg, int waitf);
+
+#define CFS_SOCK_UPCALL         0x1
+#define CFS_SOCK_DOWN           0x2
+
+#define CFS_SOCK_MAGIC          0xbabeface
+
+typedef struct cfs_socket {
+        socket_t        s_so;
+        int             s_magic;
+        int             s_flags;
+        so_upcall       s_upcall;
+        void           *s_upcallarg;
+} cfs_socket_t;
+
+
+/* cfs_socket_t to bsd socket */
+#define C2B_SOCK(s)             ((s)->s_so)     
+
+static inline int get_sock_intopt(socket_t so, int opt)
+{
+        int     val, len;
+        int     rc;
+
+        /*
+         * sock_getsockopt will take a lock(mutex) for socket,
+         * so it can be blocked. So be careful while using 
+         * them.
+         */
+        len = sizeof(val);
+        rc = sock_getsockopt(so, SOL_SOCKET, opt, &val, &len);
+        assert(rc == 0);
+        return val;
+}
+
+#define SOCK_ERROR(s)           get_sock_intopt(C2B_SOCK(s), SO_ERROR)        
+/* #define SOCK_WMEM_QUEUED(s)     (0) */
+#define SOCK_WMEM_QUEUED(s)     get_sock_intopt(C2B_SOCK(s), SO_NWRITE)
+/* XXX Liang: no reliable way to get it in Darwin8.x */
+#define SOCK_TEST_NOSPACE(s)    (0)
+
+void libcfs_sock_set_cb(cfs_socket_t *sock, so_upcall callback, void *arg);
+void libcfs_sock_reset_cb(cfs_socket_t *sock);
+
+#else /* !__DARWIN8__ */
+
+#define SOCK_WMEM_QUEUED(so)    ((so)->so_snd.sb_cc)
+#define SOCK_ERROR(so)          ((so)->so_error)
+
+#define SOCK_TEST_NOSPACE(so)   (sbspace(&(so)->so_snd) < (so)->so_snd.sb_lowat)
+
+#endif /* !__DARWIN8__ */
+
+#endif /* __KERNEL END */
+
+#endif  /* __XNU_CFS_TYPES_H__ */
index d6230ad..43ad274 100644 (file)
  *  int            cfs_fs_time_before (cfs_fs_time_t *, cfs_fs_time_t *);
  *  int            cfs_fs_time_beforeq(cfs_fs_time_t *, cfs_fs_time_t *);
  *
- *  cfs_duration_t cfs_time_minimal_timeout(void)
- *
  *  CFS_TIME_FORMAT
  *  CFS_DURATION_FORMAT
  *
  */
 
 #define ONE_BILLION ((u_int64_t)1000000000)
-#define ONE_MILLION ((u_int64_t)   1000000)
+#define ONE_MILLION 1000000
 
 #ifdef __KERNEL__
 #include <sys/types.h>
 #include <sys/systm.h>
 
-#ifndef __APPLE_API_PRIVATE
-#define __APPLE_API_PRIVATE
-#include <sys/user.h>
-#undef __APPLE_API_PRIVATE
-#else
-#include <sys/user.h>
-#endif
-
 #include <sys/kernel.h>
 
-#include <mach/thread_act.h>
 #include <mach/mach_types.h>
-#include <mach/mach_traps.h>
-#include <mach/thread_switch.h>
 #include <mach/time_value.h>
-#include <kern/sched_prim.h>
-#include <vm/pmap.h>
-#include <vm/vm_kern.h>
-#include <mach/machine/vm_param.h>
 #include <kern/clock.h>
-#include <kern/thread_call.h>
 #include <sys/param.h>
-#include <sys/vm.h>
 
 #include <libcfs/darwin/darwin-types.h>
 #include <libcfs/darwin/darwin-utils.h>
 #include <libcfs/darwin/darwin-lock.h>
 
+/*
+ * There are three way to measure time in OS X:
+ * 1. nanoseconds
+ * 2. absolute time (abstime unit equal to the length of one bus cycle),
+ *    schedule of thread/timer are counted by absolute time, but abstime
+ *    in different mac can be different also, so we wouldn't use it.
+ * 3. clock interval (1sec = 100hz). But clock interval only taken by KPI
+ *    like tsleep().
+ *
+ * We use nanoseconds (uptime, not calendar time)
+ *
+ * clock_get_uptime()   :get absolute time since bootup.
+ * nanouptime()         :get nanoseconds since bootup
+ * microuptime()        :get microseonds since bootup
+ * nanotime()           :get nanoseconds since epoch
+ * microtime()          :get microseconds since epoch
+ */
 typedef u_int64_t cfs_time_t; /* nanoseconds */
 typedef int64_t cfs_duration_t;
 
@@ -118,15 +116,15 @@ static inline cfs_time_t cfs_time_current(void)
 {
         struct timespec instant;
 
-        nanotime(&instant);
-        return ((u_int64_t)instant.tv_sec) * ONE_BILLION + instant.tv_nsec;
+        nanouptime(&instant);
+        return ((u_int64_t)instant.tv_sec) * NSEC_PER_SEC + instant.tv_nsec;
 }
 
 static inline time_t cfs_time_current_sec(void)
 {
         struct timespec instant;
 
-        nanotime(&instant);
+        nanouptime(&instant);
        return instant.tv_sec;
 }
 
@@ -152,7 +150,7 @@ static inline int cfs_time_beforeq(cfs_time_t t1, cfs_time_t t2)
 
 static inline void cfs_fs_time_current(cfs_fs_time_t *t)
 {
-        *t = time;
+        microtime((struct timeval *)t);
 }
 
 static inline time_t cfs_fs_time_sec(cfs_fs_time_t *t)
@@ -160,12 +158,6 @@ static inline time_t cfs_fs_time_sec(cfs_fs_time_t *t)
         return t->tv_sec;
 }
 
-static inline cfs_duration_t cfs_duration_build(int64_t nano)
-{
-        return nano;
-}
-
-
 static inline void cfs_fs_time_usec(cfs_fs_time_t *t, struct timeval *v)
 {
         *v = *t;
@@ -174,17 +166,12 @@ static inline void cfs_fs_time_usec(cfs_fs_time_t *t, struct timeval *v)
 static inline void cfs_fs_time_nsec(cfs_fs_time_t *t, struct timespec *s)
 {
         s->tv_sec  = t->tv_sec;
-        s->tv_nsec = t->tv_usec * 1000;
+        s->tv_nsec = t->tv_usec * NSEC_PER_USEC;
 }
 
 static inline cfs_duration_t cfs_time_seconds(int seconds)
 {
-       return cfs_duration_build(ONE_BILLION * (int64_t)seconds);
-}
-
-static inline cfs_time_t cfs_time_shift(int seconds)
-{
-       return cfs_time_add(cfs_time_current(), cfs_time_seconds(seconds));
+       return (NSEC_PER_SEC * (int64_t)seconds);
 }
 
 /*
@@ -192,7 +179,7 @@ static inline cfs_time_t cfs_time_shift(int seconds)
  */
 static inline int64_t __cfs_fs_time_flat(cfs_fs_time_t *t)
 {
-        return ((int64_t)t->tv_sec) * ONE_BILLION + t->tv_usec;
+        return ((int64_t)t->tv_sec)*NSEC_PER_SEC + t->tv_usec*NSEC_PER_USEC;
 }
 
 static inline int cfs_fs_time_before(cfs_fs_time_t *t1, cfs_fs_time_t *t2)
@@ -207,29 +194,33 @@ static inline int cfs_fs_time_beforeq(cfs_fs_time_t *t1, cfs_fs_time_t *t2)
 
 static inline time_t cfs_duration_sec(cfs_duration_t d)
 {
-        return d / ONE_BILLION;
+        return d / NSEC_PER_SEC;
 }
 
 static inline void cfs_duration_usec(cfs_duration_t d, struct timeval *s)
 {
-        s->tv_sec = d / ONE_BILLION;
-        s->tv_usec = (d - s->tv_sec * ONE_BILLION) / 1000;
+        s->tv_sec = d / NSEC_PER_SEC;
+        s->tv_usec = (d - ((int64_t)s->tv_sec) * NSEC_PER_SEC) / NSEC_PER_USEC;
 }
 
 static inline void cfs_duration_nsec(cfs_duration_t d, struct timespec *s)
 {
-        s->tv_sec = d / ONE_BILLION;
-        s->tv_nsec = d - ((int64_t)s->tv_sec) * ONE_BILLION;
+        s->tv_sec = d / NSEC_PER_SEC;
+        s->tv_nsec = d - ((int64_t)s->tv_sec) * NSEC_PER_SEC;
 }
 
-static inline cfs_duration_t cfs_time_minimal_timeout(void)
-{
-        return ONE_BILLION / (u_int64_t)hz;
-}
+#define cfs_time_current_64 cfs_time_current
+#define cfs_time_add_64     cfs_time_add
+#define cfs_time_shift_64   cfs_time_shift
+#define cfs_time_before_64  cfs_time_before
 
-/* inline function cfs_time_minimal_timeout() can not be used to
- * initiallize static variable */
-#define CFS_MIN_DELAY          (ONE_BILLION / (u_int64_t)100)
+/* 
+ * One jiffy (in nanoseconds)
+ *
+ * osfmk/kern/sched_prim.c
+ * #define DEFAULT_PREEMPTION_RATE      100
+ */
+#define CFS_TICK               (NSEC_PER_SEC / (u_int64_t)100)
 
 #define LTIME_S(t)             (t)
 
index b2762c0..0fd2966 100644 (file)
 #include <mach/mach_types.h>
 #include <sys/types.h>
 
-typedef u_int8_t  __u8;
-typedef u_int16_t __u16;
-typedef u_int32_t __u32;
-typedef u_int64_t __u64;
+#ifndef _BLKID_TYPES_H
+#define _BLKID_TYPES_H
+#endif
+
+typedef u_int8_t        __u8;
+typedef u_int16_t       __u16;
+typedef u_int32_t       __u32;
+typedef u_int64_t       __u64;
+typedef int8_t          __s8;
+typedef int16_t         __s16;
+typedef int32_t         __s32;
+typedef int64_t         __s64;
 
 #ifdef __KERNEL__
 
 #include <kern/kern_types.h>
 
-#ifndef __s32
-typedef __signed__ int                 __s32;
-#endif
-#ifndef __s64
-typedef __signed__ long long           __s64;
-#endif
 
 typedef struct { int e; }              event_chan_t;
 typedef dev_t                          kdev_t;
@@ -61,22 +63,30 @@ typedef struct { volatile uint32_t counter; }       atomic_t;
 #define ATOMIC_INIT(i)                 { (i) }
 #define atomic_read(a)                 ((a)->counter)
 #define atomic_set(a, v)               (((a)->counter) = (v))
+#ifdef __DARWIN8__
+#define atomic_add(v, a)               OSAddAtomic(v, (SInt32 *)&((a)->counter))
+#define atomic_sub(v, a)               OSAddAtomic(-(v), (SInt32 *)&((a)->counter))
+#define atomic_inc(a)                  OSIncrementAtomic((SInt32 *)&((a)->counter))
+#define atomic_dec(a)                  OSDecrementAtomic((SInt32 *)&((a)->counter))
+#else /* !__DARWIN8__ */
 #define atomic_add(v, a)               hw_atomic_add((uint32_t *)&((a)->counter), v)
 #define atomic_sub(v, a)               hw_atomic_sub((uint32_t *)&((a)->counter), v)
 #define atomic_inc(a)                  atomic_add(1, a)
 #define atomic_dec(a)                  atomic_sub(1, a)
-#define atomic_sub_and_test(v, a)      ( atomic_sub(v, a) == 0 )
-#define atomic_dec_and_test(a)         ( atomic_dec(a) == 0 )
+#endif /* !__DARWIN8__ */
+#define atomic_sub_and_test(v, a)      ( atomic_sub(v, a) == -(a) )
+#define atomic_dec_and_test(a)         ( atomic_dec(a) == 1 )
 
 #include <libsa/mach/mach.h>
-typedef uint64_t                       loff_t;
+typedef off_t                          loff_t;
 
 #else  /* !__KERNEL__ */
 
 #include <stdint.h>
 
-typedef uint64_t                       loff_t;
+typedef off_t                          loff_t;
 
 #endif /* __KERNEL END */
+typedef unsigned short                  umode_t;
 
 #endif  /* __XNU_CFS_TYPES_H__ */
index 4e91db9..0f808a2 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef __LIBCFS_DARWIN_XNU_UTILS_H__
-#define __LIBCFS_DARWIN_XNU_UTILS_H__
+#ifndef __LIBCFS_DARWIN_UTILS_H__
+#define __LIBCFS_DARWIN_UTILS_H__
 
 #ifndef __LIBCFS_LIBCFS_H__
 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
@@ -57,4 +57,11 @@ char * ul2dstr(unsigned long address, char *buf, int len);
 
 #define HIPQUAD NIPQUAD
 
+#ifndef LIST_CIRCLE
+#define LIST_CIRCLE(elm, field)                                 \
+       do {                                                    \
+               (elm)->field.le_prev = &(elm)->field.le_next;   \
+       } while (0)
+#endif
+
 #endif /* __XNU_UTILS_H__ */
index 5c1acc4..f9e94b1 100644 (file)
 
 #include <libcfs/darwin/darwin-lock.h>
 #include <libcfs/darwin/darwin-prim.h>
-#include <portals/p30.h>
+#include <lnet/lnet.h>
 
-#define our_cond_resched()              schedule_timeout(1);
+#define our_cond_resched() cfs_schedule_timeout(CFS_TASK_INTERRUPTIBLE, 1)
 
 #ifdef CONFIG_SMP
 #define LASSERT_SPIN_LOCKED(lock) do {} while(0) /* XXX */
 #else
 #define LASSERT_SPIN_LOCKED(lock) do {} while(0)
 #endif
+#define LASSERT_SEM_LOCKED(sem) do {} while(0) /* XXX */
 
-#define LBUG_WITH_LOC(file, func, line)         portals_catastrophe = 1
+#define LIBCFS_PANIC(msg) panic(msg)
+#error libcfs_register_panic_notifier() missing
+#error libcfs_unregister_panic_notifier() missing
 
 /* --------------------------------------------------------------------- */
 
 #define PORTAL_MODULE_USE                       do{int i = 0; i++;}while(0)
 #define PORTAL_MODULE_UNUSE                     do{int i = 0; i--;}while(0)
 
-#define printk(format, args...)                 printf(format, ## args)
+#define num_online_cpus()                       cfs_online_cpus()
+
+/******************************************************************************/
+/* XXX Liang: There is no module parameter supporting in OSX */
+#define CFS_MODULE_PARM(name, t, type, perm, desc)
+
+#define CFS_SYSFS_MODULE_PARM    0 /* no sysfs access to module parameters */
+/******************************************************************************/
 
 #else  /* !__KERNEL__ */
 # include <stdio.h>
 # include <sys/types.h>
 #endif
 
+#define BITS_PER_LONG   LONG_BIT
 /******************************************************************************/
 /* Light-weight trace
  * Support for temporary event tracing with minimal Heisenberg effect. */
 #define LWT_SUPPORT  0
 
-typedef struct { 
-        long long   lwte_when; 
-        char       *lwte_where; 
-        void       *lwte_task; 
-        long        lwte_p1; 
-        long        lwte_p2; 
-        long        lwte_p3; 
-        long        lwte_p4; 
+typedef struct {
+        long long   lwte_when;
+        char       *lwte_where;
+        void       *lwte_task;
+        long        lwte_p1;
+        long        lwte_p2;
+        long        lwte_p3;
+        long        lwte_p4;
 } lwt_event_t;
 
 # define LWT_EVENT(p1,p2,p3,p4)     /* no lwt implementation yet */
 
 /* -------------------------------------------------------------------------- */
 
-#define IOCTL_PORTAL_TYPE struct portal_ioctl_data
+#define IOCTL_LIBCFS_TYPE struct libcfs_ioctl_data
 
 #define LPU64 "%llu"
 #define LPD64 "%lld"
-#define LPX64 "%llx"
+#define LPX64 "%#llx"
 #define LPSZ  "%lu"
 #define LPSSZ "%ld"
 # define LI_POISON ((int)0x5a5a5a5a)
index 8e4eb89..eb4d8f3 100644 (file)
@@ -9,6 +9,7 @@
 #endif
 
 #include <mach/mach_types.h>
+#include <sys/errno.h>
 #include <string.h>
 #include <libcfs/darwin/darwin-types.h>
 #include <libcfs/darwin/darwin-time.h>
@@ -16,6 +17,7 @@
 #include <libcfs/darwin/darwin-mem.h>
 #include <libcfs/darwin/darwin-lock.h>
 #include <libcfs/darwin/darwin-fs.h>
+#include <libcfs/darwin/darwin-tcpip.h>
 
 #ifdef __KERNEL__
 # include <sys/types.h>
@@ -75,8 +77,8 @@ struct ptldebug_header {
 #endif
 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
 
-#define CHECK_STACK(stack) do { } while(0)
-#define CDEBUG_STACK (0L)
+#define CHECK_STACK() do { } while(0)
+#define CDEBUG_STACK() (0L)
 
 /* Darwin has defined RETURN, so we have to undef it in lustre */
 #ifdef RETURN
@@ -155,7 +157,7 @@ __entry_nesting(&__cdd);
 /* ENTRY_NESTING_SUPPORT */
 #endif
 
-#define LUSTRE_PTL_PID          12345
+#define LUSTRE_LNET_PID          12345
 
 #define _XNU_LIBCFS_H
 
@@ -164,10 +166,28 @@ __entry_nesting(&__cdd);
  *
  * Implementation is in darwin-curproc.c
  */
-#define CFS_CURPROC_COMM_MAX (sizeof ((struct proc *)0)->p_comm)
+#define CFS_CURPROC_COMM_MAX    MAXCOMLEN
 /*
  * XNU has no capabilities
  */
 typedef int cfs_kernel_cap_t;
 
+#ifdef __KERNEL__
+enum {
+        /* if you change this, update darwin-util.c:cfs_stack_trace_fill() */
+        CFS_STACK_TRACE_DEPTH = 16
+};
+
+struct cfs_stack_trace {
+        void *frame[CFS_STACK_TRACE_DEPTH];
+};
+
+#define printk(format, args...)                 printf(format, ## args)
+
+#ifdef WITH_WATCHDOG
+#undef WITH_WATCHDOG
+#endif
+
+#endif /* __KERNEL__ */
+
 #endif /* _XNU_LIBCFS_H */
index bb0dc91..31d6e17 100644 (file)
@@ -18,9 +18,9 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <sys/time.h>
-#include <portals/types.h>
+#include <lnet/types.h>
 #include <libcfs/kp30.h>
 #include <mach/vm_param.h>
-#include <portals/ptlctl.h>
+#include <lnet/lnetctl.h>
 
 #endif
index 971df1b..19ee200 100644 (file)
 #ifndef __LIBCFS_KP30_H__
 #define __LIBCFS_KP30_H__
 
-#define PORTAL_DEBUG
+#define LIBCFS_DEBUG
 #include <libcfs/libcfs.h>
-#include <portals/types.h>
+#include <lnet/types.h>
 
 #if defined(__linux__)
 #include <libcfs/linux/kp30.h>
 #elif defined(__APPLE__)
 #include <libcfs/darwin/kp30.h>
+#elif defined(__WINNT__)
+#include <libcfs/winnt/kp30.h>
 #else
 #error Unsupported operating system
 #endif
 
-#include <portals/types.h>
+#ifndef DEBUG_SUBSYSTEM
+# define DEBUG_SUBSYSTEM S_UNDEFINED
+#endif
 
 #ifdef __KERNEL__
 
-# ifndef DEBUG_SUBSYSTEM
-#  define DEBUG_SUBSYSTEM S_UNDEFINED
-# endif
+#ifdef LIBCFS_DEBUG
 
-#ifdef PORTAL_DEBUG
-extern void kportal_assertion_failed(char *expr, char *file, const char *func,
-                                     const int line);
-#define LASSERT(e) ((e) ? 0 : kportal_assertion_failed( #e , __FILE__,  \
-                                                        __FUNCTION__, __LINE__))
-#define LASSERTF(cond, fmt...)                                                \
-        do {                                                                  \
-                if (unlikely(!(cond))) {                                      \
-                        portals_debug_msg(DEBUG_SUBSYSTEM, D_EMERG,  __FILE__,\
-                                          __FUNCTION__,__LINE__, CDEBUG_STACK,\
-                                          "ASSERTION(" #cond ") failed:" fmt);\
-                        LBUG();                                               \
-                }                                                             \
-        } while (0)
+/*
+ * When this is on, LASSERT macro includes check for assignment used instead
+ * of equality check, but doesn't have unlikely(). Turn this on from time to
+ * time to make test-builds. This shouldn't be on for production release.
+ */
+#define LASSERT_CHECKED (0)
 
+#if LASSERT_CHECKED
+/*
+ * Assertion.
+ *
+ * Strange construction with empty "then" clause is used to trigger compiler
+ * warnings on the assertions of the form LASSERT(a = b);
+ *
+ * "warning: suggest parentheses around assignment used as truth value"
+ *
+ * requires -Wall. Unfortunately this rules out use of likely/unlikely.
+ */
+#define LASSERT(cond)                                           \
+({                                                              \
+        if (cond)                                               \
+                ;                                               \
+        else                                                    \
+                libcfs_assertion_failed( #cond , __FILE__,      \
+                        __FUNCTION__, __LINE__);                \
+})
+
+#define LASSERTF(cond, fmt, a...)                                       \
+({                                                                      \
+         if (cond)                                                      \
+                 ;                                                      \
+         else {                                                         \
+                 libcfs_debug_msg(NULL, DEBUG_SUBSYSTEM, D_EMERG,       \
+                                  __FILE__, __FUNCTION__,__LINE__,      \
+                                  "ASSERTION(" #cond ") failed:" fmt,   \
+                                  ## a);                                \
+                 LBUG();                                                \
+         }                                                              \
+})
+
+/* LASSERT_CHECKED */
 #else
-#define LASSERT(e)
-#define LASSERTF(cond, fmt...) do { } while (0)
+
+#define LASSERT(cond)                                           \
+({                                                              \
+        if (unlikely(!(cond)))                                  \
+                libcfs_assertion_failed(#cond , __FILE__,       \
+                        __FUNCTION__, __LINE__);                \
+})
+
+#define LASSERTF(cond, fmt, a...)                                       \
+({                                                                      \
+        if (unlikely(!(cond))) {                                        \
+                libcfs_debug_msg(NULL, DEBUG_SUBSYSTEM, D_EMERG,        \
+                                 __FILE__, __FUNCTION__,__LINE__,       \
+                                 "ASSERTION(" #cond ") failed:" fmt,    \
+                                 ## a);                                 \
+                LBUG();                                                 \
+        }                                                               \
+})
+
+/* LASSERT_CHECKED */
 #endif
 
-/* LBUG_WITH_LOC defined in portals/<os>/kp30.h */
-#define LBUG() LBUG_WITH_LOC(__FILE__, __FUNCTION__, __LINE__)
+/* LIBCFS_DEBUG */
+#else
+#define LASSERT(e) ((void)(0))
+#define LASSERTF(cond, fmt...) ((void)(0))
+#endif /* LIBCFS_DEBUG */
+
+void lbug_with_loc(char *file, const char *func, const int line)
+        __attribute__((noreturn));
+
+#define LBUG() lbug_with_loc(__FILE__, __FUNCTION__, __LINE__)
 
+extern atomic_t libcfs_kmemory;
 /*
  * Memory
  */
-#ifdef PORTAL_DEBUG
-extern atomic_t portal_kmemory;
+#ifdef LIBCFS_DEBUG
 
-# define portal_kmem_inc(ptr, size)                                           \
-do {                                                                          \
-        atomic_add(size, &portal_kmemory);                                    \
+# define libcfs_kmem_inc(ptr, size)             \
+do {                                            \
+        atomic_add(size, &libcfs_kmemory);      \
 } while (0)
 
-# define portal_kmem_dec(ptr, size) do {                                      \
-        atomic_sub(size, &portal_kmemory);                                    \
+# define libcfs_kmem_dec(ptr, size) do {        \
+        atomic_sub(size, &libcfs_kmemory);      \
 } while (0)
 
 #else
-# define portal_kmem_inc(ptr, size) do {} while (0)
-# define portal_kmem_dec(ptr, size) do {} while (0)
-#endif /* PORTAL_DEBUG */
+# define libcfs_kmem_inc(ptr, size) do {} while (0)
+# define libcfs_kmem_dec(ptr, size) do {} while (0)
+#endif /* LIBCFS_DEBUG */
 
-#define PORTAL_VMALLOC_SIZE        16384
+#define LIBCFS_VMALLOC_SIZE        16384
 
-#define PORTAL_ALLOC_GFP(ptr, size, mask)                                 \
+#define LIBCFS_ALLOC_GFP(ptr, size, mask)                                 \
 do {                                                                      \
         LASSERT(!in_interrupt() ||                                        \
-               (size <= PORTAL_VMALLOC_SIZE && mask == CFS_ALLOC_ATOMIC));\
-        if ((size) > PORTAL_VMALLOC_SIZE)                                 \
+               (size <= LIBCFS_VMALLOC_SIZE && mask == CFS_ALLOC_ATOMIC));\
+        if (unlikely((size) > LIBCFS_VMALLOC_SIZE))                     \
                 (ptr) = cfs_alloc_large(size);                            \
         else                                                              \
                 (ptr) = cfs_alloc((size), (mask));                        \
-        if ((ptr) == NULL) {                                              \
-                CERROR("PORTALS: out of memory at %s:%d (tried to alloc '"\
+        if (unlikely((ptr) == NULL)) {                                  \
+                CERROR("LNET: out of memory at %s:%d (tried to alloc '"   \
                        #ptr "' = %d)\n", __FILE__, __LINE__, (int)(size));\
-                CERROR("PORTALS: %d total bytes allocated by portals\n",  \
-                       atomic_read(&portal_kmemory));                     \
+                CERROR("LNET: %d total bytes allocated by lnet\n",        \
+                       atomic_read(&libcfs_kmemory));                     \
         } else {                                                          \
-                portal_kmem_inc((ptr), (size));                           \
+                libcfs_kmem_inc((ptr), (size));                           \
                 if (!((mask) & CFS_ALLOC_ZERO))                           \
                        memset((ptr), 0, (size));                          \
         }                                                                 \
         CDEBUG(D_MALLOC, "kmalloced '" #ptr "': %d at %p (tot %d).\n",    \
-               (int)(size), (ptr), atomic_read (&portal_kmemory));        \
+               (int)(size), (ptr), atomic_read (&libcfs_kmemory));        \
 } while (0)
 
-#define PORTAL_ALLOC(ptr, size) \
-        PORTAL_ALLOC_GFP(ptr, size, CFS_ALLOC_IO)
+#define LIBCFS_ALLOC(ptr, size) \
+        LIBCFS_ALLOC_GFP(ptr, size, CFS_ALLOC_IO)
 
-#define PORTAL_ALLOC_ATOMIC(ptr, size) \
-        PORTAL_ALLOC_GFP(ptr, size, CFS_ALLOC_ATOMIC)
+#define LIBCFS_ALLOC_ATOMIC(ptr, size) \
+        LIBCFS_ALLOC_GFP(ptr, size, CFS_ALLOC_ATOMIC)
 
-#define PORTAL_FREE(ptr, size)                                          \
+#define LIBCFS_FREE(ptr, size)                                          \
 do {                                                                    \
         int s = (size);                                                 \
-        if ((ptr) == NULL) {                                            \
-                CERROR("PORTALS: free NULL '" #ptr "' (%d bytes) at "   \
+        if (unlikely((ptr) == NULL)) {                                  \
+                CERROR("LIBCFS: free NULL '" #ptr "' (%d bytes) at "    \
                        "%s:%d\n", s, __FILE__, __LINE__);               \
                 break;                                                  \
         }                                                               \
-        if (s > PORTAL_VMALLOC_SIZE)                                    \
+        if (unlikely(s > LIBCFS_VMALLOC_SIZE))                          \
                 cfs_free_large(ptr);                                    \
         else                                                            \
                 cfs_free(ptr);                                          \
-        portal_kmem_dec((ptr), s);                                      \
+        libcfs_kmem_dec((ptr), s);                                      \
         CDEBUG(D_MALLOC, "kfreed '" #ptr "': %d at %p (tot %d).\n",     \
-               s, (ptr), atomic_read(&portal_kmemory));                 \
+               s, (ptr), atomic_read(&libcfs_kmemory));                 \
 } while (0)
 
 /******************************************************************************/
 
-#ifdef PORTALS_PROFILING
-#define prof_enum(FOO) PROF__##FOO
-enum {
-        prof_enum(our_recvmsg),
-        prof_enum(our_sendmsg),
-        prof_enum(socknal_recv),
-        prof_enum(lib_parse),
-        prof_enum(conn_list_walk),
-        prof_enum(memcpy),
-        prof_enum(lib_finalize),
-        prof_enum(pingcli_time),
-        prof_enum(gmnal_send),
-        prof_enum(gmnal_recv),
-        MAX_PROFS
-};
-
-struct prof_ent {
-        char *str;
-        /* hrmph.  wrap-tastic. */
-        u32       starts;
-        u32       finishes;
-        cycles_t  total_cycles;
-        cycles_t  start;
-        cycles_t  end;
-};
+/* htonl hack - either this, or compile with -O2. Stupid byteorder/generic.h */
+#if defined(__GNUC__) && (__GNUC__ >= 2) && !defined(__OPTIMIZE__)
+#define ___htonl(x) __cpu_to_be32(x)
+#define ___htons(x) __cpu_to_be16(x)
+#define ___ntohl(x) __be32_to_cpu(x)
+#define ___ntohs(x) __be16_to_cpu(x)
+#define htonl(x) ___htonl(x)
+#define ntohl(x) ___ntohl(x)
+#define htons(x) ___htons(x)
+#define ntohs(x) ___ntohs(x)
+#endif
 
-extern struct prof_ent prof_ents[MAX_PROFS];
-
-#define PROF_START(FOO)                                         \
-        do {                                                    \
-                struct prof_ent *pe = &prof_ents[PROF__##FOO];  \
-                pe->starts++;                                   \
-                pe->start = get_cycles();                       \
-        } while (0)
-
-#define PROF_FINISH(FOO)                                        \
-        do {                                                    \
-                struct prof_ent *pe = &prof_ents[PROF__##FOO];  \
-                pe->finishes++;                                 \
-                pe->end = get_cycles();                         \
-                pe->total_cycles += (pe->end - pe->start);      \
-        } while (0)
-#else /* !PORTALS_PROFILING */
-#define PROF_START(FOO) do {} while(0)
-#define PROF_FINISH(FOO) do {} while(0)
-#endif /* PORTALS_PROFILING */
-
-/* debug.c */
-extern spinlock_t stack_backtrace_lock;
-
-void portals_debug_dumpstack(cfs_task_t *tsk);
-void portals_run_upcall(char **argv);
-void portals_run_lbug_upcall(char * file, const char *fn, const int line);
-void portals_debug_dumplog(void);
-int portals_debug_init(unsigned long bufsize);
-int portals_debug_cleanup(void);
-int portals_debug_clear_buffer(void);
-int portals_debug_mark_buffer(char *text);
-int portals_debug_set_daemon(unsigned int cmd, unsigned int length,
-                             char *file, unsigned int size);
-__s32 portals_debug_copy_to_user(char *buf, unsigned long len);
-/* Use the special GNU C __attribute__ hack to have the compiler check the
- * printf style argument string against the actual argument count and
- * types.
- */
-void portals_debug_msg(int subsys, int mask, char *file, const char *fn,
-                       const int line, unsigned long stack,
-                       char *format, ...)
-        __attribute__ ((format (printf, 7, 8)));
-void portals_debug_set_level(unsigned int debug_level);
+void libcfs_debug_dumpstack(cfs_task_t *tsk);
+void libcfs_run_upcall(char **argv);
+void libcfs_run_lbug_upcall(char * file, const char *fn, const int line);
+void libcfs_debug_dumplog(void);
+int libcfs_debug_init(unsigned long bufsize);
+int libcfs_debug_cleanup(void);
+int libcfs_debug_clear_buffer(void);
+int libcfs_debug_mark_buffer(char *text);
 
-extern void kportal_daemonize (char *name);
-extern void kportal_blockallsigs (void);
+void libcfs_debug_set_level(unsigned int debug_level);
 
 #else  /* !__KERNEL__ */
-# ifndef DEBUG_SUBSYSTEM
-#  define DEBUG_SUBSYSTEM S_UNDEFINED
-# endif
-# ifdef PORTAL_DEBUG
+# ifdef LIBCFS_DEBUG
 #  undef NDEBUG
 #  include <assert.h>
 #  define LASSERT(e)     assert(e)
@@ -204,23 +204,38 @@ do {                                                                           \
                 CERROR(args);                                                  \
           assert(cond);                                                        \
 } while (0)
+#  define LBUG()   assert(0)
 # else
-#  define LASSERT(e)
+#  define LASSERT(e) ((void)(0))
 #  define LASSERTF(cond, args...) do { } while (0)
-# endif
+#  define LBUG()   ((void)(0))
+# endif /* LIBCFS_DEBUG */
 # define printk(format, args...) printf (format, ## args)
-# define PORTAL_ALLOC(ptr, size) do { (ptr) = malloc(size); } while (0);
-# define PORTAL_FREE(a, b) do { free(a); } while (0);
-void portals_debug_dumplog(void);
-# define portals_debug_msg(subsys, mask, file, fn, line, stack, format, a...) \
-    printf("%02x:%06x (@%lu %s:%s,l. %d %d %lu): " format,                    \
-           (subsys), (mask), (long)time(0), file, fn, line,                   \
-           getpid(), (unsigned long)stack, ## a);
-
-#undef CWARN
-#undef CERROR
-#define CWARN(format, a...) CDEBUG(D_WARNING, format, ## a)
-#define CERROR(format, a...) CDEBUG(D_ERROR, format, ## a)
+# ifdef CRAY_XT3                                /* buggy calloc! */
+#  define LIBCFS_ALLOC(ptr, size)               \
+   do {                                         \
+        (ptr) = malloc(size);                   \
+        memset(ptr, 0, size);                   \
+   } while (0);
+# else
+#  define LIBCFS_ALLOC(ptr, size) do { (ptr) = calloc(1,size); } while (0);
+# endif
+# define LIBCFS_FREE(a, b) do { free(a); } while (0);
+
+void libcfs_debug_dumplog(void);
+int libcfs_debug_init(unsigned long bufsize);
+int libcfs_debug_cleanup(void);
+
+/*
+ * Generic compiler-dependent macros required for kernel
+ * build go below this comment. Actual compiler/compiler version
+ * specific implementations come from the above header files
+ */
+
+#define likely(x)      __builtin_expect(!!(x), 1)
+#define unlikely(x)    __builtin_expect(!!(x), 0)
+
+/* !__KERNEL__ */
 #endif
 
 /*
@@ -240,8 +255,31 @@ void portals_debug_dumplog(void);
 #define CLASSERT(cond) ({ switch(42) { case (cond): case 0: break; } })
 
 /* support decl needed both by kernel and liblustre */
-char *portals_nid2str(int nal, ptl_nid_t nid, char *str);
-char *portals_id2str(int nal, ptl_process_id_t nid, char *str);
+int         libcfs_isknown_lnd(int type);
+char       *libcfs_lnd2modname(int type);
+char       *libcfs_lnd2str(int type);
+int         libcfs_str2lnd(char *str);
+char       *libcfs_net2str(__u32 net);
+char       *libcfs_nid2str(lnet_nid_t nid);
+__u32       libcfs_str2net(char *str);
+lnet_nid_t  libcfs_str2nid(char *str);
+int         libcfs_str2anynid(lnet_nid_t *nid, char *str);
+char       *libcfs_id2str(lnet_process_id_t id);
+void        libcfs_setnet0alias(int type);
+
+/* how an LNET NID encodes net:address */
+#define LNET_NIDADDR(nid)      ((__u32)((nid) & 0xffffffff))
+#define LNET_NIDNET(nid)       ((__u32)(((nid) >> 32)) & 0xffffffff)
+#define LNET_MKNID(net,addr)   ((((__u64)(net))<<32)|((__u64)(addr)))
+/* how net encodes type:number */
+#define LNET_NETNUM(net)       ((net) & 0xffff)
+#define LNET_NETTYP(net)       (((net) >> 16) & 0xffff)
+#define LNET_MKNET(typ,num)    ((((__u32)(typ))<<16)|((__u32)(num)))
+
+/* implication */
+#define ergo(a, b) (!(a) || (b))
+/* logical equivalence */
+#define equi(a, b) (!!(a) == !!(b))
 
 #ifndef CURRENT_TIME
 # define CURRENT_TIME time(0)
@@ -253,45 +291,132 @@ char *portals_id2str(int nal, ptl_process_id_t nid, char *str);
  * All stuff about lwt are put in arch/kp30.h
  * -------------------------------------------------------------------- */
 
-struct portals_device_userstate
+struct libcfs_device_userstate
 {
-        int          pdu_memhog_pages;
-        cfs_page_t   *pdu_memhog_root_page;
+        int           ldu_memhog_pages;
+        cfs_page_t   *ldu_memhog_root_page;
 };
 
-#include <libcfs/portals_lib.h>
+/* what used to be in portals_lib.h */
+#ifndef MIN
+# define MIN(a,b) (((a)<(b)) ? (a): (b))
+#endif
+#ifndef MAX
+# define MAX(a,b) (((a)>(b)) ? (a): (b))
+#endif
+
+#define MKSTR(ptr) ((ptr))? (ptr) : ""
+
+static inline int size_round4 (int val)
+{
+        return (val + 3) & (~0x3);
+}
+
+static inline int size_round (int val)
+{
+        return (val + 7) & (~0x7);
+}
+
+static inline int size_round16(int val)
+{
+        return (val + 0xf) & (~0xf);
+}
+
+static inline int size_round32(int val)
+{
+        return (val + 0x1f) & (~0x1f);
+}
+
+static inline int size_round0(int val)
+{
+        if (!val)
+                return 0;
+        return (val + 1 + 7) & (~0x7);
+}
+
+static inline size_t round_strlen(char *fset)
+{
+        return (size_t)size_round((int)strlen(fset) + 1);
+}
+
+#define LOGL(var,len,ptr)                                       \
+do {                                                            \
+        if (var)                                                \
+                memcpy((char *)ptr, (const char *)var, len);    \
+        ptr += size_round(len);                                 \
+} while (0)
+
+#define LOGU(var,len,ptr)                                       \
+do {                                                            \
+        if (var)                                                \
+                memcpy((char *)var, (const char *)ptr, len);    \
+        ptr += size_round(len);                                 \
+} while (0)
+
+#define LOGL0(var,len,ptr)                              \
+do {                                                    \
+        if (!len)                                       \
+                break;                                  \
+        memcpy((char *)ptr, (const char *)var, len);    \
+        *((char *)(ptr) + len) = 0;                     \
+        ptr += size_round(len + 1);                     \
+} while (0)
 
 /*
  * USER LEVEL STUFF BELOW
  */
 
-#define PORTAL_IOCTL_VERSION 0x00010008
-#define PING_SYNC       0
-#define PING_ASYNC      1
+#define LIBCFS_IOCTL_VERSION 0x0001000a
+
+struct libcfs_ioctl_data {
+        __u32 ioc_len;
+        __u32 ioc_version;
+
+        __u64 ioc_nid;
+        __u64 ioc_u64[1];
+
+        __u32 ioc_flags;
+        __u32 ioc_count;
+        __u32 ioc_net;
+        __u32 ioc_u32[7];
+
+        __u32 ioc_inllen1;
+        char *ioc_inlbuf1;
+        __u32 ioc_inllen2;
+        char *ioc_inlbuf2;
 
-struct portal_ioctl_hdr {
+        __u32 ioc_plen1; /* buffers in userspace */
+        char *ioc_pbuf1;
+        __u32 ioc_plen2; /* buffers in userspace */
+        char *ioc_pbuf2;
+
+        char ioc_bulk[0];
+};
+
+
+struct libcfs_ioctl_hdr {
         __u32 ioc_len;
         __u32 ioc_version;
 };
 
-struct portals_debug_ioctl_data
+struct libcfs_debug_ioctl_data
 {
-        struct portal_ioctl_hdr hdr;
+        struct libcfs_ioctl_hdr hdr;
         unsigned int subs;
         unsigned int debug;
 };
 
-#define PORTAL_IOC_INIT(data)                           \
+#define LIBCFS_IOC_INIT(data)                           \
 do {                                                    \
         memset(&data, 0, sizeof(data));                 \
-        data.ioc_version = PORTAL_IOCTL_VERSION;        \
+        data.ioc_version = LIBCFS_IOCTL_VERSION;        \
         data.ioc_len = sizeof(data);                    \
 } while (0)
 
 /* FIXME check conflict with lustre_lib.h */
-#define PTL_IOC_DEBUG_MASK             _IOWR('f', 250, long)
+#define LIBCFS_IOC_DEBUG_MASK             _IOWR('f', 250, long)
 
-static inline int portal_ioctl_packlen(struct portal_ioctl_data *data)
+static inline int libcfs_ioctl_packlen(struct libcfs_ioctl_data *data)
 {
         int len = sizeof(*data);
         len += size_round(data->ioc_inllen1);
@@ -299,79 +424,79 @@ static inline int portal_ioctl_packlen(struct portal_ioctl_data *data)
         return len;
 }
 
-static inline int portal_ioctl_is_invalid(struct portal_ioctl_data *data)
+static inline int libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data)
 {
         if (data->ioc_len > (1<<30)) {
-                CERROR ("PORTALS ioctl: ioc_len larger than 1<<30\n");
+                CERROR ("LIBCFS ioctl: ioc_len larger than 1<<30\n");
                 return 1;
         }
         if (data->ioc_inllen1 > (1<<30)) {
-                CERROR ("PORTALS ioctl: ioc_inllen1 larger than 1<<30\n");
+                CERROR ("LIBCFS ioctl: ioc_inllen1 larger than 1<<30\n");
                 return 1;
         }
         if (data->ioc_inllen2 > (1<<30)) {
-                CERROR ("PORTALS ioctl: ioc_inllen2 larger than 1<<30\n");
+                CERROR ("LIBCFS ioctl: ioc_inllen2 larger than 1<<30\n");
                 return 1;
         }
         if (data->ioc_inlbuf1 && !data->ioc_inllen1) {
-                CERROR ("PORTALS ioctl: inlbuf1 pointer but 0 length\n");
+                CERROR ("LIBCFS ioctl: inlbuf1 pointer but 0 length\n");
                 return 1;
         }
         if (data->ioc_inlbuf2 && !data->ioc_inllen2) {
-                CERROR ("PORTALS ioctl: inlbuf2 pointer but 0 length\n");
+                CERROR ("LIBCFS ioctl: inlbuf2 pointer but 0 length\n");
                 return 1;
         }
         if (data->ioc_pbuf1 && !data->ioc_plen1) {
-                CERROR ("PORTALS ioctl: pbuf1 pointer but 0 length\n");
+                CERROR ("LIBCFS ioctl: pbuf1 pointer but 0 length\n");
                 return 1;
         }
         if (data->ioc_pbuf2 && !data->ioc_plen2) {
-                CERROR ("PORTALS ioctl: pbuf2 pointer but 0 length\n");
+                CERROR ("LIBCFS ioctl: pbuf2 pointer but 0 length\n");
                 return 1;
         }
         if (data->ioc_plen1 && !data->ioc_pbuf1) {
-                CERROR ("PORTALS ioctl: plen1 nonzero but no pbuf1 pointer\n");
+                CERROR ("LIBCFS ioctl: plen1 nonzero but no pbuf1 pointer\n");
                 return 1;
         }
         if (data->ioc_plen2 && !data->ioc_pbuf2) {
-                CERROR ("PORTALS ioctl: plen2 nonzero but no pbuf2 pointer\n");
+                CERROR ("LIBCFS ioctl: plen2 nonzero but no pbuf2 pointer\n");
                 return 1;
         }
-        if (portal_ioctl_packlen(data) != data->ioc_len ) {
-                CERROR ("PORTALS ioctl: packlen != ioc_len\n");
+        if ((__u32)libcfs_ioctl_packlen(data) != data->ioc_len ) {
+                CERROR ("LIBCFS ioctl: packlen != ioc_len\n");
                 return 1;
         }
         if (data->ioc_inllen1 &&
             data->ioc_bulk[data->ioc_inllen1 - 1] != '\0') {
-                CERROR ("PORTALS ioctl: inlbuf1 not 0 terminated\n");
+                CERROR ("LIBCFS ioctl: inlbuf1 not 0 terminated\n");
                 return 1;
         }
         if (data->ioc_inllen2 &&
             data->ioc_bulk[size_round(data->ioc_inllen1) +
                            data->ioc_inllen2 - 1] != '\0') {
-                CERROR ("PORTALS ioctl: inlbuf2 not 0 terminated\n");
+                CERROR ("LIBCFS ioctl: inlbuf2 not 0 terminated\n");
                 return 1;
         }
         return 0;
 }
 
 #ifndef __KERNEL__
-static inline int portal_ioctl_pack(struct portal_ioctl_data *data, char **pbuf,
+static inline int libcfs_ioctl_pack(struct libcfs_ioctl_data *data, char **pbuf,
                                     int max)
 {
         char *ptr;
-        struct portal_ioctl_data *overlay;
-        data->ioc_len = portal_ioctl_packlen(data);
-        data->ioc_version = PORTAL_IOCTL_VERSION;
+        struct libcfs_ioctl_data *overlay;
+        data->ioc_len = libcfs_ioctl_packlen(data);
+        data->ioc_version = LIBCFS_IOCTL_VERSION;
 
-        if (*pbuf && portal_ioctl_packlen(data) > max)
+        if (*pbuf && libcfs_ioctl_packlen(data) > max)
                 return 1;
         if (*pbuf == NULL) {
                 *pbuf = malloc(data->ioc_len);
         }
         if (!*pbuf)
                 return 1;
-        overlay = (struct portal_ioctl_data *)*pbuf;
+        overlay = (struct libcfs_ioctl_data *)*pbuf;
         memcpy(*pbuf, data, sizeof(*data));
 
         ptr = overlay->ioc_bulk;
@@ -379,7 +504,7 @@ static inline int portal_ioctl_pack(struct portal_ioctl_data *data, char **pbuf,
                 LOGL(data->ioc_inlbuf1, data->ioc_inllen1, ptr);
         if (data->ioc_inlbuf2)
                 LOGL(data->ioc_inlbuf2, data->ioc_inllen2, ptr);
-        if (portal_ioctl_is_invalid(overlay))
+        if (libcfs_ioctl_is_invalid(overlay))
                 return 1;
 
         return 0;
@@ -387,70 +512,71 @@ static inline int portal_ioctl_pack(struct portal_ioctl_data *data, char **pbuf,
 
 #else
 
-extern int portal_ioctl_getdata(char *buf, char *end, void *arg);
+extern int libcfs_ioctl_getdata(char *buf, char *end, void *arg);
+extern int libcfs_ioctl_popdata(void *arg, void *buf, int size);
 
 #endif
 
 /* ioctls for manipulating snapshots 30- */
-#define IOC_PORTAL_TYPE                   'e'
-#define IOC_PORTAL_MIN_NR                 30
-
-#define IOC_PORTAL_PING                    _IOWR('e', 30, IOCTL_PORTAL_TYPE)
-
-#define IOC_PORTAL_CLEAR_DEBUG             _IOWR('e', 32, IOCTL_PORTAL_TYPE)
-#define IOC_PORTAL_MARK_DEBUG              _IOWR('e', 33, IOCTL_PORTAL_TYPE)
-#define IOC_PORTAL_PANIC                   _IOWR('e', 34, IOCTL_PORTAL_TYPE)
-#define IOC_PORTAL_NAL_CMD                 _IOWR('e', 35, IOCTL_PORTAL_TYPE)
-#define IOC_PORTAL_GET_NID                 _IOWR('e', 36, IOCTL_PORTAL_TYPE)
-#define IOC_PORTAL_FAIL_NID                _IOWR('e', 37, IOCTL_PORTAL_TYPE)
-#define IOC_PORTAL_LOOPBACK                _IOWR('e', 38, IOCTL_PORTAL_TYPE)
-#define IOC_PORTAL_LWT_CONTROL             _IOWR('e', 39, IOCTL_PORTAL_TYPE)
-#define IOC_PORTAL_LWT_SNAPSHOT            _IOWR('e', 40, IOCTL_PORTAL_TYPE)
-#define IOC_PORTAL_LWT_LOOKUP_STRING       _IOWR('e', 41, IOCTL_PORTAL_TYPE)
-#define IOC_PORTAL_MEMHOG                  _IOWR('e', 42, IOCTL_PORTAL_TYPE)
-#define IOC_PORTAL_DMSG                    _IOWR('e', 43, IOCTL_PORTAL_TYPE)
-#define IOC_PORTAL_MAX_NR                             43
+#define IOC_LIBCFS_TYPE                   'e'
+#define IOC_LIBCFS_MIN_NR                 30
+/* libcfs ioctls */
+#define IOC_LIBCFS_PANIC                   _IOWR('e', 30, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_CLEAR_DEBUG             _IOWR('e', 31, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_MARK_DEBUG              _IOWR('e', 32, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_LWT_CONTROL             _IOWR('e', 33, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_LWT_SNAPSHOT            _IOWR('e', 34, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_LWT_LOOKUP_STRING       _IOWR('e', 35, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_MEMHOG                  _IOWR('e', 36, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_PING_TEST               _IOWR('e', 37, IOCTL_LIBCFS_TYPE)
+/* lnet ioctls */
+#define IOC_LIBCFS_GET_NI                  _IOWR('e', 50, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_FAIL_NID                _IOWR('e', 51, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_ADD_ROUTE               _IOWR('e', 52, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_DEL_ROUTE               _IOWR('e', 53, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_GET_ROUTE               _IOWR('e', 54, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_NOTIFY_ROUTER           _IOWR('e', 55, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_UNCONFIGURE             _IOWR('e', 56, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_PORTALS_COMPATIBILITY   _IOWR('e', 57, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_LNET_DIST               _IOWR('e', 58, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_CONFIGURE               _IOWR('e', 59, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_TESTPROTOCOMPAT         _IOWR('e', 60, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_PING                    _IOWR('e', 61, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_DEBUG_PEER              _IOWR('e', 62, IOCTL_LIBCFS_TYPE)
+/* lnd ioctls */
+#define IOC_LIBCFS_REGISTER_MYNID          _IOWR('e', 70, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_CLOSE_CONNECTION        _IOWR('e', 71, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_PUSH_CONNECTION         _IOWR('e', 72, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_GET_CONN                _IOWR('e', 73, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_DEL_PEER                _IOWR('e', 74, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_ADD_PEER                _IOWR('e', 75, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_GET_PEER                _IOWR('e', 76, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_GET_TXDESC              _IOWR('e', 77, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_ADD_INTERFACE           _IOWR('e', 78, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_DEL_INTERFACE           _IOWR('e', 79, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_GET_INTERFACE           _IOWR('e', 80, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_GET_GMID                _IOWR('e', 81, IOCTL_LIBCFS_TYPE)
+
+#define IOC_LIBCFS_MAX_NR                             81
+
 
 enum {
-        QSWNAL    = 1,
-        SOCKNAL   = 2,
-        GMNAL     = 3,
-        /*          4 unused */
-        TCPNAL    = 5,
-        ROUTER    = 6,
-        OPENIBNAL = 7,
-        IIBNAL    = 8,
-        LONAL     = 9,
-        RANAL     = 10,
-        VIBNAL    = 11,
-        NAL_ENUM_END_MARKER
+        /* Only add to these values (i.e. don't ever change or redefine them):
+         * network addresses depend on them... */
+        QSWLND    = 1,
+        SOCKLND   = 2,
+        GMLND     = 3,
+        PTLLND    = 4,
+        O2IBLND   = 5,
+        CIBLND    = 6,
+        OPENIBLND = 7,
+        IIBLND    = 8,
+        LOLND     = 9,
+        RALND     = 10,
+        VIBLND    = 11,
+        MXLND     = 12,
 };
 
-#define PTL_NALFMT_SIZE             32 /* %u:%u.%u.%u.%u,%u (10+4+4+4+3+5+1) */
-#ifndef CRAY_PORTALS
-#define NALID_FROM_IFACE(nal) (nal)
-#endif
-
-#define NAL_MAX_NR (NAL_ENUM_END_MARKER - 1)
-
-#define NAL_CMD_REGISTER_PEER_FD     100
-#define NAL_CMD_CLOSE_CONNECTION     101
-#define NAL_CMD_REGISTER_MYNID       102
-#define NAL_CMD_PUSH_CONNECTION      103
-#define NAL_CMD_GET_CONN             104
-#define NAL_CMD_DEL_PEER             105
-#define NAL_CMD_ADD_PEER             106
-#define NAL_CMD_GET_PEER             107
-#define NAL_CMD_GET_TXDESC           108
-#define NAL_CMD_ADD_ROUTE            109
-#define NAL_CMD_DEL_ROUTE            110
-#define NAL_CMD_GET_ROUTE            111
-#define NAL_CMD_NOTIFY_ROUTER        112
-#define NAL_CMD_ADD_INTERFACE        113
-#define NAL_CMD_DEL_INTERFACE        114
-#define NAL_CMD_GET_INTERFACE        115
-
-
 enum {
         DEBUG_DAEMON_START       =  1,
         DEBUG_DAEMON_STOP        =  2,
index 9e7ea85..2e11e7c 100644 (file)
@@ -12,6 +12,8 @@
 #include <libcfs/linux/libcfs.h>
 #elif defined(__APPLE__)
 #include <libcfs/darwin/libcfs.h>
+#elif defined(__WINNT__)
+#include <libcfs/winnt/libcfs.h>
 #else
 #error Unsupported operating system.
 #endif
 #include <stdio.h>
 #endif
 
-#define PORTAL_DEBUG
+#define LIBCFS_DEBUG
 
 #ifndef offsetof
 # define offsetof(typ,memb)     ((unsigned long)((char *)&(((typ *)0)->memb)))
 #endif
 
+/* cardinality of array */
+#define sizeof_array(a) ((sizeof (a)) / (sizeof ((a)[0])))
+
+#if !defined(container_of)
+/* given a pointer @ptr to the field @member embedded into type (usually
+ * struct) @type, return pointer to the embedding instance of @type. */
+#define container_of(ptr, type, member) \
+        ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
+#endif
+
+#define container_of0(ptr, type, member)                        \
+({                                                              \
+        typeof(ptr) __ptr = (ptr);                              \
+        __ptr ? container_of(__ptr, type, member) : NULL;       \
+})
+
+/*
+ * true iff @i is power-of-2
+ */
+#define IS_PO2(i)                               \
+({                                              \
+        typeof(i) __i;                          \
+                                                \
+        __i = (i);                              \
+        !(__i & (__i - 1));                     \
+})
+
 #define LOWEST_BIT_SET(x)       ((x) & ~((x) - 1))
 
 /*
  *  Debugging
  */
-extern unsigned int portal_subsystem_debug;
-extern unsigned int portal_stack;
-extern unsigned int portal_debug;
-extern unsigned int portal_printk;
+extern unsigned int libcfs_subsystem_debug;
+extern unsigned int libcfs_stack;
+extern unsigned int libcfs_debug;
+extern unsigned int libcfs_printk;
+extern unsigned int libcfs_console_ratelimit;
+extern unsigned int libcfs_debug_binary;
+extern char debug_file_path[1024];
+
+int libcfs_debug_mask2str(char *str, int size, int mask, int is_subsys);
+int libcfs_debug_str2mask(int *mask, const char *str, int is_subsys);
 
 /* Has there been an LBUG? */
-extern unsigned int portals_catastrophe;
+extern unsigned int libcfs_catastrophe;
 
 /*
  * struct ptldebug_header is defined in libcfs/<os>/libcfs.h
@@ -48,6 +83,7 @@ extern unsigned int portals_catastrophe;
 #define PH_FLAG_FIRST_RECORD 1
 
 /* Debugging subsystems (32 bits, non-overlapping) */
+/* keep these in sync with lnet/utils/debug.c and lnet/libcfs/debug.c */
 #define S_UNDEFINED   0x00000001
 #define S_MDC         0x00000002
 #define S_MDS         0x00000004
@@ -58,30 +94,33 @@ extern unsigned int portals_catastrophe;
 #define S_LLITE       0x00000080
 #define S_RPC         0x00000100
 #define S_MGMT        0x00000200
-#define S_PORTALS     0x00000400
-#define S_NAL         0x00000800 /* ALL NALs */
+/* unused */
+#define S_LNET        0x00000400
+#define S_LND         0x00000800 /* ALL LNDs */
 #define S_PINGER      0x00001000
 #define S_FILTER      0x00002000
-#define S_PTLBD       0x00004000
+/* unused */
 #define S_ECHO        0x00008000
 #define S_LDLM        0x00010000
 #define S_LOV         0x00020000
-#define S_PTLROUTER   0x00040000
-#define S_COBD        0x00080000
-#define S_SM          0x00100000
-#define S_ASOBD       0x00200000
-#define S_CONFOBD     0x00400000
-#define S_LMV         0x00800000
-#define S_CMOBD       0x01000000
-#define S_SEC         0x02000000
-#define S_GSS         0x04000000
-#define S_GKS         0x08000000
-/* If you change these values, please keep these files up to date...
- *    portals/utils/debug.c
- *    utils/lconf
- */
+/* unused */
+/* unused */
+/* unused */
+/* unused */
+/* unused */
+#define S_LMV         0x00800000 /* b_new_cmd */
+/* unused */
+#define S_SEC         0x02000000 /* upcall cache */
+#define S_GSS         0x04000000 /* b_new_cmd */
+/* unused */
+#define S_MGC         0x10000000
+#define S_MGS         0x20000000
+#define S_FID         0x40000000 /* b_new_cmd */
+#define S_FLD         0x80000000 /* b_new_cmd */
+/* keep these in sync with lnet/utils/debug.c and lnet/libcfs/debug.c */
 
 /* Debugging masks (32 bits, non-overlapping) */
+/* keep these in sync with lnet/utils/debug.c */
 #define D_TRACE       0x00000001 /* ENTRY/EXIT markers */
 #define D_INODE       0x00000002
 #define D_SUPER       0x00000004
@@ -90,13 +129,13 @@ extern unsigned int portals_catastrophe;
 #define D_CACHE       0x00000020 /* cache-related items */
 #define D_INFO        0x00000040 /* general information */
 #define D_IOCTL       0x00000080 /* ioctl related information */
-#define D_BLOCKS      0x00000100 /* ext2 block allocation */
+#define D_NETERROR    0x00000100 /* network errors */
 #define D_NET         0x00000200 /* network communications */
 #define D_WARNING     0x00000400 /* CWARN(...) == CDEBUG (D_WARNING, ...) */
 #define D_BUFFS       0x00000800
 #define D_OTHER       0x00001000
 #define D_DENTRY      0x00002000
-#define D_PORTALS     0x00004000 /* ENTRY/EXIT markers */
+/* unused: keep in sync with lnet/utils/debug.c */
 #define D_PAGE        0x00008000 /* bulk page handling */
 #define D_DLMTRACE    0x00010000
 #define D_ERROR       0x00020000 /* CERROR(...) == CDEBUG (D_ERROR, ...) */
@@ -110,86 +149,75 @@ extern unsigned int portals_catastrophe;
 #define D_CONSOLE     0x02000000
 #define D_QUOTA       0x04000000
 #define D_SEC         0x08000000
-/* If you change these values, please keep these files up to date...
- *    portals/utils/debug.c
- *    utils/lconf
- */
+/* keep these in sync with lnet/utils/debug.c */
+
+#define D_CANTMASK   (D_ERROR | D_EMERG | D_WARNING | D_CONSOLE)
 
 #ifndef DEBUG_SUBSYSTEM
 # define DEBUG_SUBSYSTEM S_UNDEFINED
 #endif
 
+#define CDEBUG_MAX_LIMIT 600
+typedef struct {
+        cfs_time_t      cdls_next;
+        int             cdls_count;
+        cfs_duration_t  cdls_delay;
+} cfs_debug_limit_state_t;
+
+#define CDEBUG_ENABLED (1)
+
 #ifdef __KERNEL__
-#define CDEBUG(mask, format, a...)                                            \
-do {                                                                          \
-        CHECK_STACK(CDEBUG_STACK);                                            \
-        if (((mask) & (D_ERROR | D_EMERG | D_WARNING | D_CONSOLE)) ||         \
-            (portal_debug & (mask) &&                                         \
-             portal_subsystem_debug & DEBUG_SUBSYSTEM))                       \
-                portals_debug_msg(DEBUG_SUBSYSTEM, mask,                      \
-                                  __FILE__, __FUNCTION__, __LINE__,           \
-                                  CDEBUG_STACK, format, ## a);                \
+
+#if CDEBUG_ENABLED
+#define __CDEBUG(cdls, mask, format, a...)                              \
+do {                                                                    \
+        CHECK_STACK();                                                  \
+                                                                        \
+        if (((mask) & D_CANTMASK) != 0 ||                               \
+            ((libcfs_debug & (mask)) != 0 &&                            \
+             (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0))          \
+                libcfs_debug_msg(cdls, DEBUG_SUBSYSTEM, mask,           \
+                                 __FILE__, __FUNCTION__, __LINE__,      \
+                                 format, ## a);                         \
 } while (0)
 
-#define CDEBUG_MAX_LIMIT 600
-#define CDEBUG_LIMIT(cdebug_mask, cdebug_format, a...)                        \
-do {                                                                          \
-        static cfs_time_t cdebug_next = 0;                                    \
-        static int cdebug_count = 0;                                          \
-        static cfs_duration_t cdebug_delay = CFS_MIN_DELAY;                   \
-                                                                              \
-        CHECK_STACK(CDEBUG_STACK);                                            \
-        if (cfs_time_after(cfs_time_current(), cdebug_next)) {                \
-                portals_debug_msg(DEBUG_SUBSYSTEM, cdebug_mask, __FILE__,     \
-                                  __FUNCTION__, __LINE__, CDEBUG_STACK,       \
-                                  cdebug_format, ## a);                       \
-                if (cdebug_count) {                                           \
-                        portals_debug_msg(DEBUG_SUBSYSTEM, cdebug_mask,       \
-                                          __FILE__, __FUNCTION__, __LINE__,0, \
-                                          "previously skipped %d similar "    \
-                                          "messages\n", cdebug_count);        \
-                        cdebug_count = 0;                                     \
-                }                                                             \
-                if (cfs_time_after(cfs_time_current(),                        \
-                                   cdebug_next +                              \
-                                   cfs_time_seconds(CDEBUG_MAX_LIMIT+10)))    \
-                        cdebug_delay = cdebug_delay > (8 * CFS_MIN_DELAY)?    \
-                                       cdebug_delay/8 : CFS_MIN_DELAY;        \
-                else                                                          \
-                        cdebug_delay = cdebug_delay*2 >= cfs_time_seconds(CDEBUG_MAX_LIMIT)?\
-                                       cfs_time_seconds(CDEBUG_MAX_LIMIT) :   \
-                                       cdebug_delay*2;                        \
-                cdebug_next = cfs_time_current() + cdebug_delay;              \
-        } else {                                                              \
-                portals_debug_msg(DEBUG_SUBSYSTEM,                            \
-                                  portal_debug &                              \
-                                  ~(D_EMERG|D_ERROR|D_WARNING|D_CONSOLE),     \
-                                  __FILE__, __FUNCTION__, __LINE__,           \
-                                  CDEBUG_STACK, cdebug_format, ## a);         \
-                cdebug_count++;                                               \
-        }                                                                     \
+#define CDEBUG(mask, format, a...) __CDEBUG(NULL, mask, format, ## a)
+
+#define CDEBUG_LIMIT(mask, format, a...)        \
+do {                                            \
+        static cfs_debug_limit_state_t cdls;    \
+                                                \
+        __CDEBUG(&cdls, mask, format, ## a);    \
 } while (0)
 
-#elif defined(LUSTRE_UTILS)
+#else /* CDEBUG_ENABLED */
+#define CDEBUG(mask, format, a...) (void)(0)
+#define CDEBUG_LIMIT(mask, format, a...) (void)(0)
+#endif
+
+#elif defined(__arch_lib__) && !defined(LUSTRE_UTILS)
 
 #define CDEBUG(mask, format, a...)                                      \
 do {                                                                    \
-        if ((mask) & (D_ERROR | D_EMERG | D_WARNING | D_CONSOLE))       \
-                fprintf(stderr, "(%s:%d:%s()) " format,                 \
-                        __FILE__, __LINE__, __FUNCTION__, ## a);        \
+        if (((mask) & D_CANTMASK) != 0 ||                               \
+            ((libcfs_debug & (mask)) != 0 &&                            \
+             (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0))          \
+                libcfs_debug_msg(NULL, DEBUG_SUBSYSTEM, mask,           \
+                                 __FILE__, __FUNCTION__, __LINE__,      \
+                                 format, ## a);                         \
 } while (0)
+
 #define CDEBUG_LIMIT CDEBUG
 
-#else  /* !__KERNEL__ && !LUSTRE_UTILS*/
+#else
 
 #define CDEBUG(mask, format, a...)                                      \
 do {                                                                    \
-        if (((mask) & (D_ERROR | D_EMERG | D_WARNING | D_CONSOLE)) ||   \
-            (portal_debug & (mask) &&                                   \
-             portal_subsystem_debug & DEBUG_SUBSYSTEM))                 \
+        if (((mask) & D_CANTMASK) != 0)                                 \
                 fprintf(stderr, "(%s:%d:%s()) " format,                 \
                         __FILE__, __LINE__, __FUNCTION__, ## a);        \
 } while (0)
+
 #define CDEBUG_LIMIT CDEBUG
 
 #endif /* !__KERNEL__ */
@@ -204,6 +232,8 @@ do {                                                                    \
 #define LCONSOLE_ERROR(format, a...) CDEBUG_LIMIT(D_CONSOLE | D_ERROR, format, ## a)
 #define LCONSOLE_EMERG(format, a...) CDEBUG(D_CONSOLE | D_EMERG, format, ## a)
 
+#if CDEBUG_ENABLED
+
 #define GOTO(label, rc)                                                 \
 do {                                                                    \
         long GOTO__ret = (long)(rc);                                    \
@@ -212,8 +242,11 @@ do {                                                                    \
                (signed long)GOTO__ret);                                 \
         goto label;                                                     \
 } while (0)
+#else
+#define GOTO(label, rc) do { ((void)(rc)); goto label; } while (0)
+#endif
 
-#define CDEBUG_ENTRY_EXIT 1
+#define CDEBUG_ENTRY_EXIT (1)
 #if CDEBUG_ENTRY_EXIT
 
 /*
@@ -248,143 +281,65 @@ do {                                                                    \
 
 #endif /* !CDEBUG_ENTRY_EXIT */
 
-
-#define LUSTRE_SRV_PTL_PID      LUSTRE_PTL_PID
-
 /*
- * eeb cfg
- * ecf6
- * ecfG
+ * Some (nomina odiosa sunt) platforms define NULL as naked 0. This confuses
+ * Lustre RETURN(NULL) macro.
  */
-#define PORTALS_CFG_VERSION 0xecf60001
-
-struct portals_cfg {
-        __u32 pcfg_version;
-        __u32 pcfg_command;
-
-        __u32 pcfg_nal;
-        __u32 pcfg_flags;
-
-        __u32 pcfg_gw_nal;
-        __u32 pcfg_padding1;
-
-        __u64 pcfg_nid;
-        __u64 pcfg_nid2;
-        __u64 pcfg_nid3;
-        __u32 pcfg_id;
-        __u32 pcfg_misc;
-        __u32 pcfg_fd;
-        __u32 pcfg_count;
-        __u32 pcfg_size;
-        __u32 pcfg_wait;
-
-        __u32 pcfg_plen1; /* buffers in userspace */
-        __u32 pcfg_plen2; /* buffers in userspace */
-        __u32 pcfg_alloc_size;  /* size of this allocated portals_cfg */
-        char  pcfg_pbuf[0];
-};
-
-#define PCFG_INIT(pcfg, cmd)                            \
-do {                                                    \
-        memset(&(pcfg), 0, sizeof((pcfg)));             \
-        (pcfg).pcfg_version = PORTALS_CFG_VERSION;      \
-        (pcfg).pcfg_command = (cmd);                    \
-                                                        \
-} while (0)
+#if defined(NULL)
+#undef NULL
+#endif
 
-#define PCFG_INIT_PBUF(pcfg, cmd, plen1, plen2)                         \
-        do {                                                            \
-                int bufsize = size_round(sizeof(*(pcfg)));              \
-                bufsize += size_round(plen1) + size_round(plen2);       \
-                PORTAL_ALLOC((pcfg), bufsize);                          \
-                if ((pcfg)) {                                           \
-                        memset((pcfg), 0, bufsize);                     \
-                        (pcfg)->pcfg_version = PORTALS_CFG_VERSION;     \
-                        (pcfg)->pcfg_command = (cmd);                   \
-                        (pcfg)->pcfg_plen1 = (plen1);                   \
-                        (pcfg)->pcfg_plen2 = (plen2);                   \
-                        (pcfg)->pcfg_alloc_size = bufsize;              \
-                }                                                       \
-        } while (0)
-
-#define PCFG_FREE_PBUF(pcfg) PORTAL_FREE((pcfg), (pcfg)->pcfg_alloc_size)
-
-#define PCFG_PBUF(pcfg, idx)                                            \
-        (0 == (idx)                                                     \
-         ? ((char *)(pcfg) + size_round(sizeof(*(pcfg))))               \
-         : (1 == (idx)                                                  \
-            ? ((char *)(pcfg) + size_round(sizeof(*(pcfg))) + size_round(pcfg->pcfg_plen1)) \
-            : (NULL)))
-
-typedef int (nal_cmd_handler_fn)(struct portals_cfg *, void *);
-int libcfs_nal_cmd_register(int nal, nal_cmd_handler_fn *handler, void *arg);
-int libcfs_nal_cmd(struct portals_cfg *pcfg);
-void libcfs_nal_cmd_unregister(int nal);
-
-struct portal_ioctl_data {
-        __u32 ioc_len;
-        __u32 ioc_version;
-        __u64 ioc_nid;
-        __u64 ioc_nid2;
-        __u64 ioc_nid3;
-        __u32 ioc_count;
-        __u32 ioc_nal;
-        __u32 ioc_nal_cmd;
-        __u32 ioc_fd;
-        __u32 ioc_id;
-
-        __u32 ioc_flags;
-        __u32 ioc_size;
-
-        __u32 ioc_wait;
-        __u32 ioc_timeout;
-        __u32 ioc_misc;
-
-        __u32 ioc_inllen1;
-        char *ioc_inlbuf1;
-        __u32 ioc_inllen2;
-        char *ioc_inlbuf2;
-
-        __u32 ioc_plen1; /* buffers in userspace */
-        char *ioc_pbuf1;
-        __u32 ioc_plen2; /* buffers in userspace */
-        char *ioc_pbuf2;
-
-        char ioc_bulk[0];
-};
+#define NULL ((void *)0)
 
+#define LUSTRE_SRV_LNET_PID      LUSTRE_LNET_PID
 
 #ifdef __KERNEL__
 
 #include <libcfs/list.h>
 
+struct libcfs_ioctl_data;                       /* forward ref */
+
 struct libcfs_ioctl_handler {
         struct list_head item;
-        int (*handle_ioctl)(struct portal_ioctl_data *data,
-                            unsigned int cmd, unsigned long args);
+        int (*handle_ioctl)(unsigned int cmd, struct libcfs_ioctl_data *data);
 };
 
-#define DECLARE_IOCTL_HANDLER(ident, func)              \
-        struct libcfs_ioctl_handler ident = {           \
-                .item = CFS_LIST_HEAD_INIT(ident.item),     \
-                .handle_ioctl = func                    \
+#define DECLARE_IOCTL_HANDLER(ident, func)                      \
+        struct libcfs_ioctl_handler ident = {                   \
+                /* .item = */ CFS_LIST_HEAD_INIT(ident.item),   \
+                /* .handle_ioctl = */ func                      \
         }
 
 int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand);
 int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand);
 
+/* libcfs tcpip */
+#define LNET_ACCEPTOR_MIN_RESERVED_PORT    512
+#define LNET_ACCEPTOR_MAX_RESERVED_PORT    1023
+
+int libcfs_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask);
+int libcfs_ipif_enumerate(char ***names);
+void libcfs_ipif_free_enumeration(char **names, int n);
+int libcfs_sock_listen(cfs_socket_t **sockp, __u32 ip, int port, int backlog);
+int libcfs_sock_accept(cfs_socket_t **newsockp, cfs_socket_t *sock);
+void libcfs_sock_abort_accept(cfs_socket_t *sock);
+int libcfs_sock_connect(cfs_socket_t **sockp, int *fatal,
+                        __u32 local_ip, int local_port,
+                        __u32 peer_ip, int peer_port);
+int libcfs_sock_setbuf(cfs_socket_t *socket, int txbufsize, int rxbufsize);
+int libcfs_sock_getbuf(cfs_socket_t *socket, int *txbufsize, int *rxbufsize);
+int libcfs_sock_getaddr(cfs_socket_t *socket, int remote, __u32 *ip, int *port);
+int libcfs_sock_write(cfs_socket_t *sock, void *buffer, int nob, int timeout);
+int libcfs_sock_read(cfs_socket_t *sock, void *buffer, int nob, int timeout);
+void libcfs_sock_release(cfs_socket_t *sock);
+
 /* libcfs watchdogs */
 struct lc_watchdog;
 
-/* Just use the default handler (dumplog)  */
-#define LC_WATCHDOG_DEFAULT_CB NULL
-
 /* Add a watchdog which fires after "time" milliseconds of delay.  You have to
  * touch it once to enable it. */
 struct lc_watchdog *lc_watchdog_add(int time,
-                                    void (*cb)(struct lc_watchdog *,
-                                               struct task_struct *,
-                                               void *),
+                                    void (*cb)(pid_t pid, void *),
                                     void *data);
 
 /* Enables a watchdog and resets its timer. */
@@ -397,9 +352,7 @@ void lc_watchdog_disable(struct lc_watchdog *lcw);
 void lc_watchdog_delete(struct lc_watchdog *lcw);
 
 /* Dump a debug log */
-void lc_watchdog_dumplog(struct lc_watchdog *lcw,
-                         struct task_struct *tsk,
-                         void *data);
+void lc_watchdog_dumplog(pid_t pid, void *data);
 
 /* __KERNEL__ */
 #endif
@@ -452,7 +405,25 @@ static inline time_t cfs_unix_seconds(void)
         cfs_fs_time_t t;
 
         cfs_fs_time_current(&t);
-        return cfs_fs_time_sec(&t);
+        return (time_t)cfs_fs_time_sec(&t);
+}
+
+static inline cfs_time_t cfs_time_shift(int seconds)
+{
+        return cfs_time_add(cfs_time_current(), cfs_time_seconds(seconds));
+}
+
+static inline long cfs_timeval_sub(struct timeval *large, struct timeval *small,
+                                   struct timeval *result)
+{
+        long r = (long) (
+                (large->tv_sec - small->tv_sec) * ONE_MILLION +
+                (large->tv_usec - small->tv_usec));
+        if (result != NULL) {
+                result->tv_usec = r / ONE_MILLION;
+                result->tv_sec = r;
+        }
+        return r;
 }
 
 #define CFS_RATELIMIT(seconds)                                  \
@@ -472,10 +443,57 @@ static inline time_t cfs_unix_seconds(void)
         result;                                                 \
 })
 
-extern void portals_debug_msg(int subsys, int mask, char *file, const char *fn,
-                              const int line, unsigned long stack,
-                              char *format, ...)
-            __attribute__ ((format (printf, 7, 8)));
+struct libcfs_debug_msg_data {
+        cfs_debug_limit_state_t *msg_cdls;
+        int                      msg_subsys;
+        const char              *msg_file;
+        const char              *msg_fn;
+        int                      msg_line;
+};
+
+#define DEBUG_MSG_DATA_INIT(cdls, subsystem, file, func, ln ) { \
+        .msg_cdls           = (cdls),       \
+        .msg_subsys         = (subsystem),  \
+        .msg_file           = (file),       \
+        .msg_fn             = (func),       \
+        .msg_line           = (ln)          \
+    }
+
+
+extern int libcfs_debug_vmsg2(cfs_debug_limit_state_t *cdls,
+                              int subsys, int mask,
+                              const char *file, const char *fn, const int line, 
+                              const char *format1, va_list args, 
+                              const char *format2, ...);
+
+#define libcfs_debug_vmsg(cdls, subsys, mask, file, fn, line, format, args) \
+    libcfs_debug_vmsg2(cdls, subsys, mask, file, fn, line, format, args, NULL, NULL)
+
+#define libcfs_debug_msg(cdls, subsys, mask, file, fn, line, format, a...) \
+    libcfs_debug_vmsg2(cdls, subsys, mask, file, fn, line, NULL, NULL, format, ##a) 
+
+#define cdebug_va(cdls, mask, file, func, line, fmt, args)      do {            \
+        CHECK_STACK();                                                          \
+                                                                                \
+        if (((mask) & D_CANTMASK) != 0 ||                                       \
+            ((libcfs_debug & (mask)) != 0 &&                                    \
+             (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0))                  \
+                libcfs_debug_vmsg(cdls, DEBUG_SUBSYSTEM, (mask),                \
+                                  (file), (func), (line), fmt, args);           \
+} while(0);
+
+#define cdebug(cdls, mask, file, func, line, fmt, a...) do {                    \
+        CHECK_STACK();                                                          \
+                                                                                \
+        if (((mask) & D_CANTMASK) != 0 ||                                       \
+            ((libcfs_debug & (mask)) != 0 &&                                    \
+             (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0))                  \
+                libcfs_debug_msg(cdls, DEBUG_SUBSYSTEM, (mask),                 \
+                                 (file), (func), (line), fmt, ## a);            \
+} while(0);
+
+extern void libcfs_assertion_failed(const char *expr, const char *file,
+                                    const char *fn, const int line);
 
 static inline void cfs_slow_warning(cfs_time_t now, int seconds, char *msg)
 {
@@ -490,10 +508,10 @@ static inline void cfs_slow_warning(cfs_time_t now, int seconds, char *msg)
  */
 static inline void cfs_fs_timeval(struct timeval *tv)
 {
-       cfs_fs_time_t time;
+        cfs_fs_time_t time;
 
-       cfs_fs_time_current(&time);
-       cfs_fs_time_usec(&time, tv);
+        cfs_fs_time_current(&time);
+        cfs_fs_time_usec(&time, tv);
 }
 
 /*
@@ -502,13 +520,13 @@ static inline void cfs_fs_timeval(struct timeval *tv)
  */
 static inline cfs_duration_t cfs_timeout_cap(cfs_duration_t timeout)
 {
-       if (timeout < cfs_time_minimal_timeout())
-               timeout = cfs_time_minimal_timeout();
-       return timeout;
+        if (timeout < CFS_TICK)
+                timeout = CFS_TICK;
+        return timeout;
 }
 
 /*
- * Portable memory allocator API (draft)
+ * Universal memory allocator API
  */
 enum cfs_alloc_flags {
         /* allocation is not allowed to block */
@@ -522,27 +540,124 @@ enum cfs_alloc_flags {
         CFS_ALLOC_FS     = (1 << 3),
         /* allocation is allowed to do io to free/clean memory */
         CFS_ALLOC_IO     = (1 << 4),
+        /* don't report allocation failure to the console */
+        CFS_ALLOC_NOWARN = (1 << 5),
         /* standard allocator flag combination */
         CFS_ALLOC_STD    = CFS_ALLOC_FS | CFS_ALLOC_IO,
         CFS_ALLOC_USER   = CFS_ALLOC_WAIT | CFS_ALLOC_FS | CFS_ALLOC_IO,
 };
 
-#define CFS_SLAB_ATOMIC         CFS_ALLOC_ATOMIC
-#define CFS_SLAB_WAIT           CFS_ALLOC_WAIT
-#define CFS_SLAB_ZERO           CFS_ALLOC_ZERO
-#define CFS_SLAB_FS             CFS_ALLOC_FS
-#define CFS_SLAB_IO             CFS_ALLOC_IO
-#define CFS_SLAB_STD            CFS_ALLOC_STD
-#define CFS_SLAB_USER           CFS_ALLOC_USER
-
 /* flags for cfs_page_alloc() in addition to enum cfs_alloc_flags */
-enum cfs_page_alloc_flags {
+enum cfs_alloc_page_flags {
         /* allow to return page beyond KVM. It has to be mapped into KVM by
          * cfs_page_map(); */
         CFS_ALLOC_HIGH   = (1 << 5),
         CFS_ALLOC_HIGHUSER = CFS_ALLOC_WAIT | CFS_ALLOC_FS | CFS_ALLOC_IO | CFS_ALLOC_HIGH,
 };
 
+/*
+ * portable UNIX device file identification. (This is not _very_
+ * portable. Probably makes no sense for Windows.)
+ */
+/*
+ * Platform defines
+ *
+ * cfs_rdev_t
+ */
+
+typedef unsigned int cfs_major_nr_t;
+typedef unsigned int cfs_minor_nr_t;
+
+/*
+ * Defined by platform.
+ */
+cfs_rdev_t     cfs_rdev_build(cfs_major_nr_t major, cfs_minor_nr_t minor);
+cfs_major_nr_t cfs_rdev_major(cfs_rdev_t rdev);
+cfs_minor_nr_t cfs_rdev_minor(cfs_rdev_t rdev);
+
+/*
+ * Generic on-wire rdev format.
+ */
+
+typedef __u32 cfs_wire_rdev_t;
+
+cfs_wire_rdev_t cfs_wire_rdev_build(cfs_major_nr_t major, cfs_minor_nr_t minor);
+cfs_major_nr_t  cfs_wire_rdev_major(cfs_wire_rdev_t rdev);
+cfs_minor_nr_t  cfs_wire_rdev_minor(cfs_wire_rdev_t rdev);
+
+/*
+ * Drop into debugger, if possible. Implementation is provided by platform.
+ */
+
+void cfs_enter_debugger(void);
+
+/*
+ * Defined by platform
+ */
+void cfs_daemonize(char *str);
+int cfs_daemonize_ctxt(char *str);
+cfs_sigset_t cfs_get_blocked_sigs(void);
+cfs_sigset_t cfs_block_allsigs(void);
+cfs_sigset_t cfs_block_sigs(cfs_sigset_t bits);
+void cfs_restore_sigs(cfs_sigset_t);
+int cfs_signal_pending(void);
+void cfs_clear_sigpending(void);
+/*
+ * XXX Liang:
+ * these macros should be removed in the future,
+ * we keep them just for keeping libcfs compatible
+ * with other branches.
+ */
+#define libcfs_daemonize(s)     cfs_daemonize(s)
+#define cfs_sigmask_lock(f)     do { f= 0; } while (0)
+#define cfs_sigmask_unlock(f)   do { f= 0; } while (0)
+
+int convert_server_error(__u64 ecode);
+int convert_client_oflag(int cflag, int *result);
+
+/*
+ * Stack-tracing filling.
+ */
+
+/*
+ * Platform-dependent data-type to hold stack frames.
+ */
+struct cfs_stack_trace;
+
+/*
+ * Fill @trace with current back-trace.
+ */
+void cfs_stack_trace_fill(struct cfs_stack_trace *trace);
+
+/*
+ * Return instruction pointer for frame @frame_no. NULL if @frame_no is
+ * invalid.
+ */
+void *cfs_stack_trace_frame(struct cfs_stack_trace *trace, int frame_no);
+
+/*
+ * Universal open flags.
+ */
+#define CFS_O_ACCMODE           0003
+#define CFS_O_CREAT             0100
+#define CFS_O_EXCL              0200
+#define CFS_O_NOCTTY            0400
+#define CFS_O_TRUNC             01000
+#define CFS_O_APPEND            02000
+#define CFS_O_NONBLOCK          04000
+#define CFS_O_NDELAY            CFS_O_NONBLOCK
+#define CFS_O_SYNC              010000
+#define CFS_O_ASYNC             020000
+#define CFS_O_DIRECT            040000
+#define CFS_O_LARGEFILE         0100000
+#define CFS_O_DIRECTORY         0200000
+#define CFS_O_NOFOLLOW          0400000
+#define CFS_O_NOATIME           01000000
+
+/* convert local open flags to universal open flags */
+int cfs_oflags2univ(int flags);
+/* convert universal open flags to local open flags */
+int cfs_univ2oflags(int flags);
 
 #define _LIBCFS_H
 
index 159cf57..072a7ad 100644 (file)
@@ -1,3 +1,3 @@
 EXTRA_DIST := kp30.h libcfs.h linux-fs.h linux-lock.h linux-mem.h      \
-       linux-prim.h linux-time.h lltrace.h portals_compat25.h          \
-       portals_lib.h portals_utils.h
+       linux-prim.h linux-time.h linux-tcpip.h lltrace.h               \
+       portals_compat25.h portals_utils.h
index d2329ba..be2cd34 100644 (file)
@@ -9,7 +9,9 @@
 #endif
 
 #ifdef __KERNEL__
+#ifdef HAVE_KERNEL_CONFIG_H
 # include <linux/config.h>
+#endif
 # include <linux/kernel.h>
 # include <linux/mm.h>
 # include <linux/string.h>
@@ -30,7 +32,7 @@
 # include <linux/highmem.h>
 # include <linux/module.h>
 # include <linux/version.h>
-# include <portals/p30.h>
+# include <lnet/lnet.h>
 # include <linux/smp_lock.h>
 # include <asm/atomic.h>
 # include <asm/uaccess.h>
 # include <linux/file.h>
 # include <linux/smp.h>
 # include <linux/ctype.h>
+# include <linux/compiler.h>
 # ifdef HAVE_MM_INLINE
 #  include <linux/mm_inline.h>
 # endif
 # if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
 #  include <linux/kallsyms.h>
+#  include <linux/moduleparam.h>
 # endif
 
 #include <libcfs/linux/portals_compat25.h>
@@ -88,28 +92,9 @@ static inline void our_cond_resched(void)
 #else
 #define LASSERT_SPIN_LOCKED(lock) do {} while(0)
 #endif
+#define LASSERT_SEM_LOCKED(sem) LASSERT(down_trylock(sem) != 0)
 
-#ifdef __arch_um__
-#define LBUG_WITH_LOC(file, func, line)                                 \
-do {                                                                    \
-        CEMERG("LBUG - trying to dump log to /tmp/lustre-log\n");       \
-        portals_catastrophe = 1;                                        \
-        portals_debug_dumplog();                                        \
-        portals_run_lbug_upcall(file, func, line);                      \
-        panic("LBUG");                                                  \
-} while (0)
-#else
-#define LBUG_WITH_LOC(file, func, line)                                 \
-do {                                                                    \
-        CEMERG("LBUG\n");                                               \
-        portals_catastrophe = 1;                                        \
-        portals_debug_dumpstack(NULL);                                  \
-        portals_debug_dumplog();                                        \
-        portals_run_lbug_upcall(file, func, line);                      \
-        set_task_state(current, TASK_UNINTERRUPTIBLE);                  \
-        schedule();                                                     \
-} while (0)
-#endif /* __arch_um__ */
+#define LIBCFS_PANIC(msg)            panic(msg)
 
 /* ------------------------------------------------------------------- */
 
@@ -137,6 +122,24 @@ do {                                                                    \
 #endif
 
 /******************************************************************************/
+/* Module parameter support */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+# define CFS_MODULE_PARM(name, t, type, perm, desc) \
+        MODULE_PARM(name, t);\
+        MODULE_PARM_DESC(name, desc)
+
+#else
+# define CFS_MODULE_PARM(name, t, type, perm, desc) \
+        module_param(name, type, perm);\
+        MODULE_PARM_DESC(name, desc)
+#endif
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9))
+# define CFS_SYSFS_MODULE_PARM  0 /* no sysfs module parameters */
+#else
+# define CFS_SYSFS_MODULE_PARM  1 /* module parameters accessible via sysfs */
+#endif
+/******************************************************************************/
 
 #if (__GNUC__)
 /* Use the special GNU C __attribute__ hack to have the compiler check the
@@ -157,14 +160,22 @@ do {                                                                    \
 #else  /* !__KERNEL__ */
 # include <stdio.h>
 # include <stdlib.h>
-#ifndef __CYGWIN__
-# include <stdint.h>
-#else
+#ifdef CRAY_XT3
+# include <ioctl.h>
+#elif defined(__CYGWIN__)
 # include <cygwin-ioctl.h>
+#else
+# include <stdint.h>
 #endif
 # include <unistd.h>
 # include <time.h>
 # include <limits.h>
+# include <errno.h>
+# include <sys/ioctl.h>                         /* for _IOWR */
+
+# define CFS_MODULE_PARM(name, t, type, perm, desc)
+#define PORTAL_SYMBOL_GET(x) inter_module_get(#x)
+#define PORTAL_SYMBOL_PUT(x) inter_module_put(#x)
 
 #endif /* End of !__KERNEL__ */
 
@@ -175,7 +186,7 @@ do {                                                                    \
 
 #define LWT_MEMORY   (16<<20)
 
-#if !KLWT_SUPPORT
+#ifndef KLWT_SUPPORT
 # if defined(__KERNEL__)
 #  if !defined(BITS_PER_LONG)
 #   error "BITS_PER_LONG not defined"
@@ -225,7 +236,7 @@ extern lwt_cpu_t lwt_cpus[];
 
 #define LWTSTR(n)       #n
 #define LWTWHERE(f,l)   f ":" LWTSTR(l)
-#define LWT_EVENTS_PER_PAGE (PAGE_SIZE / sizeof (lwt_event_t))
+#define LWT_EVENTS_PER_PAGE (CFS_PAGE_SIZE / sizeof (lwt_event_t))
 
 #define LWT_EVENT(p1, p2, p3, p4)                                       \
 do {                                                                    \
@@ -276,7 +287,7 @@ extern int  lwt_snapshot (cycles_t *now, int *ncpu, int *total_size,
 
 /* ------------------------------------------------------------------ */
 
-#define IOCTL_PORTAL_TYPE long
+#define IOCTL_LIBCFS_TYPE long
 
 #ifdef __CYGWIN__
 # ifndef BITS_PER_LONG
@@ -298,23 +309,26 @@ extern int  lwt_snapshot (cycles_t *now, int *ncpu, int *total_size,
 # define LP_POISON ((void *)(long)0x5a5a5a5a)
 #endif
 
-#if defined(__x86_64__) && defined(__KERNEL__)
+#if (defined(__x86_64__) && defined(__KERNEL__))
 /* x86_64 defines __u64 as "long" in userspace, but "long long" in the kernel */
 # define LPU64 "%Lu"
 # define LPD64 "%Ld"
 # define LPX64 "%#Lx"
+# define LPF64 "L"
 # define LPSZ  "%lu"
 # define LPSSZ "%ld"
 #elif (BITS_PER_LONG == 32 || __WORDSIZE == 32)
 # define LPU64 "%Lu"
 # define LPD64 "%Ld"
 # define LPX64 "%#Lx"
+# define LPF64 "L"
 # define LPSZ  "%u"
 # define LPSSZ "%d"
 #elif (BITS_PER_LONG == 64 || __WORDSIZE == 64)
 # define LPU64 "%lu"
 # define LPD64 "%ld"
 # define LPX64 "%#lx"
+# define LPF64 "l"
 # define LPSZ  "%lu"
 # define LPSSZ "%ld"
 #endif
index 1e82343..0aac919 100644 (file)
@@ -8,28 +8,18 @@
 #error Do not #include this file directly. #include <libcfs/libcfs.h> instead
 #endif
 
+#include <stdarg.h>
 #include <libcfs/linux/linux-mem.h>
 #include <libcfs/linux/linux-time.h>
 #include <libcfs/linux/linux-prim.h>
 #include <libcfs/linux/linux-lock.h>
 #include <libcfs/linux/linux-fs.h>
+#include <libcfs/linux/linux-tcpip.h>
 
 #ifdef HAVE_ASM_TYPES_H
 #include <asm/types.h>
 #else
-/* this is actually coming from within lustre, a layering violation.
- * we may not even need it, as libuptlctl (the dependency for which it
- * is needed in liblustre building on catamount, bug 6923) shows no
- * apparent need to be included in liblustre AFAICS.  The change of
- * include to lustre/types.h only makes this explicit instead of implicit.
- * To be resolved.  For now, make it CRAY_PORTALS only, to avoid breaking
- * non-b1_4 branches that don't have this file.
- */
-# if CRAY_PORTALS
-#  include <lustre/types.h>
-# else
-#  include "types.h"
-# endif
+#include <libcfs/types.h>
 #endif
 
 
@@ -99,49 +89,40 @@ struct ptldebug_header {
 
 #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5)
 
-#ifdef __KERNEL__
+#if defined(__KERNEL__) && !defined(__x86_64__)
 # ifdef  __ia64__
-#  define CDEBUG_STACK (THREAD_SIZE -                                      \
-                        ((unsigned long)__builtin_dwarf_cfa() &            \
-                         (THREAD_SIZE - 1)))
+#  define CDEBUG_STACK() (THREAD_SIZE -                                 \
+                          ((unsigned long)__builtin_dwarf_cfa() &       \
+                           (THREAD_SIZE - 1)))
 # else
-#  define CDEBUG_STACK (THREAD_SIZE -                                      \
-                        ((unsigned long)__builtin_frame_address(0) &       \
-                         (THREAD_SIZE - 1)))
+#  define CDEBUG_STACK() (THREAD_SIZE -                                 \
+                          ((unsigned long)__builtin_frame_address(0) &  \
+                           (THREAD_SIZE - 1)))
 # endif /* __ia64__ */
 
-#define CHECK_STACK(stack)                                                    \
-        do {                                                                  \
-                if ((stack) > 3*THREAD_SIZE/4 && (stack) > portal_stack) {    \
-                        portals_debug_msg(DEBUG_SUBSYSTEM, D_WARNING,         \
-                                          __FILE__, __FUNCTION__, __LINE__,   \
-                                          (stack),"maximum lustre stack %u\n",\
-                                          portal_stack = (stack));            \
-                      /*panic("LBUG");*/                                      \
-                }                                                             \
-        } while (0)
+#define __CHECK_STACK(file, func, line)                                 \
+do {                                                                    \
+        unsigned long _stack = CDEBUG_STACK();                          \
+                                                                        \
+        if (_stack > 3*THREAD_SIZE/4 && _stack > libcfs_stack) {        \
+                libcfs_stack = _stack;                                  \
+                libcfs_debug_msg(NULL, DEBUG_SUBSYSTEM, D_WARNING,      \
+                                 file, func, line,                      \
+                                 "maximum lustre stack %lu\n", _stack); \
+              /*panic("LBUG");*/                                        \
+        }                                                               \
+} while (0)
+#define CHECK_STACK()     __CHECK_STACK(__FILE__, __func__, __LINE__)
 #else /* !__KERNEL__ */
-#define CHECK_STACK(stack) do { } while(0)
-#define CDEBUG_STACK (0L)
+#define __CHECK_STACK(X, Y, Z) do { } while(0)
+#define CHECK_STACK() do { } while(0)
+#define CDEBUG_STACK() (0L)
 #endif /* __KERNEL__ */
 
 /* initial pid  */
-# if CRAY_PORTALS
-/*
- * 1) ptl_pid_t in cray portals is only 16 bits, not 32 bits, therefore this
- *    is too big.
- *
- * 2) the implementation of ernal in cray portals further restricts the pid
- *    space that may be used to 0 <= pid <= 255 (an 8 bit value).  Returns
- *    an error at nal init time for any pid outside this range.  Other nals
- *    in cray portals don't have this restriction.
- * */
-#define LUSTRE_PTL_PID          9
-# else
-#define LUSTRE_PTL_PID          12345
-# endif
+#define LUSTRE_LNET_PID          12345
 
-#define ENTRY_NESTING_SUPPORT (0)
+#define ENTRY_NESTING_SUPPORT (1)
 #define ENTRY_NESTING   do {;} while (0)
 #define EXIT_NESTING   do {;} while (0)
 #define __current_nesting_level() (0)
@@ -160,4 +141,17 @@ typedef kernel_cap_t cfs_kernel_cap_t;
 typedef __u32 cfs_kernel_cap_t;
 #endif
 
+#if defined(__KERNEL__)
+/*
+ * No stack-back-tracing in Linux for now.
+ */
+struct cfs_stack_trace {
+};
+
+#ifndef WITH_WATCHDOG
+#define WITH_WATCHDOG
+#endif
+
+#endif
+
 #endif /* _LINUX_LIBCFS_H */
index 9530360..3ba5461 100644 (file)
 #include <linux/fs.h>
 #include <linux/stat.h>
 #include <linux/mount.h>
-#endif
+#else /* !__KERNEL__ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/mount.h>
+#include <mntent.h>
+#endif  /* __KERNEL__ */
 
 typedef struct file cfs_file_t;
 typedef struct dentry cfs_dentry_t;
@@ -55,15 +64,23 @@ cfs_file_t *cfs_filp_open (const char *name, int flags, int mode, int *err);
 #define cfs_put_file(f)                     fput(f)
 #define cfs_file_count(f)                   file_count(f)
 
-typedef struct file_lock cfs_flock_t; 
-#define CFS_FLOCK_TYPE(fl)                  ((fl)->fl_type)
-#define CFS_FLOCK_SET_TYPE(fl, type)        do { (fl)->fl_type = (type); } while(0)
-#define CFS_FLOCK_PID(fl)                   ((fl)->fl_pid)
-#define CFS_FLOCK_SET_PID(fl, pid)          do { (fl)->fl_pid = (pid); } while(0)
-#define CFS_FLOCK_START(fl)                 ((fl)->fl_start)
-#define CFS_FLOCK_SET_START(fl, start)      do { (fl)->fl_start = (start); } while(0)
-#define CFS_FLOCK_END(fl)                   ((fl)->fl_end)
-#define CFS_FLOCK_SET_END(fl, end)          do { (fl)->fl_end = (end); } while(0)
+typedef struct file_lock cfs_flock_t;
+#define cfs_flock_type(fl)                  ((fl)->fl_type)
+#define cfs_flock_set_type(fl, type)        do { (fl)->fl_type = (type); } while(0)
+#define cfs_flock_pid(fl)                   ((fl)->fl_pid)
+#define cfs_flock_set_pid(fl, pid)          do { (fl)->fl_pid = (pid); } while(0)
+#define cfs_flock_start(fl)                 ((fl)->fl_start)
+#define cfs_flock_set_start(fl, start)      do { (fl)->fl_start = (start); } while(0)
+#define cfs_flock_end(fl)                   ((fl)->fl_end)
+#define cfs_flock_set_end(fl, end)          do { (fl)->fl_end = (end); } while(0)
+
+ssize_t cfs_user_write (cfs_file_t *filp, const char *buf, size_t count, loff_t *offset);
+
+/*
+ * portable UNIX device file identification.
+ */
+
+typedef dev_t cfs_rdev_t;
 
 #endif
 
index ce097e9..f419c9b 100644 (file)
@@ -74,7 +74,7 @@
  */
 
 /*
- * mutex_t:
+ * mutex:
  *
  * - init_mutex(x)
  * - init_mutex_locked(x)
  * - wait_for_completion(c)
  */
 
-/*
- * OSX funnels:
- *
- * No funnels needed in Linux
- */
-#define CFS_DECL_FUNNEL_DATA
-#define CFS_DECL_CONE_DATA             DECLARE_FUNNEL_DATA
-#define CFS_DECL_NET_DATA               DECLARE_FUNNEL_DATA
-#define CFS_CONE_IN                    do {} while(0)
-#define CFS_CONE_EX                    do {} while(0)
-
-#define CFS_NET_IN                      do {} while(0)
-#define CFS_NET_EX                      do {} while(0)
-
 /* __KERNEL__ */
 #else
 
-//#include "../user-lock.h"
+#include "../user-lock.h"
 
 /* __KERNEL__ */
 #endif
index 94b764f..7591213 100644 (file)
 typedef struct page                     cfs_page_t;
 #define CFS_PAGE_SIZE                   PAGE_CACHE_SIZE
 #define CFS_PAGE_SHIFT                  PAGE_CACHE_SHIFT
-#define CFS_PAGE_MASK                   PAGE_CACHE_MASK
+#define CFS_PAGE_MASK                   (~((__u64)CFS_PAGE_SIZE-1))
 
-cfs_page_t *cfs_alloc_pages(unsigned int flags, unsigned int order);
-#define cfs_alloc_page(f)              cfs_alloc_pages(f, 0)
-#define cfs_free_pages(p, o)           __free_pages(p, o)
+cfs_page_t *cfs_alloc_page(unsigned int flags);
 #define cfs_free_page(p)               __free_pages(p, 0)
 
 static inline void *cfs_page_address(cfs_page_t *page)
 {
+        /*
+         * XXX nikita: do NOT call portals_debug_msg() (CDEBUG/ENTRY/EXIT)
+         * from here: this will lead to infinite recursion.
+         */
         return page_address(page);
 }
 
@@ -73,13 +75,11 @@ static inline int cfs_page_count(cfs_page_t *page)
         return page_count(page);
 }
 
-static inline void cfs_set_page_count(cfs_page_t *page, int v)
-{
-        set_page_count(page, v);
-}
+#define cfs_page_index(p)       ((p)->index)
 
 /*
  * Memory allocator
+ * XXX Liang: move these declare to public file
  */
 extern void *cfs_alloc(size_t nr_bytes, u_int32_t flags);
 extern void  cfs_free(void *addr);
@@ -88,12 +88,17 @@ extern void *cfs_alloc_large(size_t nr_bytes);
 extern void  cfs_free_large(void *addr);
 
 /*
+ * In Linux there is no way to determine whether current execution context is
+ * blockable.
+ */
+#define CFS_ALLOC_ATOMIC_TRY   CFS_ALLOC_ATOMIC
+
+/*
  * SLAB allocator
+ * XXX Liang: move these declare to public file
  */
 typedef kmem_cache_t    cfs_mem_cache_t;
-extern cfs_mem_cache_t * cfs_mem_cache_create (const char *, size_t, size_t, unsigned long,
-                                               void (*)(void *, cfs_mem_cache_t *, unsigned long),
-                                               void (*)(void *, cfs_mem_cache_t *, unsigned long));
+extern cfs_mem_cache_t * cfs_mem_cache_create (const char *, size_t, size_t, unsigned long);
 extern int cfs_mem_cache_destroy ( cfs_mem_cache_t * );
 extern void *cfs_mem_cache_alloc ( cfs_mem_cache_t *, int);
 extern void cfs_mem_cache_free ( cfs_mem_cache_t *, void *);
@@ -104,6 +109,12 @@ extern void cfs_mem_cache_free ( cfs_mem_cache_t *, void *);
 #define CFS_MMSPACE_OPEN                do { __oldfs = get_fs(); set_fs(get_ds());} while(0)
 #define CFS_MMSPACE_CLOSE               set_fs(__oldfs)
 
+#else   /* !__KERNEL__ */
+#ifdef HAVE_ASM_PAGE_H
+#include <asm/page.h>           /* needed for PAGE_SIZE - rread */
+#endif
+
+#include <libcfs/user-prim.h>
 /* __KERNEL__ */
 #endif
 
index 69bda36..41eeb8a 100644 (file)
@@ -30,7 +30,9 @@
 #endif
 
 #ifdef __KERNEL__
+#ifdef HAVE_KERNEL_CONFIG_H
 #include <linux/config.h>
+#endif
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/version.h>
@@ -57,8 +59,27 @@ typedef struct miscdevice            cfs_psdev_t;
 typedef struct ctl_table               cfs_sysctl_table_t;
 typedef struct ctl_table_header                cfs_sysctl_table_header_t;
 
-#define register_cfs_sysctl_table(t, a)        register_sysctl_table(t, a)
-#define unregister_cfs_sysctl_table(t) unregister_sysctl_table(t, a)
+#define cfs_register_sysctl_table(t, a)        register_sysctl_table(t, a)
+#define cfs_unregister_sysctl_table(t) unregister_sysctl_table(t, a)
+
+/*
+ * Symbol register
+ */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+#define cfs_symbol_register(s, p)       inter_module_register(s, THIS_MODULE, p)
+#define cfs_symbol_unregister(s)        inter_module_unregister(s)
+#define cfs_symbol_get(s)               inter_module_get(s)
+#define cfs_symbol_put(s)               inter_module_put(s)
+#define cfs_module_get()                MOD_INC_USE_COUNT
+#define cfs_module_put()                MOD_DEC_USE_COUNT
+#else
+#define cfs_symbol_register(s, p)       do {} while(0)
+#define cfs_symbol_unregister(s)        do {} while(0)
+#define cfs_symbol_get(s)               symbol_get(s)
+#define cfs_symbol_put(s)               symbol_put(s)
+#define cfs_module_get()                try_module_get(THIS_MODULE)
+#define cfs_module_put()                module_put(THIS_MODULE)
+#endif
 
 /*
  * Proc file system APIs
@@ -73,21 +94,28 @@ typedef struct proc_dir_entry           cfs_proc_dir_entry_t;
 /*
  * Wait Queue
  */
+#define CFS_TASK_INTERRUPTIBLE          TASK_INTERRUPTIBLE
+#define CFS_TASK_UNINT                  TASK_UNINTERRUPTIBLE
+
 typedef wait_queue_t                   cfs_waitlink_t;
 typedef wait_queue_head_t              cfs_waitq_t;
 
-#define cfs_waitq_init(w)              init_waitqueue_head(w)
-#define cfs_waitlink_init(l)           init_waitqueue_entry(l, current)
-#define cfs_waitq_add(w, l)            add_wait_queue(w, l)
-#define cfs_waitq_add_exclusive(w, l)  add_wait_queue_exclusive(w, l)
+typedef long                            cfs_task_state_t;
+
+#define cfs_waitq_init(w)               init_waitqueue_head(w)
+#define cfs_waitlink_init(l)            init_waitqueue_entry(l, current)
+#define cfs_waitq_add(w, l)             add_wait_queue(w, l)
+#define cfs_waitq_add_exclusive(w, l)   add_wait_queue_exclusive(w, l)
 #define cfs_waitq_forward(l, w)         do {} while(0)
-#define cfs_waitq_del(w, l)            remove_wait_queue(w, l)
-#define cfs_waitq_active(w)            waitqueue_active(w)
-#define cfs_waitq_signal(w)            wake_up(w)
-#define cfs_waitq_signal_nr(w,n)       wake_up_nr(w, n)
-#define cfs_waitq_broadcast(w)         wake_up_all(w)
-#define cfs_waitq_wait(l)              schedule()
-#define cfs_waitq_timedwait(l, t)      schedule_timeout(t)
+#define cfs_waitq_del(w, l)             remove_wait_queue(w, l)
+#define cfs_waitq_active(w)             waitqueue_active(w)
+#define cfs_waitq_signal(w)             wake_up(w)
+#define cfs_waitq_signal_nr(w,n)        wake_up_nr(w, n)
+#define cfs_waitq_broadcast(w)          wake_up_all(w)
+#define cfs_waitq_wait(l, s)            schedule()
+#define cfs_waitq_timedwait(l, s, t)    schedule_timeout(t)
+#define cfs_schedule_timeout(s, t)      schedule_timeout(t)
+#define cfs_schedule()                  schedule()
 
 /* Kernel thread */
 typedef int (*cfs_thread_t)(void *);
@@ -98,6 +126,8 @@ typedef int (*cfs_thread_t)(void *);
  */
 typedef struct task_struct              cfs_task_t;
 #define cfs_current()                   current
+#define cfs_task_lock(t)                task_lock(t)
+#define cfs_task_unlock(t)              task_unlock(t)
 #define CFS_DECL_JOURNAL_DATA           void *journal_info
 #define CFS_PUSH_JOURNAL                do {    \
         journal_info = current->journal_info;   \
@@ -115,14 +145,7 @@ module_exit(fini)
 /*
  * Signal
  */
-#define cfs_sigmask_lock(t, f)          SIGNAL_MASK_LOCK(t, f)
-#define cfs_sigmask_unlock(t, f)        SIGNAL_MASK_UNLOCK(t, f)
-#define cfs_recalc_sigpending(t)        RECALC_SIGPENDING
-#define cfs_signal_pending(t)           signal_pending(t)
-#define cfs_sigfillset(s)               sigfillset(s)
-
-#define cfs_set_sig_blocked(t, b)       do { (t)->blocked = b; } while(0)
-#define cfs_get_sig_blocked(t)          (&(t)->blocked)
+typedef sigset_t                        cfs_sigset_t;
 
 /*
  * Timer
@@ -164,8 +187,17 @@ static inline cfs_time_t cfs_timer_deadline(cfs_timer_t *t)
         return t->expires;
 }
 
+
+/* deschedule for a bit... */
+static inline void cfs_pause(cfs_duration_t ticks)
+{
+        set_current_state(TASK_UNINTERRUPTIBLE);
+        schedule_timeout(ticks);
+}
+
 #else   /* !__KERNEL__ */
 
+typedef struct proc_dir_entry           cfs_proc_dir_entry_t;
 #include "../user-prim.h"
 
 #endif /* __KERNEL__ */
diff --git a/lnet/include/libcfs/linux/linux-tcpip.h b/lnet/include/libcfs/linux/linux-tcpip.h
new file mode 100644 (file)
index 0000000..2d14904
--- /dev/null
@@ -0,0 +1,62 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ *  Copyright (C) 2001 Cluster File Systems, Inc. <braam@clusterfs.com>
+ *
+ *   This file is part of Lustre, http://www.lustre.org.
+ *
+ *   Lustre is free software; you can redistribute it and/or
+ *   modify it under the terms of version 2 of the GNU General Public
+ *   License as published by the Free Software Foundation.
+ *
+ *   Lustre is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with Lustre; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Basic library routines. 
+ *
+ */
+
+#ifndef __LIBCFS_LINUX_CFS_TCP_H__
+#define __LIBCFS_LINUX_CFS_TCP_H__
+
+#ifndef __LIBCFS_LIBCFS_H__
+#error Do not #include this file directly. #include <libcfs/libcfs.h> instead
+#endif
+
+#ifdef __KERNEL__
+#include <net/sock.h>
+
+typedef struct socket   cfs_socket_t;
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,72))
+# define sk_allocation  allocation
+# define sk_data_ready  data_ready
+# define sk_write_space write_space
+# define sk_user_data   user_data
+# define sk_prot        prot
+# define sk_sndbuf      sndbuf
+# define sk_rcvbuf      rcvbuf
+# define sk_socket      socket
+# define sk_sleep       sleep
+#endif
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
+# define sk_wmem_queued wmem_queued
+# define sk_err         err
+# define sk_route_caps  route_caps
+#endif
+
+#define SOCK_SNDBUF(so)         ((so)->sk->sk_sndbuf)
+#define SOCK_WMEM_QUEUED(so)    ((so)->sk->sk_wmem_queued)
+#define SOCK_ERROR(so)          ((so)->sk->sk_err)
+#define SOCK_TEST_NOSPACE(so)   test_bit(SOCK_NOSPACE, &(so)->flags)
+
+#endif
+
+#endif
index f18e7d9..7135218 100644 (file)
  *  int            cfs_fs_time_before (cfs_fs_time_t *, cfs_fs_time_t *);
  *  int            cfs_fs_time_beforeq(cfs_fs_time_t *, cfs_fs_time_t *);
  *
- *  cfs_duration_t cfs_time_minimal_timeout(void)
- *
  *  CFS_TIME_FORMAT
  *  CFS_DURATION_FORMAT
  *
  */
 
 #define ONE_BILLION ((u_int64_t)1000000000)
-#define ONE_MILLION ((u_int64_t)   1000000)
+#define ONE_MILLION 1000000
 
 #ifdef __KERNEL__
-
+#ifdef HAVE_KERNEL_CONFIG_H
 #include <linux/config.h>
+#endif
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/version.h>
@@ -106,15 +105,15 @@ static inline void cfs_fs_time_nsec(cfs_fs_time_t *t, struct timespec *s)
 /*
  * internal helper function used by cfs_fs_time_before*()
  */
-static inline unsigned long __cfs_fs_time_flat(cfs_fs_time_t *t)
+static inline unsigned long long __cfs_fs_time_flat(cfs_fs_time_t *t)
 {
-        return ((unsigned long)t->tv_sec) * ONE_MILLION + t->tv_usec * 1000;
+        return (unsigned long long)t->tv_sec * ONE_MILLION + t->tv_usec;
 }
 
 #define CURRENT_KERN_TIME        xtime
 
-/* (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) */
 #else
+/* (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) */
 
 /*
  * post 2.5 kernels.
@@ -138,9 +137,9 @@ static inline void cfs_fs_time_nsec(cfs_fs_time_t *t, struct timespec *s)
 /*
  * internal helper function used by cfs_fs_time_before*()
  */
-static inline unsigned long __cfs_fs_time_flat(cfs_fs_time_t *t)
+static inline unsigned long long __cfs_fs_time_flat(cfs_fs_time_t *t)
 {
-        return ((unsigned long)t->tv_sec) * ONE_BILLION + t->tv_nsec;
+        return (unsigned long long)t->tv_sec * ONE_BILLION + t->tv_nsec;
 }
 
 #define CURRENT_KERN_TIME        CURRENT_TIME
@@ -198,12 +197,12 @@ static inline time_t cfs_fs_time_sec(cfs_fs_time_t *t)
 
 static inline int cfs_fs_time_before(cfs_fs_time_t *t1, cfs_fs_time_t *t2)
 {
-        return time_before(__cfs_fs_time_flat(t1), __cfs_fs_time_flat(t2));
+        return __cfs_fs_time_flat(t1) <  __cfs_fs_time_flat(t2);
 }
 
 static inline int cfs_fs_time_beforeq(cfs_fs_time_t *t1, cfs_fs_time_t *t2)
 {
-        return time_before_eq(__cfs_fs_time_flat(t1), __cfs_fs_time_flat(t2));
+        return __cfs_fs_time_flat(t1) <= __cfs_fs_time_flat(t2);
 }
 
 #if 0
@@ -224,12 +223,7 @@ static inline cfs_duration_t cfs_duration_build(int64_t nano)
 
 static inline cfs_duration_t cfs_time_seconds(int seconds)
 {
-        return seconds * HZ;
-}
-
-static inline cfs_time_t cfs_time_shift(int seconds)
-{
-        return jiffies + seconds * HZ;
+        return ((cfs_duration_t)seconds) * HZ;
 }
 
 static inline time_t cfs_duration_sec(cfs_duration_t d)
@@ -239,34 +233,64 @@ static inline time_t cfs_duration_sec(cfs_duration_t d)
 
 static inline void cfs_duration_usec(cfs_duration_t d, struct timeval *s)
 {
-#if (BITS_PER_LONG == 32)
-        uint64_t t = (d - s->tv_sec * HZ) * ONE_MILLION;
+#if (BITS_PER_LONG == 32) && (HZ > 4096)
+        uint64_t t;
+
+        s->tv_sec = d / HZ;
+        t = (d - (cfs_duration_t)s->tv_sec * HZ) * ONE_MILLION;
         s->tv_usec = do_div (t, HZ);
 #else
-        s->tv_usec = (d - s->tv_sec * HZ) * ONE_MILLION / HZ;
-#endif
         s->tv_sec = d / HZ;
+        s->tv_usec = ((d - (cfs_duration_t)s->tv_sec * HZ) * ONE_MILLION) / HZ;
+#endif
 }
 
 static inline void cfs_duration_nsec(cfs_duration_t d, struct timespec *s)
 {
 #if (BITS_PER_LONG == 32)
-        uint64_t t = (d - s->tv_sec * HZ) * ONE_BILLION;
+        uint64_t t;
+
+        s->tv_sec = d / HZ;
+        t = (d - s->tv_sec * HZ) * ONE_BILLION;
         s->tv_nsec = do_div (t, HZ);
 #else
-        s->tv_nsec = (d - s->tv_sec * HZ) * ONE_BILLION / HZ;
-#endif
         s->tv_sec = d / HZ;
+        s->tv_nsec = ((d - s->tv_sec * HZ) * ONE_BILLION) / HZ;
+#endif
+}
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+
+#define cfs_time_current_64 get_jiffies_64
+
+static inline __u64 cfs_time_add_64(__u64 t, __u64 d)
+{
+        return t + d;
+}
+
+static inline __u64 cfs_time_shift_64(int seconds)
+{
+        return cfs_time_add_64(cfs_time_current_64(),
+                               cfs_time_seconds(seconds));
 }
 
-static inline cfs_duration_t cfs_time_minimal_timeout(void)
+static inline int cfs_time_before_64(__u64 t1, __u64 t2)
 {
-        return 1;
+        return (__s64)t2 - (__s64)t1 > 0;
 }
 
-/* inline function cfs_time_minimal_timeout() can not be used
- * to initiallize static variable */
-#define CFS_MIN_DELAY           (1)
+#else
+#define cfs_time_current_64 cfs_time_current
+#define cfs_time_add_64     cfs_time_add
+#define cfs_time_shift_64   cfs_time_shift
+#define cfs_time_before_64  cfs_time_before
+
+#endif
+
+/*
+ * One jiffy
+ */
+#define CFS_TICK                (1)
 
 #define CFS_TIME_T              "%lu"
 #define CFS_DURATION_T          "%ld"
index 5050abc..1ddd03d 100644 (file)
@@ -18,9 +18,9 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <sys/time.h>
-#include <portals/types.h>
+#include <lnet/types.h>
 #include <libcfs/kp30.h>
-#include <portals/ptlctl.h>
+#include <lnet/lnetctl.h>
 #include <linux/limits.h>
 #include <asm/page.h>
 #include <linux/version.h>
index 31658d5..657c011 100644 (file)
@@ -5,7 +5,7 @@
 #define __LIBCFS_LINUX_PORTALS_COMPAT_H__
 
 // XXX BUG 1511 -- remove this stanza and all callers when bug 1511 is resolved
-#if SPINLOCK_DEBUG
+#if defined(SPINLOCK_DEBUG) && SPINLOCK_DEBUG
 # if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) || defined(CONFIG_RH_2_4_20)
 #  define SIGNAL_MASK_ASSERT() \
    LASSERT(current->sighand->siglock.magic == SPINLOCK_MAGIC)
@@ -44,6 +44,8 @@
 # define RECALC_SIGPENDING         recalc_sigpending()
 # define CLEAR_SIGPENDING          (current->sigpending = 0)
 # define CURRENT_SECONDS           CURRENT_TIME
+# define wait_event_interruptible_exclusive(wq, condition)              \
+        wait_event_interruptible(wq, condition)
 
 #else /* 2.4.x */
 
@@ -56,6 +58,8 @@
 # define RECALC_SIGPENDING         recalc_sigpending(current)
 # define CLEAR_SIGPENDING          (current->sigpending = 0)
 # define CURRENT_SECONDS           CURRENT_TIME
+# define wait_event_interruptible_exclusive(wq, condition)              \
+        wait_event_interruptible(wq, condition)
 
 #endif
 
 #endif
 
 #ifndef HAVE_CPU_ONLINE
-#define cpu_online(cpu) test_bit(cpu, &(cpu_online_map))
+#define cpu_online(cpu) ((1<<cpu) & (cpu_online_map))
 #endif
 #ifndef HAVE_CPUMASK_T
-#define cpu_set(cpu, map) set_bit(cpu, &(map))
 typedef unsigned long cpumask_t;
+#define cpu_set(cpu, map) set_bit(cpu, &(map))
+#define cpus_clear(map) memset(&(map), 0, sizeof(cpumask_t))
+#endif
+
+#ifndef __user
+#define __user
+#endif
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8)
+#define ll_proc_dointvec(table, write, filp, buffer, lenp, ppos)        \
+        proc_dointvec(table, write, filp, buffer, lenp)
+#define ll_proc_dostring(table, write, filp, buffer, lenp, ppos)        \
+        proc_dostring(table, write, filp, buffer, lenp)
+#define LL_PROC_PROTO(name)                                             \
+        name(ctl_table *table, int write, struct file *filp,            \
+             void __user *buffer, size_t *lenp)
+#else
+#define ll_proc_dointvec(table, write, filp, buffer, lenp, ppos)        \
+        proc_dointvec(table, write, filp, buffer, lenp, ppos);
+#define ll_proc_dostring(table, write, filp, buffer, lenp, ppos)        \
+        proc_dostring(table, write, filp, buffer, lenp, ppos);
+#define LL_PROC_PROTO(name)                                             \
+        name(ctl_table *table, int write, struct file *filp,            \
+             void __user *buffer, size_t *lenp, loff_t *ppos)
 #endif
 
 #endif /* _PORTALS_COMPAT_H */
index 0dd6c7e..ae319af 100644 (file)
@@ -14,7 +14,7 @@
 #include <linux/smp_lock.h>
 #include <linux/poll.h>
 #include <linux/random.h>
-                                                                                                                                                                      
+
 #include <asm/unistd.h>
 #include <asm/semaphore.h>
 
 
 #include <endian.h>
 #include <libcfs/list.h>
-                                                                                                                                                                      
+
 #ifdef HAVE_LINUX_VERSION_H
 # include <linux/version.h>
-                                                                                                                                                                      
+
 # if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
 #  define BUG()                            /* workaround for module.h includes */
 #  include <linux/module.h>
 # endif
 #endif /* !HAVE_LINUX_VERSION_H */
-                                                                                                                                                                      
+
 #ifndef __CYGWIN__
 # include <syscall.h>
 #else /* __CYGWIN__ */
@@ -47,5 +47,5 @@
 # include <netinet/in.h>
 #endif /* __CYGWIN__ */
 
-#endif /* !__KERNEL__ */
+#endif /* !__KERNEL__ */
 #endif